/* ============================================================
   QuoteTool — app.css
   Design: Clean industrial / utility aesthetic — monochrome
   base with a sharp steel-blue accent, mono numerals, tight grid
   ============================================================ */

/* ---- Tokens ------------------------------------------------ */
:root {
  --bg:           #0f1117;
  --surface:      #181c26;
  --surface-alt:  #1e2333;
  --border:       #2a2f42;
  --border-light: #333a52;

  --accent:       #4f8ef7;
  --accent-dim:   #2d5bbf;
  --accent-glow:  rgba(79,142,247,.15);

  --text-primary:   #e8eaf0;
  --text-secondary: #8a91a8;
  --text-muted:     #555e7a;

  --green:  #3ecf8e;
  --red:    #f7644f;
  --yellow: #f5c842;
  --purple: #a374f7;

  --font-body:  'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --radius:   6px;
  --radius-lg: 10px;
  --sidebar-w: 220px;
  --topbar-h:  56px;
}

/* ---- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: .03em;
  color: var(--text-primary);
}
.brand-icon { font-size: 1.3rem; color: var(--accent); }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-list { padding: 12px 0; flex: 1; }
.nav-list li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  transition: color .15s, background .15s;
  border-left: 3px solid transparent;
}
.nav-list li a:hover { color: var(--text-primary); background: var(--surface-alt); text-decoration: none; }
.nav-list li.active a {
  color: var(--accent);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}
.nav-icon { font-size: .75rem; opacity: .6; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.btn-logout {
  display: block;
  text-align: center;
  padding: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: .8rem;
  transition: all .15s;
}
.btn-logout:hover { color: var(--red); border-color: var(--red); text-decoration: none; }

/* ---- Main content ------------------------------------------ */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  z-index: 50;
}
.page-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text-primary);
}
.page-body {
  padding: 28px;
  flex: 1;
}

/* ---- Cards ------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: .875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-secondary);
}

/* ---- Stat tiles ------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.stat-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}
.stat-tile.accent .stat-value { color: var(--accent); }
.stat-tile.green  .stat-value { color: var(--green); }
.stat-tile.yellow .stat-value { color: var(--yellow); }
.stat-tile.red    .stat-value { color: var(--red); }

/* ---- Tables ----------------------------------------------- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}
tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-alt); color: var(--text-primary); }
td.mono { font-family: var(--font-mono); font-size: .82rem; }
td.amount { font-family: var(--font-mono); text-align: right; }
thead th.amount { text-align: right; }

/* ---- Badges ----------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.badge-draft    { background: rgba(138,145,168,.15); color: var(--text-secondary); }
.badge-sent     { background: rgba(79,142,247,.15);  color: var(--accent); }
.badge-accepted { background: rgba(62,207,142,.15);  color: var(--green); }
.badge-declined { background: rgba(247,100,79,.15);  color: var(--red); }
.badge-expired  { background: rgba(245,200,66,.15);  color: var(--yellow); }
.badge-invoiced { background: rgba(163,116,247,.15); color: var(--purple); }

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover { color: var(--text-primary); border-color: var(--border-light); }
.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover { background: rgba(247,100,79,.1); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-icon { padding: 6px 8px; }

/* ---- Forms ------------------------------------------------ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px 20px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  font-weight: 600;
}
input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: .875rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--surface); }

/* ---- Alerts ----------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: .875rem;
  border: 1px solid transparent;
}
.alert-success { background: rgba(62,207,142,.1); border-color: var(--green); color: var(--green); }
.alert-error   { background: rgba(247,100,79,.1); border-color: var(--red);   color: var(--red); }
.alert-info    { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

/* ---- Line items editor ------------------------------------ */
.line-items { width: 100%; border-collapse: collapse; font-size: .875rem; }
.line-items th {
  text-align: left;
  padding: 8px 10px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.line-items td { padding: 6px 5px; border-bottom: 1px solid var(--border); vertical-align: top; }
.line-items td input, .line-items td textarea, .line-items td select {
  padding: 7px 9px;
  font-size: .85rem;
}
.line-items .col-sort    { width: 28px; }
.line-items .col-name    { min-width: 200px; }
.line-items .col-desc    { min-width: 160px; }
.line-items .col-qty     { width: 80px; }
.line-items .col-unit    { width: 70px; }
.line-items .col-price   { width: 110px; }
.line-items .col-taxable { width: 60px; text-align: center; }
.line-items .col-total   { width: 110px; text-align: right; font-family: var(--font-mono); }
.line-items .col-del     { width: 34px; }
.drag-handle { cursor: grab; color: var(--text-muted); font-size: 1.1rem; user-select: none; }

/* ---- Quote totals summary --------------------------------- */
.totals-panel {
  margin-top: 16px;
  margin-left: auto;
  width: 320px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: .875rem;
}
.totals-row.divider { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 12px; }
.totals-row.grand   { font-weight: 700; font-size: 1.05rem; color: var(--text-primary); }
.totals-label { color: var(--text-secondary); }
.totals-value { font-family: var(--font-mono); color: var(--text-primary); }

/* ---- Print view ------------------------------------------- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { margin-left: 0; }
  .page-body { padding: 0; }
  body { background: #fff; color: #000; }
  .card { border: none; padding: 0; }
}
.print-header { display: none; }
@media print { .print-header { display: block; margin-bottom: 24px; } }

/* ---- Toolbar row ------------------------------------------ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.toolbar-spacer { flex: 1; }

/* ---- Login page ------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}
.login-card p { color: var(--text-secondary); font-size: .875rem; margin-bottom: 28px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* ---- Responsive ------------------------------------------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .content { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .totals-panel { width: 100%; }
}

/* ---- Utilities -------------------------------------------- */
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0 !important; }
.mt-16 { margin-top: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; align-items: center; }
.hidden { display: none; }
