/* ============================================================
   BizBill Pro — app.css
   Aesthetic: Industrial Ledger — slate sidebar, amber accents,
   monospace financials, crisp white content zones.
   ============================================================ */

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

/* ── Variables ──────────────────────────────────────────── */
:root {
  --sidebar-w:       260px;
  --topbar-h:        60px;

  --navy:            #0f172a;
  --navy-light:      #1e293b;
  --navy-muted:      #334155;
  --amber:           #f59e0b;
  --amber-light:     #fef3c7;
  --amber-dark:      #b45309;
  --emerald:         #10b981;
  --rose:            #f43f5e;
  --sky:             #0ea5e9;
  --slate-50:        #f8fafc;
  --slate-100:       #f1f5f9;
  --slate-200:       #e2e8f0;
  --slate-400:       #94a3b8;
  --slate-500:       #64748b;
  --slate-700:       #334155;
  --white:           #ffffff;

  --font-body:       'DM Sans', sans-serif;
  --font-mono:       'DM Mono', monospace;
  --font-display:    'Playfair Display', serif;

  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       16px;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:       0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:       0 10px 40px rgba(0,0,0,.14);

  --transition:      all .18s cubic-bezier(.4,0,.2,1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--navy);
  background: var(--slate-100);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

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

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  transition: transform .25s ease;
  overflow: hidden;
}

.sidebar::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(245,158,11,.15) 0%, transparent 70%);
  pointer-events: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}

.sidebar-brand-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--amber);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--navy); font-weight: 700;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .01em;
  line-height: 1.2;
}

.sidebar-brand-name span {
  display: block;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 400;
  color: var(--slate-400);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--slate-500);
  padding: 12px 20px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: var(--transition);
  font-weight: 500;
  font-size: 13.5px;
  position: relative;
}

.sidebar-link i {
  font-size: 17px;
  width: 20px;
  flex-shrink: 0;
  opacity: .75;
  transition: var(--transition);
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255,255,255,.05);
  border-left-color: rgba(245,158,11,.4);
}

.sidebar-link:hover i { opacity: 1; }

.sidebar-link.active {
  color: var(--amber);
  background: rgba(245,158,11,.10);
  border-left-color: var(--amber);
}

.sidebar-link.active i { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-footer-user {
  font-size: 12px;
  color: var(--slate-400);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-footer-user .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--amber);
  color: var(--navy);
  font-weight: 700;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1039;
  box-shadow: var(--shadow-sm);
}

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

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

.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: 30px;
  padding: 5px 12px 5px 6px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.topbar-user-btn:hover {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.topbar-user-btn .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--amber);
  color: var(--navy);
  font-weight: 700;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}

.topbar-user-btn .uname {
  font-size: 13px;
  font-weight: 600;
  color: inherit;
}

/* ── MAIN CONTENT ───────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
}

.page-body {
  flex: 1;
  padding: 28px 32px;
}

/* ── PAGE HEADER ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 12px;
}

.page-header-left h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}

.page-header-left p {
  font-size: 13px;
  color: var(--slate-500);
  margin: 4px 0 0;
}

.breadcrumb-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--slate-400);
  margin-bottom: 4px;
}

.breadcrumb-dot span { color: var(--slate-500); }

/* ── CARDS ──────────────────────────────────────────────── */
.biz-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
}

.biz-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.biz-card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
}

.biz-card-body {
  padding: 24px;
}

/* ── STAT CARDS ─────────────────────────────────────────── */
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 0 var(--radius-lg) 0 80px;
  opacity: .08;
}

.stat-card.amber::after  { background: var(--amber); }
.stat-card.emerald::after{ background: var(--emerald); }
.stat-card.rose::after   { background: var(--rose); }
.stat-card.sky::after    { background: var(--sky); }

.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.stat-card.amber  .stat-icon { background: var(--amber-light);  color: var(--amber-dark); }
.stat-card.emerald .stat-icon{ background: #d1fae5;  color: #065f46; }
.stat-card.rose   .stat-icon { background: #ffe4e6;  color: #9f1239; }
.stat-card.sky    .stat-icon { background: #e0f2fe;  color: #075985; }

.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--navy);
  letter-spacing: -.02em;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--slate-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── TABLES ─────────────────────────────────────────────── */
.biz-table {
  width: 100%;
  border-collapse: collapse;
}

.biz-table thead th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--slate-500);
  background: var(--slate-50);
  padding: 12px 16px;
  border-bottom: 2px solid var(--slate-200);
  white-space: nowrap;
}

.biz-table tbody tr {
  border-bottom: 1px solid var(--slate-100);
  transition: background .12s;
}

.biz-table tbody tr:hover { background: #fafbfc; }

.biz-table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  color: var(--navy-muted);
  font-size: 13.5px;
}

.biz-table .mono {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}

