/* ============================================================
   Gig Export — Stylesheet
   Matches the Mark's Music Tools design system (light / dark)
   ============================================================ */

/* ── 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:      #2e3355;
  --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.4rem; gap: 1rem;
}
[data-theme="dark"] .nav {
  background: #080a14;
  border-bottom: 2px solid #3a4070;
}
.nav-brand {
  font-weight: 700; font-size: 1.05rem; color: var(--text);
  text-decoration: none; display: flex; align-items: center; gap: .55rem;
}
.nav-brand svg { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; }
[data-theme="dark"] .nav-brand { color: #ffffff; }
.nav-back {
  font-size: .85rem; color: var(--text-muted);
  display: flex; align-items: center; gap: .3rem;
  text-decoration: none;
}
.nav-back:hover { color: var(--accent); text-decoration: none; }
.nav-spacer { flex: 1; }
.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; cursor: pointer;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon svg { width: 18px; height: 18px; }
[data-theme="dark"] .btn-icon { color: #ffffff; }

/* ── Page body ─────────────────────────────────────────────── */
.page-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.4rem 4rem;
}
.page-header { margin-bottom: 1.8rem; }
.page-title  { font-size: 1.4rem; font-weight: 700; }
.page-subtitle { font-size: .9rem; color: var(--text-muted); margin-top: .25rem; }
[data-theme="dark"] .page-title    { color: #ffffff; }
[data-theme="dark"] .page-subtitle { color: #b8c4e0; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem 1.1rem; font-size: .9rem; font-weight: 600;
  border-radius: var(--radius-sm); border: none; cursor: pointer;
  transition: background var(--trans), opacity var(--trans), transform var(--trans);
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 16px; height: 16px; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hov); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hov); }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

