/* ══════════════════════════════════════════════════════════════════
   Exelyxis Invoice App — Dark Theme
   Colors: #0A0A0A bg, #141414 surface, #F5A623 orange, #FFFFFF text
═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg:         #0A0A0A;
  --surface:    #141414;
  --surface2:   #1c1c1c;
  --border:     #2a2a2a;
  --orange:     #F5A623;
  --orange-dk:  #d4891a;
  --text:       #f0f0f0;
  --text-muted: #888;
  --text-dim:   #555;
  --success:    #22c55e;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --info:       #3b82f6;
  --sidebar-w:  240px;
  --topbar-h:   56px;
  --radius:     8px;
  --radius-sm:  4px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar logo ────────────────────────────────────────────────── */
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-img { max-height: 36px; max-width: 180px; object-fit: contain; }
.logo-text { font-size: 18px; font-weight: 800; color: var(--orange); letter-spacing: 1px; }
.logo-x { color: var(--text-muted); margin-right: 4px; }
.logo-tagline { display: block; font-size: 11px; color: var(--text-muted); margin-top: 4px;
                letter-spacing: 1px; text-transform: uppercase; }

/* ── Sidebar nav ─────────────────────────────────────────────────── */
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: color .15s, background .15s;
  border-left: 3px solid transparent;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--orange); border-left-color: var(--orange);
                    background: rgba(245,166,35,.07); }
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--text); }

/* ── Page body ───────────────────────────────────────────────────── */
.page-body { padding: 24px 28px; flex: 1; }

/* ══════════════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════════════ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) { .cards-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px)  { .cards-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.card--orange { border-left: 3px solid var(--orange); }
.card-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 8px; }
.card-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.card--orange .card-value { color: var(--orange); }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 24px;
  overflow: hidden;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.section-title { font-size: 15px; font-weight: 600; }

/* ══════════════════════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead tr { border-bottom: 1px solid var(--border); }
.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.data-table tbody tr:hover { background: var(--surface2); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody td { padding: 11px 16px; font-size: 13.5px; }
.data-table .mono { font-family: monospace; font-size: 12px; color: var(--orange); }
.data-table .amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.row--overdue { background: rgba(239,68,68,.04); }
.row--muted td { opacity: .5; }

/* ══════════════════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px; font-weight: 600;
  text-transform: capitalize;
}
.badge--draft     { background: rgba(136,136,136,.2); color: #aaa; }
.badge--scheduled { background: rgba(168,85,247,.2);  color: #c084fc; }
.badge--sent      { background: rgba(59,130,246,.2);  color: #60a5fa; }
.badge--paid      { background: rgba(34,197,94,.2);   color: #4ade80; }
.badge--overdue   { background: rgba(239,68,68,.2);   color: #f87171; }
.badge--neutral   { background: rgba(245,166,35,.15); color: var(--orange); }
.badge-sub { font-size: 11px; color: var(--text-muted); margin-left: 4px; }

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--orange); color: #0A0A0A; }
.btn-primary:hover { background: var(--orange-dk); }
.btn-ghost { background: transparent; color: var(--text-muted);
             border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: #444; background: var(--surface2); }
.btn--sm { padding: 5px 12px; font-size: 12.5px; }
.btn--full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* Action icon buttons */
.actions-cell { white-space: nowrap; }
.action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: none; border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text-muted);
  cursor: pointer; text-decoration: none;
  transition: color .1s, background .1s;
  margin-right: 4px;
}
.action-btn svg { width: 15px; height: 15px; fill: currentColor; }
.action-btn:hover { background: #2a2a2a; color: var(--text); }
.action-btn--green:hover { color: var(--success); }
.action-btn--red:hover   { color: var(--danger); }

/* ══════════════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════════════ */
.form-control {
  display: block; width: 100%;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color .15s;
  outline: none;
}
.form-control:focus { border-color: var(--orange); }
.form-control::placeholder { color: var(--text-dim); }
.form-control--sm { width: auto; padding: 6px 10px; font-size: 13px; }
select.form-control { cursor: pointer; appearance: auto; }
textarea.form-control { resize: vertical; }
input[type="file"].form-control { padding: 6px; cursor: pointer; }

.form-label { display: block; font-size: 12px; font-weight: 600;
              text-transform: uppercase; letter-spacing: .7px;
              color: var(--text-muted); margin-bottom: 6px; }
.form-hint { display: block; font-size: 11px; color: var(--text-dim); margin-top: 5px; }
.form-hint code { background: var(--surface2); border: 1px solid var(--border); border-radius: 3px;
                  padding: 1px 5px; font-size: 10px; color: var(--orange); font-family: monospace; }
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.form-card-title { font-size: 14px; font-weight: 700; margin-bottom: 16px;
                   padding-bottom: 10px; border-bottom: 1px solid var(--border); }

.form-actions { display: flex; gap: 12px; margin-top: 4px; }
.form-actions-stack { display: flex; flex-direction: column; gap: 10px; }

.form-page-wrapper { max-width: 820px; }

/* ── Two-column layout ───────────────────────────────────────────── */
.two-col-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .two-col-layout { grid-template-columns: 1fr; } }
.col-main {}
.col-side {}

