/*
 * Living Ledger Design System
 * Budget Greens + Paper Neutrals
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --ll-primary: #00672f;
  --ll-primary-container: #00833e;
  --ll-primary-fixed: #8ef9a6;
  --ll-surface: #f8f9fa;
  --ll-surface-low: #f3f4f5;
  --ll-surface-lowest: #ffffff;
  --ll-surface-highest: #e1e3e4;
  --ll-on-surface: #191c1d;
  --ll-on-surface-variant: #3e4a3f;
  --ll-tertiary-container: #bb4c61;
  --ll-secondary-fixed: #baeed9;
  --ll-error: #ba1a1a;
  --ll-outline-variant: #becabc;
  --ll-shadow-ambient: 0 12px 32px rgba(25, 28, 29, 0.06);
}

html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
}

html,
body {
  background: var(--ll-surface);
  color: var(--ll-on-surface);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
}

/* ===== HEADER ===== */

.ll-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  background: var(--ll-surface-low);
  border-bottom: none;
  overflow: hidden;
}

.ll-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 800px;
  margin: 0 auto;
  padding: 14px 20px;
}

.ll-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ll-logo-text {
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: var(--ll-primary);
  letter-spacing: -0.01em;
}

.ll-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--ll-on-surface-variant);
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.ll-settings-btn:hover {
  background: var(--ll-surface-highest);
}

/* ===== MAIN CONTENT ===== */

.ll-main {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 20px 120px;
}

.ll-main--authed {
  padding-top: 20px;
}

/* ===== HERO BALANCE CARD ===== */

.hero-card {
  background: linear-gradient(135deg, var(--ll-primary) 0%, var(--ll-primary-container) 100%);
  color: white;
  padding: 28px 24px 24px;
  border-radius: 20px;
  margin-bottom: 28px;
  box-shadow: var(--ll-shadow-ambient);
}

.balance-label {
  font-family: "Inter", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 10px;
}

.hero-card .balance-amount {
  font-family: "Manrope", sans-serif;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-card-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  opacity: 0.9;
}

.hero-card-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ll-primary-fixed);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.hero-copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}

.hero-copy-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
}

.hero-copy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== SECTION HEADER ===== */

.ll-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 16px;
}

.ll-section-title {
  font-family: "Manrope", sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--ll-on-surface);
}

.ll-section-meta {
  font-size: 13px;
  color: var(--ll-on-surface-variant);
}

/* ===== DATE SECTION HEADERS ===== */

.date-section-header {
  font-family: "Manrope", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--ll-on-surface-variant);
  margin: 24px 0 10px 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== TRANSACTION CARD GROUP ===== */

.transaction-card-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

/* ===== TRANSACTION CARD ROW ===== */

.transaction-card-row {
  display: flex;
  align-items: center;
  padding: 16px;
  background: var(--ll-surface-lowest);
  border-radius: 16px;
  box-shadow: var(--ll-shadow-ambient);
  transition: box-shadow 0.15s ease;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.transaction-card-row:hover {
  box-shadow: 0 16px 40px rgba(25, 28, 29, 0.1);
}

/* ===== TRANSACTION ICON ===== */

.transaction-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ll-surface-low);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-right: 14px;
  flex-shrink: 0;
}

/* ===== TRANSACTION DETAILS ===== */

.transaction-details {
  flex: 1;
  min-width: 0;
}

.transaction-payee {
  font-weight: 600;
  color: var(--ll-on-surface);
  margin-bottom: 4px;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-meta {
  font-size: 13px;
  color: var(--ll-on-surface-variant);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.transaction-date {
  color: var(--ll-on-surface-variant);
}

.transaction-category {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-memo {
  font-style: italic;
  color: var(--ll-on-surface-variant);
  opacity: 0.8;
}

/* ===== TRANSACTION AMOUNT ===== */

.transaction-amount {
  font-family: "Manrope", sans-serif;
  font-weight: 700;
  font-size: 16px;
  margin-left: 12px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.amount-positive {
  color: var(--ll-primary);
}

.amount-negative {
  color: var(--ll-error);
}

/* ===== STATUS BADGES ===== */

.ll-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.6;
}

.ll-badge--synced {
  background: var(--ll-primary-fixed);
  color: #005225;
}

.ll-badge--pending {
  background: var(--ll-tertiary-container);
  color: #fff5f5;
}

.ll-badge--approved {
  background: var(--ll-secondary-fixed);
  color: #1d4f40;
}

.ll-badge--unmatched {
  background: #fde8ea;
  color: #ba1a1a;
}

/* ===== DAY TOTAL FOOTER ===== */

.day-total-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--ll-surface-low);
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ll-on-surface-variant);
  margin-bottom: 16px;
  min-width: 0;
}

