/* Wallet - Gold & Black Theme | Mobile-First Professional UI */
@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #0a0a0a;
  --bg-elevated: #111111;
  --surface: #1a1a1a;
  --surface-hover: #222222;
  --text: #f5f5f5;
  --text-muted: #888888;
  --gold: #d4af37;
  --gold-light: #e8c547;
  --gold-dark: #b8860b;
  --gold-gradient: linear-gradient(135deg, #d4af37 0%, #b8860b 50%, #8b6914 100%);
  --gold-glow: 0 0 20px rgba(212, 175, 55, 0.3);
  --primary: #d4af37;
  --primary-hover: #e8c547;
  --danger: #e74c3c;
  --danger-soft: rgba(231, 76, 60, 0.15);
  --success: #27ae60;
  --success-soft: rgba(39, 174, 96, 0.15);
  --border: #2a2a2a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.5);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-left: env(safe-area-inset-left, 0);
  --safe-right: env(safe-area-inset-right, 0);
}

* { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Prompt', system-ui, -apple-system, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  padding-bottom: var(--safe-bottom);
  font-weight: 400;
}

a { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }

/* Container - mobile first */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  padding-left: max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
  padding-bottom: max(1rem, calc(1rem + var(--safe-bottom)));
}
.container-wide { max-width: 960px; }

/* Nav Header */
.nav-header {
  background: var(--surface);
  padding: 0.875rem 1rem;
  padding-top: max(0.875rem, var(--safe-top));
  padding-left: max(1rem, var(--safe-left));
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.nav-header .menu-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.nav-header .menu-btn:hover { background: var(--surface-hover); color: var(--gold-light); }
.nav-header .menu-btn:active { transform: scale(0.96); }

.nav-header .app-title {
  flex: 1;
  font-weight: 700;
  font-size: 1.25rem;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  backdrop-filter: blur(4px);
}
.drawer-overlay.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 85vw);
  background: var(--surface);
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding-top: var(--safe-top);
}
.drawer-overlay.open .drawer { transform: translateX(0); }

.drawer-inner { padding: 0.5rem 0 2rem; }
.drawer .drawer-header {
  padding: 1.25rem 1.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
  color: var(--gold);
}

.drawer a,
.drawer .drawer-user {
  display: block;
  padding: 1rem 1.5rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), color var(--transition);
  font-size: 1rem;
  min-height: 48px;
  display: flex;
  align-items: center;
}
.drawer a:hover {
  background: var(--surface-hover);
  color: var(--gold);
}
.drawer a:active { background: var(--border); }
.drawer .drawer-user {
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 2px solid var(--border);
  margin-top: 0.5rem;
  min-height: auto;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  min-height: 48px;
  transition: all var(--transition);
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--gold-gradient);
  color: #0a0a0a;
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #e8c547 0%, #d4af37 100%);
  box-shadow: var(--gold-glow);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; filter: brightness(1.1); }
.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: rgba(212, 175, 55, 0.2); }
.card h2, .card .card-title { margin-top: 0; margin-bottom: 1rem; font-size: 1.1rem; font-weight: 600; color: var(--text); }
.card h2:first-child, .card .card-title:first-child { margin-top: 0; }

/* Form */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 48px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}
.form-group input::placeholder { color: var(--text-muted); }
.form-group select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }

/* Tables - mobile scroll */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  margin: 0 -0.25rem;
}
.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-track { background: var(--bg); border-radius: 3px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.table-responsive table { min-width: 520px; }
.table-responsive.table-wide table { min-width: 720px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.875rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { font-weight: 600; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
thead tr { background: rgba(255,255,255,0.03); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }
td.amount-cell { font-variant-numeric: tabular-nums; font-weight: 500; }
tr.row-deleted { opacity: 0.7; }
tr.row-deleted td { color: var(--text-muted); }
.col-datetime { white-space: nowrap; }
.col-note { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.col-muted { font-size: 0.8rem; }
.card-empty { text-align: center; }
.card-empty .empty-text { color: var(--text-muted); margin: 1.5rem 0; }

/* Amount colors */
.amount-income { color: var(--success); font-weight: 600; }
.amount-expense { color: var(--danger); font-weight: 600; }
.amount-neutral { color: var(--text); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}
.badge-income { background: var(--success-soft); color: var(--success); }
.badge-expense { background: var(--danger-soft); color: var(--danger); }
.badge-transfer { background: rgba(212, 175, 55, 0.2); color: var(--gold); }
.badge-neutral { background: rgba(136, 136, 136, 0.2); color: var(--text-muted); }

/* Page titles */
.container > h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.25rem 0;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* Filters */
.card-filters .filters-title { margin: 0 0 1rem 0; font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.filters { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.filters .form-group { margin-bottom: 0; flex: 1; min-width: 120px; }
.filters .btn-primary { flex-shrink: 0; }

/* Category list */
.cat-list { list-style: none; padding: 0; margin: 0 0 1rem 0; }
.cat-list li { display: flex; justify-content: space-between; align-items: center; padding: 0.875rem 0; border-bottom: 1px solid var(--border); }
.cat-list li:last-child { border-bottom: none; }
.cat-list h3 { margin: 1rem 0 0.5rem 0; font-size: 1rem; color: var(--text-muted); }
.cat-list h3:first-child { margin-top: 0; }

/* Actions */
.actions { white-space: nowrap; }
.actions .btn { margin-right: 0.35rem; font-size: 0.875rem; padding: 0.5rem 0.75rem; min-height: 40px; }
.btn-sm { padding: 0.5rem 0.875rem; min-height: 36px; font-size: 0.875rem; }

.error { color: var(--danger); font-size: 0.9rem; margin-top: 0.5rem; }
.text-muted { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }

/* Grid */
.grid { display: grid; gap: 1rem; }
@media (min-width: 480px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 640px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Dashboard wallet cards */
.section-wallets { margin-bottom: 1.5rem; }
.section-wallets h2 { margin: 0 0 1rem 0; font-size: 1.1rem; font-weight: 600; }

.wallet-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
@media (max-width: 380px) {
  .wallet-cards { grid-template-columns: 1fr; }
}

.wallet-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: all var(--transition);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.wallet-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gold-gradient);
}
.wallet-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--gold-glow), var(--shadow-card);
  border-color: rgba(212, 175, 55, 0.3);
}
.wallet-card:active { transform: translateY(-2px); }
.wallet-card .wallet-name { font-weight: 700; font-size: 1.1rem; }
.wallet-card .wallet-currency { font-size: 0.8rem; color: var(--text-muted); }
.wallet-card .wallet-balance { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.wallet-card .wallet-balance.positive { color: var(--success); }
.wallet-card .wallet-balance.negative { color: var(--danger); }
.wallet-cards .empty-msg { grid-column: 1 / -1; color: var(--text-muted); padding: 1.5rem; text-align: center; }
.wallet-cards .empty-msg a { color: var(--gold); font-weight: 500; }

/* Summary page */
.summary-result .summary-currency-block { min-width: 0; }
@media (min-width: 600px) {
  .summary-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
  .summary-result .summary-title { grid-column: 1 / -1; margin-bottom: 0.5rem; }
}

.summary-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.summary-tabs button {
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all var(--transition);
  min-height: 44px;
}
.summary-tabs button:hover { border-color: var(--gold); color: var(--gold); }
.summary-tabs button.active {
  background: var(--gold-gradient);
  color: #0a0a0a;
  border-color: var(--gold);
}
.period-row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.period-row .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* Login page */
.login-box { max-width: 400px; margin: 2rem auto; }
.login-box h1 {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Dashboard summary cards - inline style override */
.dashboard-summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
}
.dashboard-summary-card strong { color: var(--gold); }


/* Loading state */
#content:empty::after,
#list:empty::after,
#result:empty::after {
  content: 'กำลังโหลด...';
  color: var(--text-muted);
  display: block;
  padding: 2rem;
  text-align: center;
}
