/* ============================================================
   SYNCORA — Main Stylesheet v1.0
   ============================================================ */

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

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:      #0f1e3d;
  --blue:      #2563eb;
  --blue-lt:   #eff6ff;
  --blue-mid:  #bfdbfe;
  --gray-50:   #f8fafc;
  --gray-100:  #f1f5f9;
  --gray-200:  #e2e8f0;
  --gray-400:  #94a3b8;
  --gray-500:  #64748b;
  --gray-700:  #334155;
  --gray-900:  #0f172a;
  --green:     #16a34a;
  --green-lt:  #dcfce7;
  --red:       #dc2626;
  --red-lt:    #fee2e2;
  --amber:     #d97706;
  --amber-lt:  #fef3c7;
  --white:     #ffffff;
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    10px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
}

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

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper  { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform .25s;
}

.sidebar-brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-icon { font-size: 24px; color: var(--blue); }
.sidebar-brand-name { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.sidebar-brand-sub  { font-size: 10px; color: var(--gray-400); letter-spacing: 1px; text-transform: uppercase; }

.sidebar-vendor {
  padding: 12px 20px;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 12px;
  color: var(--gray-400);
}
.sidebar-vendor strong { color: white; display: block; font-size: 13px; margin-bottom: 2px; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-label {
  padding: 16px 20px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,.3);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.65);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: white; text-decoration: none; }
.nav-item.active { background: rgba(37,99,235,.2); color: white; border-left-color: var(--blue); }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer a {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,.5); font-size: 12px; text-decoration: none;
}
.sidebar-footer a:hover { color: white; }

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

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 16px;
}
.topbar-title   { font-size: 18px; font-weight: 700; color: var(--navy); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--gray-500);
}
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}