.biz-table .text-right { text-align: right; }

/* Invoice number badge */
.inv-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--slate-100);
  color: var(--slate-700);
  border-radius: 4px;
  padding: 2px 7px;
  border: 1px solid var(--slate-200);
  font-weight: 500;
}

/* ── FORMS ──────────────────────────────────────────────── */
.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate-700);
  letter-spacing: .02em;
  margin-bottom: 5px;
}

.form-control, .form-select {
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--navy);
  padding: 8px 12px;
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245,158,11,.15);
  outline: none;
}

.form-control.mono, .mono-input {
  font-family: var(--font-mono);
  letter-spacing: .01em;
}

/* ── INVOICE FORM TABLE ─────────────────────────────────── */
#items-table {
  font-size: 13px;
}

#items-table thead th {
  font-size: 10.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--slate-500);
  font-weight: 600;
  background: var(--slate-50);
  padding: 10px 10px;
  white-space: nowrap;
}

#items-table tbody td {
  padding: 7px 8px;
  vertical-align: middle;
}

#items-table .form-control-sm {
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 5px;
}

.items-total-row td {
  background: var(--slate-50);
  font-weight: 600;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.grand-total-row td {
  background: var(--navy);
  color: var(--amber);
  font-weight: 700;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 15px;
}

/* ── BUTTONS ────────────────────────────────────────────── */
.btn-biz-primary {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}

.btn-biz-primary:hover {
  background: var(--navy-light);
  color: var(--amber);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-biz-amber {
  background: var(--amber);
  color: var(--navy);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}

.btn-biz-amber:hover {
  background: #fbbf24;
  color: var(--navy);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(245,158,11,.35);
}

.btn-biz-ghost {
  background: transparent;
  color: var(--slate-500);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn-biz-ghost:hover {
  border-color: var(--navy);
  color: var(--navy);
}

/* ── BADGES ─────────────────────────────────────────────── */
.badge-paid {
  background: #d1fae5; color: #065f46;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
}

.badge-partial {
  background: var(--amber-light); color: var(--amber-dark);
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
}

.badge-due {
  background: #ffe4e6; color: #9f1239;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
}

.badge-admin {
  background: var(--navy); color: var(--amber);
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
  letter-spacing: .06em; text-transform: uppercase;
}

.badge-user {
  background: var(--slate-100); color: var(--slate-700);
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
  letter-spacing: .06em; text-transform: uppercase;
}

/* ── FOOTER ─────────────────────────────────────────────── */
.app-footer {
  background: var(--white);
  border-top: 1px solid var(--slate-200);
  padding: 14px 32px;
  font-size: 12px;
  color: var(--slate-400);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── MODALS ─────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: none;
  padding: 18px 24px;
}

.modal-header .btn-close {
  filter: invert(1) opacity(.7);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

/* ── CHART CONTAINER ────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 320px;
}

/* ── ALERTS / TOASTS ────────────────────────────────────── */
#toast-container { z-index: 9999; }

.flash-success {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 13.5px;
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}

/* ── LOGIN PAGE ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,158,11,.12) 0%, transparent 70%);
  top: -200px; left: -200px;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16,185,129,.08) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  pointer-events: none;
}

.login-card {
  background: rgba(255,255,255,.04);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  padding: 44px 48px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: loginFadeIn .45s ease both;
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-card .brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-card .brand-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.login-card .brand-sub {
  font-size: 12px;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-top: 6px;
}

.login-card .form-label {
  color: rgba(255,255,255,.55);
}

.login-card .form-control {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.12);
  color: #fff;
}

.login-card .form-control:focus {
  background: rgba(255,255,255,.09);
  border-color: var(--amber);
  color: #fff;
}

.login-card .form-control::placeholder { color: rgba(255,255,255,.25); }

/* ── AUTOCOMPLETE ───────────────────────────────────────── */
.ui-autocomplete {
  border: 1.5px solid var(--slate-200) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-md) !important;
  font-family: var(--font-body) !important;
  font-size: 13px !important;
  max-height: 240px;
  overflow-y: auto;
  z-index: 9999 !important;
}

.ui-menu-item-wrapper {
  padding: 9px 14px !important;
  color: var(--navy) !important;
}

.ui-menu-item-wrapper.ui-state-active {
  background: var(--amber-light) !important;
  color: var(--amber-dark) !important;
  border: none !important;
}

/* ── STOCK BADGE ────────────────────────────────────────── */
.stock-low  { color: var(--rose);    font-weight: 600; }
.stock-ok   { color: var(--emerald); font-weight: 600; }
.stock-zero { color: var(--slate-400); }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 992px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
  .page-body { padding: 18px; }
}

/* ── PRINT HIDE ─────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .app-footer, .btn, .no-print { display: none !important; }
  .main-content { margin: 0; }
}
