/* ============================================================
   Band Invoice Generator — Stylesheet
   Light / Dark mode via CSS custom properties
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #f5f6fa;
  --surface:     #ffffff;
  --surface2:    #f0f1f7;
  --border:      #e2e5ef;
  --text:        #1a1d2e;
  --text-muted:  #6b7280;
  --accent:      #4f6ef7;
  --accent-hov:  #3a56d4;
  --danger:      #e74c3c;
  --danger-hov:  #c0392b;
  --success:     #27ae60;
  --warning:     #f39c12;
  --radius:      8px;
  --radius-sm:   5px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.12);
  --nav-h:       56px;
  --trans:       .18s ease;
}

[data-theme="dark"] {
  --bg:          #0b0d16;
  --surface:     #14172a;
  --surface2:    #1c2035;
  --border:      #5a6090;
  --text:        #ffffff;
  --text-muted:  #b8c4e0;
  --accent:      #8aaafe;
  --accent-hov:  #6f8ffd;
  --shadow:      0 1px 4px rgba(0,0,0,.5);
  --shadow-md:   0 4px 16px rgba(0,0,0,.6);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background var(--trans), color var(--trans);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Nav ───────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; align-items: center; padding: 0 1.2rem; gap: .8rem;
}
[data-theme="dark"] .nav {
  background: #080a14;
  border-bottom: 2px solid #3a4070;
}
.nav-back {
  display: flex; align-items: center; gap: .35rem;
  font-size: .82rem; color: var(--text-muted);
  text-decoration: none; padding: .3rem .5rem; border-radius: var(--radius-sm);
  transition: background var(--trans), color var(--trans); flex-shrink: 0;
}
.nav-back:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-sep { color: var(--border); font-size: .9rem; flex-shrink: 0; }
.nav-brand {
  font-weight: 700; font-size: 1rem; color: var(--text);
  text-decoration: none; display: flex; align-items: center; gap: .45rem;
}
.nav-brand svg { width: 20px; height: 20px; color: var(--accent); }
[data-theme="dark"] .nav-brand { color: #fff; }
.nav-spacer { flex: 1; }
.nav-links { display: flex; gap: .3rem; align-items: center; }
.nav-links a {
  padding: .32rem .75rem; border-radius: var(--radius-sm);
  font-size: .84rem; color: var(--text-muted);
  transition: background var(--trans), color var(--trans);
  text-decoration: none;
}
.nav-links a:hover { background: var(--surface2); color: var(--text); }
.nav-links a.active { color: var(--accent); font-weight: 600; }
[data-theme="dark"] .nav-links a { color: #b8c4e0; }
[data-theme="dark"] .nav-links a:hover { background: #1c2035; color: #fff; }
[data-theme="dark"] .nav-links a.active { color: var(--accent); }
.nav-user { font-size: .82rem; color: var(--text-muted); }

/* Hamburger */
.nav-hamburger {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  background: none; border: none; padding: .4rem; cursor: pointer; flex-shrink: 0;
}
.nav-hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Dark mode toggle */
.btn-icon {
  background: none; border: none; padding: .4rem; border-radius: var(--radius-sm);
  color: var(--text-muted); transition: background var(--trans), color var(--trans);
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon svg { width: 18px; height: 18px; }
[data-theme="dark"] .btn-icon { color: #fff; }

/* ── Page wrap ─────────────────────────────────────────────── */
.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.4rem 4rem;
}
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.8rem;
}
.page-title { font-size: 1.35rem; font-weight: 700; }
.page-subtitle { font-size: .88rem; color: var(--text-muted); margin-top: .2rem; }
[data-theme="dark"] .page-title { color: #fff; }
[data-theme="dark"] .page-subtitle { color: var(--text-muted); }

/* Section label */
.section-label {
  font-size: .72rem; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 1rem; font-weight: 600;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .48rem 1.1rem; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 500; border: none;
  transition: background var(--trans), color var(--trans), box-shadow var(--trans);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hov); color: #fff; }

.btn-secondary {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
[data-theme="dark"] .btn-secondary { background: #1c2035; color: #fff; border-color: #5a6090; }
[data-theme="dark"] .btn-secondary:hover { background: #2a3060; }

.btn-danger {
  background: var(--danger); color: #fff;
}
.btn-danger:hover { background: var(--danger-hov); color: #fff; }

.btn-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); }
[data-theme="dark"] .btn-ghost { color: #fff; border-color: #5a6090; }
[data-theme="dark"] .btn-ghost:hover { background: #1c2035; }

.btn-sm { padding: .3rem .75rem; font-size: .8rem; }

/* ── Auth pages ────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 2.2rem; width: 100%; max-width: 420px;
}
.auth-logo {
  text-align: center; margin-bottom: 1.8rem;
}
.auth-logo svg { margin-bottom: .6rem; }
.auth-logo h1 { font-size: 1.2rem; font-weight: 700; margin-bottom: .2rem; }
.auth-logo p { font-size: .88rem; color: var(--text-muted); }
[data-theme="dark"] .auth-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .auth-logo h1 { color: #fff; }
.auth-footer {
  text-align: center; margin-top: 1.4rem;
  font-size: .85rem; color: var(--text-muted);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block; font-size: .85rem; font-weight: 500;
  margin-bottom: .35rem; color: var(--text);
}
[data-theme="dark"] .form-label { color: #fff; }
.form-control {
  width: 100%; padding: .55rem .75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: .9rem;
  transition: border-color var(--trans), background var(--trans);
}
.form-control:focus { outline: none; border-color: var(--accent); }
[data-theme="dark"] .form-control {
  background: #12152a; border-color: #5a6090; color: #fff;
}
[data-theme="dark"] .form-control:focus { border-color: var(--accent); background: #1a1e38; }
[data-theme="dark"] .form-control::placeholder { color: #8090b8; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
[data-theme="dark"] .form-hint { color: #b8c4e0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .75rem 1rem; border-radius: var(--radius-sm);
  font-size: .88rem; border: 1px solid transparent; margin-bottom: 1rem;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: .1rem; }
.alert-success { background: #edfbf1; border-color: #a8e6bc; color: #1a6e35; }
.alert-error   { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
[data-theme="dark"] .alert-success { background: #0e2a1a; border-color: #2a6a40; color: #80e8a8; }
[data-theme="dark"] .alert-error   { background: #2a0e0e; border-color: #8a2a2a; color: #ff9090; }
[data-theme="dark"] .alert-info    { background: #0e1e2e; border-color: #2a60a8; color: #80c8f8; }
[data-theme="dark"] .alert-warning { background: #2a1e08; border-color: #8a6018; color: #ffd060; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
[data-theme="dark"] .card { background: var(--surface); border-color: var(--border); }
.card-header {
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .6rem;
  font-weight: 600; font-size: .95rem;
}
[data-theme="dark"] .card-header { border-color: var(--border); }
.card-body { padding: 1.2rem; }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse; font-size: .88rem;
}
th {
  text-align: left; padding: .65rem 1rem;
  font-size: .75rem; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  background: var(--surface2); white-space: nowrap;
}
td {
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
[data-theme="dark"] th { background: #1c2035; border-color: var(--border); }
[data-theme="dark"] td { border-color: #2e3355; }
[data-theme="dark"] tr:hover td { background: #1c2035; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .18rem .6rem;
  border-radius: 20px; font-size: .75rem; font-weight: 600;
  letter-spacing: .3px; white-space: nowrap;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-grey   { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-blue   { background: #dbeafe; color: #1e40af; }
[data-theme="dark"] .badge-green  { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-orange { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-red    { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-grey   { background: #1c2035; color: #b8c4e0; }
[data-theme="dark"] .badge-blue   { background: #1e3a5f; color: #93c5fd; }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
[data-theme="dark"] .empty-state h3 { color: #fff; }
.empty-state p { font-size: .88rem; }

/* ── Toolbar ───────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: .6rem;
  flex-wrap: wrap; margin-bottom: 1.2rem;
}
.toolbar-spacer { flex: 1; }
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search-wrap svg {
  position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-muted); pointer-events: none;
}
.search-input {
  width: 100%; padding: .48rem .75rem .48rem 2.1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: .88rem;
}
.search-input:focus { outline: none; border-color: var(--accent); }
[data-theme="dark"] .search-input { background: #12152a; border-color: #5a6090; color: #fff; }
[data-theme="dark"] .search-input:focus { border-color: var(--accent); }
[data-theme="dark"] .search-input::placeholder { color: #8090b8; }

/* Filter select */
.filter-select {
  padding: .45rem .75rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: .88rem;
}
.filter-select:focus { outline: none; border-color: var(--accent); }
[data-theme="dark"] .filter-select { background: #12152a; border-color: #5a6090; color: #fff; }

/* ── Status actions dropdown ───────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: 100%; min-width: 150px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  z-index: 200; padding: .3rem 0; margin-top: .25rem;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: block; width: 100%; padding: .45rem 1rem;
  font-size: .85rem; color: var(--text); background: none; border: none;
  text-align: left; text-decoration: none; white-space: nowrap;
  transition: background var(--trans);
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface2); }
.dropdown-menu .divider { border-top: 1px solid var(--border); margin: .3rem 0; }
[data-theme="dark"] .dropdown-menu { background: #10142a; border-color: #5a6090; }
[data-theme="dark"] .dropdown-menu a,
[data-theme="dark"] .dropdown-menu button { color: #fff; }
[data-theme="dark"] .dropdown-menu a:hover,
[data-theme="dark"] .dropdown-menu button:hover { background: #2a3060; }

/* ── Stats row ─────────────────────────────────────────────── */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem; margin-bottom: 1.8rem;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.stat-label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .8px; font-weight: 600; margin-bottom: .3rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
[data-theme="dark"] .stat-value { color: #fff; }
.stat-sub { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 300; align-items: center; justify-content: center; padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
[data-theme="dark"] .modal { background: #14172a; border-color: #5a6090; }
.modal-header {
  padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 1rem;
}
[data-theme="dark"] .modal-header { border-color: #5a6090; color: #fff; }
.modal-close {
  background: none; border: none; color: var(--text-muted); font-size: 1.3rem;
  line-height: 1; padding: .1rem;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.3rem; }
.modal-footer {
  padding: .9rem 1.3rem; border-top: 1px solid var(--border);
  display: flex; gap: .6rem; justify-content: flex-end;
}
[data-theme="dark"] .modal-footer { border-color: #5a6090; }

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: .75rem 1.1rem; font-size: .88rem;
  display: flex; align-items: center; gap: .5rem;
  animation: slideIn .2s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .page-wrap { padding: 1.2rem 1rem 3rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
  .nav-links.mobile-open {
    display: flex; flex-direction: column;
    position: fixed; top: var(--nav-h); left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: .5rem; z-index: 99; box-shadow: var(--shadow-md);
  }
  .nav-links.mobile-open a {
    padding: .6rem 1rem; border-radius: var(--radius-sm);
  }
  table { font-size: .82rem; }
  td, th { padding: .6rem .75rem; }
  .page-header { flex-direction: column; gap: .8rem; }
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:none; }
}
.fade-up { animation: fadeUp .3s ease both; }