/* Page content */
.page-content { padding: 24px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-title  { font-size: 15px; font-weight: 700; color: var(--navy); flex: 1; }
.card-body   { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); background: var(--gray-50); border-radius: 0 0 var(--radius) var(--radius); }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--blue-lt); }
.stat-icon.green  { background: var(--green-lt); }
.stat-icon.amber  { background: var(--amber-lt); }
.stat-icon.red    { background: var(--red-lt); }
.stat-icon.navy   { background: #e8edf7; }
.stat-label { font-size: 12px; color: var(--gray-400); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.stat-trend-up   { color: var(--green); font-size: 12px; font-weight: 600; }
.stat-trend-down { color: var(--red);   font-size: 12px; font-weight: 600; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
table.data-table thead tr { background: var(--navy); }
table.data-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
}
table.data-table tbody tr { border-bottom: 1px solid var(--gray-100); transition: background .1s; }
table.data-table tbody tr:hover { background: var(--gray-50); }
table.data-table tbody td { padding: 11px 14px; vertical-align: middle; }
table.data-table tbody tr:last-child { border-bottom: none; }
.td-mono { font-family: monospace; font-size: 12px; }
.td-muted { color: var(--gray-400); font-size: 12px; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--blue);  color: white; border-color: var(--blue); }
.btn-primary:hover   { background: #1d4ed8; border-color: #1d4ed8; }
.btn-secondary { background: white; color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-success   { background: var(--green); color: white; }
.btn-success:hover   { background: #15803d; }
.btn-danger    { background: var(--red);   color: white; }
.btn-danger:hover    { background: #b91c1c; }
.btn-warning   { background: var(--amber); color: white; }
.btn-navy      { background: var(--navy);  color: white; }
.btn-navy:hover      { background: #1a2e5a; }
.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-lg  { padding: 11px 24px; font-size: 15px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; font-size: 15px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group   { margin-bottom: 18px; }
.form-label   { display: block; font-size: 12px; font-weight: 600; color: var(--gray-500); margin-bottom: 6px; letter-spacing: .3px; }
.form-label .req { color: var(--red); }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: white;
  color: var(--gray-700);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-control:disabled { background: var(--gray-50); color: var(--gray-400); cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-text    { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.form-row     { display: grid; gap: 16px; }
.form-row-2   { grid-template-columns: 1fr 1fr; }
.form-row-3   { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4   { grid-template-columns: 1fr 1fr 1fr 1fr; }
.input-group  { display: flex; }
.input-addon  {
  padding: 9px 12px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  color: var(--gray-500);
  font-size: 13px;
  white-space: nowrap;
}
.input-addon:first-child { border-right: none; border-radius: 8px 0 0 8px; }
.input-addon:last-child  { border-left: none;  border-radius: 0 8px 8px 0; }
.input-group .form-control { border-radius: 0; }
.input-group .form-control:first-child { border-radius: 8px 0 0 8px; }
.input-group .form-control:last-child  { border-radius: 0 8px 8px 0; }

/* ── Search & Filter Bar ──────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 18px; flex-wrap: wrap;
}
.filter-bar .form-control { max-width: 260px; }
.search-wrap { position: relative; }
.search-wrap .form-control { padding-left: 34px; }
.search-wrap::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 14px; pointer-events: none; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-blue   { background: var(--blue-lt);  color: var(--blue); }
.badge-green  { background: var(--green-lt); color: var(--green); }
.badge-red    { background: var(--red-lt);   color: var(--red); }
.badge-amber  { background: var(--amber-lt); color: var(--amber); }
.badge-gray   { background: var(--gray-100); color: var(--gray-500); }
.badge-navy   { background: #e8edf7; color: var(--navy); }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.page-header-info { flex: 1; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--navy); }
.page-header p  { font-size: 13px; color: var(--gray-400); margin-top: 2px; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--gray-500); font-weight: 600; margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ── Alert / Info Boxes ───────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--green-lt); border-color: #4ade80; color: var(--green); }
.alert-danger  { background: var(--red-lt);   border-color: #f87171; color: var(--red); }
.alert-warning { background: var(--amber-lt); border-color: #fbbf24; color: var(--amber); }
.alert-info    { background: var(--blue-lt);  border-color: var(--blue-mid); color: var(--blue); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  padding: 20px; display: none;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 14px;
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-lg { max-width: 860px; }
.modal-header {
  padding: 18px 20px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 12px;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--navy); flex: 1; }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); display: flex; gap: 10px; justify-content: flex-end; }
.btn-close { background: var(--gray-100); border: none; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.btn-close:hover { background: var(--gray-200); }

/* ── Invoice/Quote Line Items ─────────────────────────────── */
.line-items-table { width: 100%; border-collapse: collapse; }
.line-items-table th { padding: 8px 10px; font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; border-bottom: 2px solid var(--gray-200); text-align: left; }
.line-items-table td { padding: 8px 10px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.line-items-table td input, .line-items-table td select { border: 1px solid var(--gray-200); border-radius: 6px; padding: 6px 8px; width: 100%; font-size: 13px; }
.line-items-table td input:focus, .line-items-table td select:focus { outline: none; border-color: var(--blue); }

/* ── Totals Block ─────────────────────────────────────────── */
.totals-block { max-width: 320px; margin-left: auto; margin-top: 12px; }
.totals-block table { width: 100%; }
.totals-block td { padding: 5px 0; font-size: 13px; }
.totals-block td:last-child { text-align: right; font-weight: 600; }
.totals-block .total-final td { font-size: 16px; font-weight: 700; color: var(--navy); border-top: 2px solid var(--gray-200); padding-top: 10px; }

/* ── Dashboard Charts ─────────────────────────────────────── */
.chart-container { position: relative; }

/* ── Low Stock Alert ──────────────────────────────────────── */
.low-stock-row { background: #fff9f0 !important; }
.low-stock-row td { color: var(--amber); }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 12px; border-radius: 6px; font-size: 13px;
  border: 1px solid var(--gray-200); color: var(--gray-700);
  text-decoration: none; font-weight: 500;
}
.pagination a:hover { background: var(--blue-lt); border-color: var(--blue); color: var(--blue); }
.pagination .current { background: var(--blue); color: white; border-color: var(--blue); }
.pagination .disabled { color: var(--gray-300); pointer-events: none; }

/* ── Utilities ────────────────────────────────────────────── */
.d-flex   { display: flex; }
.d-grid   { display: grid; }
.gap-8    { gap: 8px; }
.gap-12   { gap: 12px; }
.gap-16   { gap: 16px; }
.gap-24   { gap: 24px; }
.mb-8     { margin-bottom: 8px; }
.mb-16    { margin-bottom: 16px; }
.mb-24    { margin-bottom: 24px; }
.mt-8     { margin-top: 8px; }
.mt-16    { margin-top: 16px; }
.mt-24    { margin-top: 24px; }
.fw-600   { font-weight: 600; }
.fw-700   { font-weight: 700; }
.text-sm  { font-size: 12px; }
.text-muted { color: var(--gray-400); }
.text-navy  { color: var(--navy); }
.text-blue  { color: var(--blue); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-amber { color: var(--amber); }
.ms-auto  { margin-left: auto; }
.w-100    { width: 100%; }

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, #1e3a8a 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-box {
  background: white; border-radius: 16px;
  width: 100%; max-width: 400px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon { font-size: 40px; margin-bottom: 8px; }
.login-logo h1 { font-size: 28px; font-weight: 700; color: var(--navy); letter-spacing: 2px; }
.login-logo p  { font-size: 12px; color: var(--gray-400); letter-spacing: 1px; text-transform: uppercase; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-title { font-size: 15px; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { border: none; box-shadow: none; }
}