/* ===== UNMATCHED TRANSACTIONS ===== */

.unmatched-card {
  background: rgba(186, 26, 26, 0.06);
  border: 1px solid rgba(186, 26, 26, 0.2);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
}

.unmatched-card h3 {
  color: var(--ll-error);
  margin-top: 0;
  margin-bottom: 16px;
  font-family: "Manrope", sans-serif;
  font-size: 16px;
  font-weight: 700;
}

/* ===== EMPTY STATE ===== */

.ll-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--ll-on-surface-variant);
}

.ll-empty-state-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.ll-empty-state-text {
  font-family: "Manrope", sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--ll-on-surface-variant);
}

/* ===== TOAST NOTIFICATIONS ===== */

#ll-toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.ll-toast {
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: white;
  box-shadow: 0 4px 16px rgba(25, 28, 29, 0.15);
  opacity: 1;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}

.ll-toast--success {
  background: var(--ll-primary);
}

.ll-toast--danger {
  background: var(--ll-error);
}

.ll-toast--hide {
  opacity: 0;
}

/* ===== SYNC STATUS ===== */

.sync-status-card {
  background: var(--ll-surface-lowest);
  border: none;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--ll-shadow-ambient);
}

/* ===== FLOATING ACTION BUTTON ===== */

.fab {
  position: fixed;
  bottom: 88px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ll-primary) 0%, var(--ll-primary-container) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(0, 103, 47, 0.35);
  cursor: pointer;
  border: none;
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 40;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 103, 47, 0.45);
}

.fab:active {
  transform: scale(0.95);
}

/* ===== BOTTOM NAV ===== */

.ll-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 50;
  background: rgba(248, 249, 250, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -4px 24px rgba(25, 28, 29, 0.08);
  overflow: hidden;
}

.ll-bottom-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  max-width: 800px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.ll-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 24px;
  border-radius: 999px;
  text-decoration: none;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: all 0.15s ease;
}

.ll-nav-item--active {
  background: var(--ll-primary-container);
  color: white;
}

.ll-nav-item--active svg {
  stroke: white;
}

/* ===== PAGINATION ===== */

.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 20px 0;
  margin-bottom: 16px;
  overflow-x: auto;
}

.pagination a,
.pagination span {
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--ll-surface-lowest);
  border: 1px solid var(--ll-outline-variant);
  color: var(--ll-on-surface);
  text-decoration: none;
  font-size: 14px;
  transition: background-color 0.15s ease;
}

.pagination a:hover {
  background: var(--ll-surface-low);
}

.pagination .current {
  background: var(--ll-primary);
  border-color: transparent;
  color: white;
}

/* ===== GLOBAL BUTTON RESET ===== */

button:not(.fab):not(.ll-nav-item):not(.hero-copy-btn),
[type="submit"]:not(.fab) {
  background: var(--ll-primary);
  border-color: transparent;
  color: white;
  font-family: "Inter", sans-serif;
}

button:not(.fab):not(.ll-nav-item):not(.hero-copy-btn):hover,
[type="submit"]:not(.fab):hover {
  opacity: 0.9;
}

button[data-variant="secondary"],
button.outline {
  background: transparent;
  border: 1px solid var(--ll-outline-variant);
  color: var(--ll-on-surface);
}

button[data-variant="secondary"]:hover,
button.outline:hover {
  background: var(--ll-surface-low);
  opacity: 1;
}

button[data-variant="danger"] {
  background: var(--ll-error);
  border-color: transparent;
  color: white;
}

/* ===== TABLES ===== */

table {
  background: var(--ll-surface-lowest);
  border: 1px solid var(--ll-outline-variant);
  border-radius: 12px;
  overflow: hidden;
}

table thead {
  background: var(--ll-surface-low);
}

table tbody tr {
  border-bottom-color: var(--ll-outline-variant);
}

table tbody tr:hover {
  background: var(--ll-surface-low);
}

/* ===== CONTAINER ===== */

.container {
  max-width: 800px;
}

/* ===== MOBILE ===== */

@media (max-width: 768px) {
  .ll-main {
    padding: 12px 12px 120px;
  }

  .ll-header-inner {
    padding: 12px 16px;
  }

  .hero-card {
    border-radius: 16px;
    padding: 20px 16px 16px;
  }

  .hero-card .balance-amount {
    font-size: 34px;
  }

  .transaction-card-row {
    padding: 12px;
  }

  .transaction-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
    margin-right: 10px;
  }

  .date-section-header {
    margin-top: 20px;
  }

  .ll-nav-item {
    padding: 8px 16px;
  }
}
