/* ============================================================
   SARNATH ERP — Stylesheet
   Brand: Deep navy base, saffron accent, clean data-first
   ============================================================ */

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

:root {
  --navy:       #1a2744;
  --navy-mid:   #243460;
  --navy-light: #2e4080;
  --saffron:    #e8841a;
  --saffron-lt: #f5a64a;
  --red:        #c0392b;
  --green:      #1e8449;
  --green-lt:   #27ae60;
  --amber:      #d4ac0d;
  --white:      #ffffff;
  --bg:         #f4f6fb;
  --surface:    #ffffff;
  --border:     #dde3f0;
  --text-main:  #1a2744;
  --text-muted: #6b7a9a;
  --text-light: #a0aec0;
  --shadow-sm:  0 1px 4px rgba(26,39,68,0.08);
  --shadow-md:  0 4px 16px rgba(26,39,68,0.12);
  --radius:     8px;
  --radius-lg:  12px;
  --sidebar-w:  240px;
  --font:       'Inter', system-ui, sans-serif;
  --mono:       'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--saffron); text-decoration: none; }
a:hover { color: var(--saffron-lt); }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--navy);
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .brand {
  font-size: 16px; font-weight: 700; color: var(--white);
  letter-spacing: 0.3px;
}

.sidebar-logo .sub {
  font-size: 10px; color: var(--saffron);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-top: 2px;
}

.sidebar-logo .gstin {
  font-size: 9px; color: rgba(255,255,255,0.35);
  font-family: var(--mono); margin-top: 4px;
}

.nav-section {
  padding: 16px 0 8px;
}

.nav-label {
  font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: rgba(255,255,255,0.3);
  padding: 0 20px 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 13px; font-weight: 500;
  transition: all 0.15s; cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}

.nav-item.active {
  color: var(--white);
  background: rgba(232,132,26,0.15);
  border-left-color: var(--saffron);
}

.nav-item .icon { font-size: 16px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; color: rgba(255,255,255,0.4);
}

.sidebar-footer .user-name {
  font-weight: 600; color: rgba(255,255,255,0.7);
  font-size: 13px;
}

.sidebar-footer .logout-btn {
  display: inline-block; margin-top: 8px;
  font-size: 11px; color: var(--saffron);
  cursor: pointer;
}

/* ── Main Layout ─────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 17px; font-weight: 700; color: var(--navy);
}

.topbar-meta {
  font-size: 12px; color: var(--text-muted);
}

.topbar-right {
  display: flex; align-items: center; gap: 12px;
}

.page-body {
  padding: 24px 28px;
  max-width: 1400px;
}

/* ── Cards & Stats ───────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
}

.stat-card.orange::before { background: var(--saffron); }
.stat-card.red::before    { background: var(--red); }
.stat-card.green::before  { background: var(--green-lt); }
.stat-card.blue::before   { background: var(--navy-light); }
.stat-card.amber::before  { background: var(--amber); }

.stat-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted); margin-bottom: 8px;
}

.stat-value {
  font-size: 24px; font-weight: 700;
  color: var(--navy); font-family: var(--mono);
}

.stat-sub {
  font-size: 11px; color: var(--text-light);
  margin-top: 4px;
}

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title {
  font-size: 14px; font-weight: 700;
  color: var(--navy);
}

.card-body { padding: 20px; }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 10px 14px; text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: none; }

.mono { font-family: var(--mono); font-size: 12px; }
.amount { font-family: var(--mono); font-weight: 600; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-pending   { background: #fef9e7; color: #9a7d0a; }
.badge-paid      { background: #eafaf1; color: #1e8449; }
.badge-partial   { background: #eaf4fb; color: #1a5276; }
.badge-returned  { background: #fdf2f8; color: #7d3c98; }
.badge-cancelled { background: #f2f3f4; color: #626567; }
.badge-critical  { background: #fdedec; color: #922b21; }
.badge-warning   { background: #fef9e7; color: #9a7d0a; }
.badge-info      { background: #eaf4fb; color: #1a5276; }
.badge-gpay      { background: #e8f5e9; color: #2e7d32; }
.badge-cash      { background: #e3f2fd; color: #1565c0; }
.badge-cheque    { background: #fff3e0; color: #e65100; }
.badge-neft      { background: #f3e5f5; color: #6a1b9a; }
.badge-non-delivery { background: #fce4ec; color: #880e4f; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.15s;
  font-family: var(--font);
}

.btn-primary {
  background: var(--saffron); color: var(--white);
}
.btn-primary:hover { background: var(--saffron-lt); color: var(--white); }

.btn-navy {
  background: var(--navy); color: var(--white);
}
.btn-navy:hover { background: var(--navy-mid); color: var(--white); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-main);
}
.btn-outline:hover { border-color: var(--saffron); color: var(--saffron); }

.btn-danger {
  background: var(--red); color: var(--white);
}
.btn-danger:hover { background: #a93226; color: var(--white); }

.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-xs { padding: 3px 8px; font-size: 10px; }

/* ── Forms ───────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px; font-family: var(--font);
  color: var(--text-main);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--saffron);
  box-shadow: 0 0 0 3px rgba(232,132,26,0.1);
}

textarea { resize: vertical; min-height: 80px; }

.form-actions {
  display: flex; gap: 10px; align-items: center;
  padding-top: 8px; flex-wrap: wrap;
}

/* ── Alerts ──────────────────────────────────────────── */
.alert-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  border: 1px solid;
}

.alert-item.critical {
  background: #fdedec; border-color: #f1948a;
}
.alert-item.warning {
  background: #fef9e7; border-color: #f7dc6f;
}
.alert-item.info {
  background: #eaf4fb; border-color: #85c1e9;
}

.alert-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-msg { font-size: 13px; font-weight: 500; color: var(--text-main); }
.alert-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── Flash messages ──────────────────────────────────── */
.flash {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 13px; font-weight: 500;
}
.flash-success { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }
.flash-error   { background: #fdedec; color: #922b21; border: 1px solid #f1948a; }

/* ── Search / Filter bar ─────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: flex-end; margin-bottom: 16px;
}

.filter-bar input, .filter-bar select {
  width: auto; min-width: 160px;
}

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Login ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; background: var(--navy);
  display: flex; align-items: center; justify-content: center;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px; width: 380px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  text-align: center; margin-bottom: 28px;
}

.login-logo .brand {
  font-size: 22px; font-weight: 800;
  color: var(--navy); letter-spacing: 0.5px;
}

.login-logo .sub {
  font-size: 11px; color: var(--saffron);
  text-transform: uppercase; letter-spacing: 2px;
  margin-top: 4px;
}

/* ── Misc ────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); font-weight: 600; }
.text-red   { color: var(--red);   font-weight: 600; }
.text-amber { color: var(--amber); font-weight: 600; }
.fw-600 { font-weight: 600; }

.gap-flag {
  font-size: 10px; padding: 2px 6px;
  background: #fef9e7; color: #9a7d0a;
  border-radius: 4px; font-weight: 600;
}

.pagination {
  display: flex; gap: 4px; align-items: center;
  justify-content: flex-end; padding-top: 12px;
}
.page-btn {
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; font-size: 12px;
  background: var(--white); color: var(--text-main);
}
.page-btn.active { background: var(--navy); color: var(--white); border-color: var(--navy); }
.page-btn:hover:not(.active) { border-color: var(--saffron); color: var(--saffron); }

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px; width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--navy); }
.modal-close {
  cursor: pointer; font-size: 20px; color: var(--text-muted);
  background: none; border: none;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .page-body { padding: 16px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}