/* ══════════════════════════════════════════════════════════════════
   LINE ITEMS TABLE (create/edit invoice)
═══════════════════════════════════════════════════════════════════ */
.items-edit-table { width: 100%; border-collapse: collapse; }
.items-edit-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.items-edit-table td { padding: 6px 4px; vertical-align: middle; }
.remove-item-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1;
  transition: color .1s;
}
.remove-item-btn:hover { color: var(--danger); }

/* ══════════════════════════════════════════════════════════════════
   TOTALS SUMMARY (create invoice sidebar)
═══════════════════════════════════════════════════════════════════ */
.totals-summary {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 8px;
}
.totals-line {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--text-muted);
  padding: 4px 0;
}
.totals-line--total {
  font-size: 15px; font-weight: 800; color: var(--orange);
  border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   TOGGLE SWITCH
═══════════════════════════════════════════════════════════════════ */
.toggle-label { display: flex; align-items: center; gap: 10px; cursor: pointer;
                font-size: 13.5px; font-weight: 500; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-switch {
  width: 40px; height: 22px; flex-shrink: 0;
  background: var(--border);
  border-radius: 99px;
  position: relative;
  transition: background .2s;
}
.toggle-switch::after {
  content: ''; position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-input:checked + .toggle-switch { background: var(--orange); }
.toggle-input:checked + .toggle-switch::after { transform: translateX(18px); }

/* ══════════════════════════════════════════════════════════════════
   FILTER BAR
═══════════════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 14px 20px;
}

/* ══════════════════════════════════════════════════════════════════
   FLASH MESSAGES
═══════════════════════════════════════════════════════════════════ */
.flash-container { padding: 12px 28px 0; }
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  margin-bottom: 8px;
}
.flash--success { background: rgba(34,197,94,.15); color: #4ade80; border: 1px solid rgba(34,197,94,.3); }
.flash--error   { background: rgba(239,68,68,.15);  color: #f87171; border: 1px solid rgba(239,68,68,.3); }
.flash--warning { background: rgba(245,158,11,.15); color: #fbbf24; border: 1px solid rgba(245,158,11,.3); }
.flash--info    { background: rgba(59,130,246,.15);  color: #60a5fa; border: 1px solid rgba(59,130,246,.3); }
.flash-close { background: none; border: none; color: inherit; font-size: 18px;
               cursor: pointer; padding: 0; opacity: .7; line-height: 1; }
.flash-close:hover { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state a { color: var(--orange); text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════════════
   CUSTOMER DISPLAY (edit recurring)
═══════════════════════════════════════════════════════════════════ */
.customer-display { padding: 4px 0; }
.customer-name { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.customer-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-muted); }
.customer-meta span::before { content: '·'; margin-right: 6px; color: var(--text-dim); }
.customer-meta span:first-child::before { display: none; }

/* ══════════════════════════════════════════════════════════════════
   ITEM PILLS (active invoices)
═══════════════════════════════════════════════════════════════════ */
.item-pill {
  display: inline-block;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  margin: 2px 2px 2px 0;
  border: 1px solid var(--border);
}