[data-theme="dark"] .btn-secondary {
  background: #1c2035; color: #ffffff; border-color: #3a4070;
}
[data-theme="dark"] .btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] .btn-ghost {
  color: #b8c4e0; border-color: #3a4070;
}
[data-theme="dark"] .btn-ghost:hover { color: var(--accent); border-color: var(--accent); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .85rem 1.1rem; border-radius: var(--radius);
  border: 1px solid; font-size: .88rem; margin-bottom: 1.2rem;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #f0faf5; border-color: #a8dfc0; color: #1a5c36; }
.alert-error   { background: #fff5f5; border-color: #fca5a5; color: #7f1d1d; }
.alert-info    { background: #f0f4ff; border-color: #a5b4fc; color: #1e3a5f; }
.alert-warning { background: #fffbeb; border-color: #fcd34d; color: #78350f; }
[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; }

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

/* ── Form controls ──────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
.form-control {
  width: 100%; padding: .5rem .75rem; font-size: .9rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color var(--trans);
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }
[data-theme="dark"] .form-control { background: #0e1020; border-color: #3a4070; color: #ffffff; }
[data-theme="dark"] .form-control:focus { border-color: var(--accent); }

/* ── Date inputs ───────────────────────────────────────────────
   color-scheme tells the browser to render the native date-picker
   (calendar icon + popup) in a palette matching light/dark mode —
   without this, the picker icon is nearly invisible on a dark
   background in Chrome/Edge. Also make the whole field clickable
   (not just the tiny icon) via JS calling showPicker(). */
input[type="date"] { color-scheme: light; cursor: pointer; }
[data-theme="dark"] input[type="date"] { color-scheme: dark; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; }
[data-theme="dark"] .form-label { color: #ffffff; }
[data-theme="dark"] .form-hint  { color: #b8c4e0; }

/* ── Connect screen ─────────────────────────────────────────── */
.connect-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - var(--nav-h));
  padding: 2rem;
}
.connect-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  max-width: 440px; width: 100%;
  text-align: center;
}
.connect-icon {
  width: 56px; height: 56px;
  color: var(--accent);
  margin: 0 auto 1.2rem;
}
.connect-title { font-size: 1.3rem; font-weight: 700; margin-bottom: .5rem; }
.connect-desc  { font-size: .9rem; color: var(--text-muted); margin-bottom: 1.8rem; line-height: 1.6; }
.btn-google {
  display: inline-flex; align-items: center; gap: .75rem;
  padding: .75rem 1.5rem; font-size: .95rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
  box-shadow: var(--shadow-md); transition: box-shadow var(--trans), border-color var(--trans);
  width: 100%; justify-content: center;
}
.btn-google:hover { box-shadow: 0 4px 20px rgba(0,0,0,.15); border-color: var(--accent); }
.btn-google svg  { width: 22px; height: 22px; }
[data-theme="dark"] .connect-card { background: var(--surface); }
[data-theme="dark"] .connect-title { color: #ffffff; }
[data-theme="dark"] .connect-desc  { color: #b8c4e0; }
[data-theme="dark"] .btn-google    { background: #1c2035; border-color: #3a4070; color: #ffffff; }

/* ── Toolbar (search + date range) ──────────────────────────── */
.toolbar {
  display: flex; align-items: flex-end; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.4rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.2rem;
}
[data-theme="dark"] .toolbar { background: var(--surface); border-color: var(--border); }

/* ── Results table ─────────────────────────────────────────── */
.results-table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
table.results-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.results-table th, .results-table td {
  text-align: left; padding: .6rem .85rem; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.results-table th {
  font-weight: 600; color: var(--text-muted); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .04em; background: var(--surface2);
}
.results-table tbody tr:last-child td { border-bottom: none; }
.results-table tr.excluded { opacity: .4; }
.results-table tr.excluded .ev-title { text-decoration: line-through; }
.results-table td.ev-checkbox { width: 34px; }
.results-table td.ev-when { white-space: nowrap; }
.results-table .ev-title { font-weight: 600; }
.results-table .ev-location { color: var(--text-muted); }
.results-table .ev-venue { color: var(--text-muted); white-space: nowrap; }
.results-table td.ev-num, .results-table th.ev-num { text-align: right; white-space: nowrap; }
.results-table td.ev-num { font-variant-numeric: tabular-nums; }
[data-theme="dark"] .results-table th { background: var(--surface2); }

.results-totals-row td {
  font-weight: 700; border-bottom: none; border-top: 2px solid var(--border);
  background: var(--surface2);
}
[data-theme="dark"] .results-totals-row td { background: var(--surface2); }

.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted); font-size: .9rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.empty-state svg { width: 40px; height: 40px; margin: 0 auto .75rem; display: block; opacity: .4; }

/* Spinner */
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Calendar picker — prominent, always-visible ──────────────── */
.cal-picker-group {
  max-width: 380px;
  margin-bottom: 1.2rem;
}
.cal-picker-group .form-label {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 700;
}
.cal-picker-group .cal-select {
  font-weight: 600; font-size: .95rem; padding: .6rem .8rem;
  border-width: 2px;
}
.cal-picker-group .cal-select:focus { border-color: var(--accent); }

/* ── Settings accordion ────────────────────────────────────────
   Structure: .accordion > .accordion-header (button) + .accordion-panel-wrap
   .accordion-panel-wrap is a grid whose row track animates between 0fr/1fr —
   a modern, JS-free way to smoothly animate to/from "auto" height. Its direct
   child (.accordion-panel-clip) carries the overflow:hidden and nothing else
   (no border/background/padding), so at 0fr it collapses to a true zero-height
   box with no visual artifact; the actual bordered/padded panel is nested one
   level deeper (.settings-drawer) and simply gets clipped away entirely when
   closed. */
.accordion { margin-bottom: 1.2rem; }
.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; gap: .5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .9rem;
  font-size: .85rem; font-weight: 600; color: var(--text);
  cursor: pointer; transition: border-color var(--trans), color var(--trans);
}
.accordion-header:hover { border-color: var(--accent); color: var(--accent); }
.accordion-header-title { display: flex; align-items: center; gap: .5rem; }
.accordion-header-title svg { color: var(--text-muted); flex-shrink: 0; }
.accordion-header:hover .accordion-header-title svg { color: var(--accent); }
.accordion-chevron { color: var(--text-muted); flex-shrink: 0; transition: transform .2s ease, color var(--trans); }
.accordion-header[aria-expanded="true"] .accordion-chevron { transform: rotate(180deg); }
.accordion-header:hover .accordion-chevron { color: var(--accent); }
[data-theme="dark"] .accordion-header { background: #1c2035; border-color: #3a4070; color: #ffffff; }

.accordion-panel-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .25s ease;
}
.accordion-panel-wrap.open { grid-template-rows: 1fr; }
.accordion-panel-clip { overflow: hidden; }

.settings-drawer {
  margin-top: .6rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem;
}
[data-theme="dark"] .settings-drawer { background: #1c2035; border-color: #3a4070; }

.cal-select {
  width: 100%; padding: .5rem .75rem; font-size: .9rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.cal-select:focus { outline: none; border-color: var(--accent); }
[data-theme="dark"] .cal-select { background: #0e1020; border-color: #3a4070; color: #ffffff; }

/* ── Venue rates ───────────────────────────────────────────────── */
.venues-list { margin-bottom: .8rem; display: flex; flex-direction: column; gap: .4rem; }
.venues-empty { font-size: .85rem; color: var(--text-muted); font-style: italic; margin-bottom: .8rem; }
.venue-row {
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .5rem .75rem; font-size: .85rem;
}
.venue-row-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.venue-row-detail { color: var(--text-muted); white-space: nowrap; min-width: 70px; text-align: right; }
.venue-row .venue-delete-btn:hover { color: var(--danger); background: rgba(231,76,60,.08); }
[data-theme="dark"] .venue-row { background: #0e1020; border-color: #3a4070; }

.venue-form-row {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
}
.venue-form-row .form-control { width: auto; flex: 1; min-width: 140px; }
#venue-km-input, #venue-income-input { max-width: 150px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
  .page-wrap { padding: 1.2rem 1rem 3rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .form-group { margin-bottom: .6rem; }
  .results-table .ev-location { display: none; }
  .nav { padding: 0 1rem; }
  .venue-form-row { flex-direction: column; align-items: stretch; }
  .venue-form-row .form-control, #venue-km-input, #venue-income-input { max-width: none; }
}
