/* ============================================================
   VIPER IMAGINATION GST BILLING SYSTEM — MASTER STYLESHEET
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Poppins:wght@400;600;700&display=swap');

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
  --topbar-height: 60px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active: linear-gradient(90deg, #667eea, #764ba2);
  --primary: #667eea;
  --primary-dark: #5a67d8;
  --success: #48bb78;
  --danger: #fc8181;
  --warning: #f6ad55;
  --info: #63b3ed;
  --body-bg: #f0f4f8;
  --card-bg: #fff;
  --text-main: #1a202c;
  --text-muted: #718096;
  --border-color: #e2e8f0;
  --topbar-bg: #fff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

/* Dark Mode */
.dark-mode {
  --body-bg: #0d1117;
  --card-bg: #161b22;
  --text-main: #e6edf3;
  --text-muted: #8b949e;
  --border-color: #30363d;
  --topbar-bg: #161b22;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--body-bg);
  color: var(--text-main);
  font-size: 0.9rem;
  transition: background-color 0.3s, color 0.3s;
  margin: 0;
  padding: 0;
}

/* ── Wrapper ── */
.wrapper { min-height: 100vh; }

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

/* Header */
.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
}
.brand-logo { display: flex; align-items: center; gap: 0.75rem; overflow: hidden; }
.brand-icon {
  width: 38px; height: 38px; flex-shrink: 0;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { color: #fff; font-weight: 700; font-size: 0.95rem; white-space: nowrap; font-family: 'Poppins', sans-serif; }
.brand-sub { color: rgba(255,255,255,0.4); font-size: 0.7rem; white-space: nowrap; }
.sidebar.collapsed .brand-text, .sidebar.collapsed .brand-sub { display: none; }
.sidebar-toggle-btn { color: rgba(255,255,255,0.5); background: transparent; border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; padding: 2px 6px; transition: all 0.2s; }
.sidebar-toggle-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* User */
.sidebar-user {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  overflow: hidden;
}
.user-avatar { color: rgba(255,255,255,0.6); font-size: 1.8rem; flex-shrink: 0; }
.user-info { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.user-name { color: #fff; font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,0.4); font-size: 0.7rem; }
.sidebar.collapsed .user-info { display: none; }

/* Menu */
.sidebar-menu { padding: 0.75rem 0; margin: 0; flex: 1; }
.menu-label {
  color: rgba(255,255,255,0.25);
  font-size: 0.65rem; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  padding: 0.8rem 1.25rem 0.3rem;
  transition: opacity 0.2s;
}
.sidebar.collapsed .menu-label { opacity: 0; height: 0; padding: 0; overflow: hidden; }
.sidebar-menu li a {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.65rem 1.25rem;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  border-radius: 0;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}
.sidebar-menu li a i { font-size: 1.05rem; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-menu li a:hover { color: #fff; background: var(--sidebar-hover); }
.sidebar-menu li.active a {
  color: #fff;
  background: linear-gradient(90deg, rgba(102,126,234,0.25), rgba(102,126,234,0.05));
  border-left: 3px solid #667eea;
}
.sidebar.collapsed .sidebar-menu li a { justify-content: center; padding: 0.75rem; }
.sidebar.collapsed .sidebar-menu li a span { display: none; }
.sidebar.collapsed .sidebar-menu li.active a { border-left: none; background: rgba(102,126,234,0.3); border-radius: 10px; margin: 0 8px; }

/* ══════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.main-content.expanded { margin-left: var(--sidebar-collapsed-width); }

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-btn { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); border-radius: 8px; }
.topbar-btn:hover { background: var(--body-bg); color: var(--text-main); }

/* Page content */
.page-content { flex: 1; }

/* Footer */
.app-footer { border-top: 1px solid var(--border-color); background: var(--card-bg); }

/* ══════════════════════════════════════
   CARDS & STATS
══════════════════════════════════════ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  padding: 0.9rem 1.25rem;
}
.card-body { padding: 1.25rem; }

/* Stat Cards */
.stat-card {
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  position: relative;
  overflow: hidden;
  border: none;
  box-shadow: var(--shadow-md);
  transition: transform 0.25s, box-shadow 0.25s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
  position: absolute; right: 1rem; top: 50%;
  transform: translateY(-50%);
  font-size: 3.5rem;
  opacity: 0.15;
}
.stat-card .stat-label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; opacity: 0.85; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; margin: 0.3rem 0 0.2rem; }
.stat-card .stat-sub { font-size: 0.75rem; opacity: 0.75; }

.stat-blue   { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.stat-green  { background: linear-gradient(135deg, #48bb78, #38a169); color: #fff; }
.stat-orange { background: linear-gradient(135deg, #f6ad55, #ed8936); color: #fff; }
.stat-red    { background: linear-gradient(135deg, #fc8181, #e53e3e); color: #fff; }
.stat-teal   { background: linear-gradient(135deg, #4fd1c7, #38b2ac); color: #fff; }
.stat-indigo { background: linear-gradient(135deg, #76e4f7, #3182ce); color: #fff; }
.stat-pink   { background: linear-gradient(135deg, #f687b3, #d53f8c); color: #fff; }
.stat-cyan   { background: linear-gradient(135deg, #63b3ed, #2b6cb0); color: #fff; }

/* ══════════════════════════════════════
   TABLES
══════════════════════════════════════ */
.table { color: var(--text-main); }
.table-hover tbody tr:hover { background: rgba(102,126,234,0.05); }
.table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; border-bottom: 2px solid var(--border-color); }
.dark-mode .table { --bs-table-bg: transparent; color: var(--text-main); }
.dark-mode .table-bordered { border-color: var(--border-color); }
.dark-mode .table td, .dark-mode .table th { border-color: var(--border-color); }
.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--text-main) !important; }
.dark-mode .dataTables_filter input, .dark-mode .dataTables_length select { background: var(--card-bg); color: var(--text-main); border-color: var(--border-color); }

/* ══════════════════════════════════════
   FORMS
══════════════════════════════════════ */
.form-control, .form-select {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
  background: var(--card-bg);
  color: var(--text-main);
}
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.35rem; }
.input-group-text { background: var(--body-bg); border-color: var(--border-color); color: var(--text-muted); }

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.btn { border-radius: var(--radius-sm); font-weight: 500; font-size: 0.85rem; transition: all 0.2s; }
.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); border: none; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102,126,234,0.4); }
.btn-success { background: linear-gradient(135deg, #48bb78, #38a169); border: none; }
.btn-success:hover { opacity: 0.9; transform: translateY(-1px); }

/* Badges */
.badge { font-size: 0.72rem; font-weight: 600; border-radius: 20px; padding: 0.3em 0.75em; }

/* Status badges */
.status-active { background: rgba(72,187,120,0.15); color: #2f855a; border: 1px solid rgba(72,187,120,0.3); }
.status-cancelled { background: rgba(252,129,129,0.15); color: #c53030; border: 1px solid rgba(252,129,129,0.3); }
.status-draft { background: rgba(246,173,85,0.15); color: #c05621; border: 1px solid rgba(246,173,85,0.3); }
.dark-mode .status-active { color: #68d391; }
.dark-mode .status-cancelled { color: #fc8181; }
.dark-mode .status-draft { color: #f6ad55; }

/* ══════════════════════════════════════
   PAGE HEADER
══════════════════════════════════════ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-header .breadcrumb { margin: 0; font-size: 0.8rem; }

/* ══════════════════════════════════════
   INVOICE FORM ROWS
══════════════════════════════════════ */
.invoice-item-row { background: var(--card-bg); border-radius: var(--radius-sm); border: 1px solid var(--border-color); padding: 0.75rem; margin-bottom: 0.5rem; transition: border-color 0.2s; }
.invoice-item-row:hover { border-color: var(--primary); }
.remove-row-btn { color: var(--danger); background: transparent; border: none; padding: 0; font-size: 1.1rem; }
.remove-row-btn:hover { color: #c53030; }

/* Totals box */
.totals-box {
  background: linear-gradient(135deg, rgba(102,126,234,0.08), rgba(118,75,162,0.08));
  border: 1px solid rgba(102,126,234,0.2);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.totals-box .total-row { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0; border-bottom: 1px dashed var(--border-color); }
.totals-box .total-row:last-child { border-bottom: none; padding-top: 0.75rem; }
.totals-box .total-label { font-weight: 500; color: var(--text-muted); }
.totals-box .total-value { font-weight: 700; font-size: 1rem; }
.totals-box .grand-total { font-size: 1.4rem; color: var(--primary); }

/* ══════════════════════════════════════
   MOBILE RESPONSIVE
══════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1039;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), width 0.3s; width: var(--sidebar-width); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
}

/* ══════════════════════════════════════
   DARK MODE OVERRIDES
══════════════════════════════════════ */
.dark-mode .card, .dark-mode .modal-content { background: var(--card-bg); border-color: var(--border-color); }
.dark-mode .form-control, .dark-mode .form-select { background: #0d1117; border-color: var(--border-color); color: var(--text-main); }
.dark-mode .input-group-text { background: #161b22; border-color: var(--border-color); color: var(--text-muted); }
.dark-mode .topbar { background: var(--topbar-bg); border-color: var(--border-color); }
.dark-mode .topbar-btn { border-color: var(--border-color); color: var(--text-muted); }
.dark-mode .app-footer { background: var(--card-bg); border-color: var(--border-color); }
.dark-mode .dropdown-menu { background: #1c2333; border-color: var(--border-color); }
.dark-mode .dropdown-item { color: var(--text-main); }
.dark-mode .dropdown-item:hover { background: rgba(255,255,255,0.08); }

/* ══════════════════════════════════════
   PRINT STYLES
══════════════════════════════════════ */
@media print {
  body { background: #fff !important; font-size: 12pt; }
  .sidebar, .topbar, .app-footer, .no-print, .btn, .page-header,
  .breadcrumb, #sidebarOverlay { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { border: none !important; box-shadow: none !important; }
  .invoice-print { display: block !important; }
}

/* ══════════════════════════════════════
   INVOICE PRINT TEMPLATE
══════════════════════════════════════ */
.invoice-print-wrapper {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  color: #000;
  font-size: 13px;
  font-family: 'Inter', Arial, sans-serif;
}
.invoice-header-bar {
  background: linear-gradient(135deg, #1a237e, #283593);
  color: #fff;
  padding: 1.5rem 2rem;
  position: relative;
}
.invoice-header-bar .company-name { font-size: 1.5rem; font-weight: 800; font-family: 'Poppins', sans-serif; }
.invoice-header-bar .company-details { font-size: 0.78rem; opacity: 0.85; line-height: 1.7; }
.invoice-title-badge {
  background: #fff;
  color: #1a237e;
  display: inline-block;
  padding: 0.3rem 1.2rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.invoice-watermark {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 5rem;
  font-weight: 900;
  color: rgba(255,255,255,0.04);
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 8px;
  text-transform: uppercase;
}
.invoice-body { padding: 1.5rem 2rem; }
.invoice-info-box {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: #f8fafc;
}
.invoice-info-box .label { font-size: 0.7rem; color: #718096; font-weight: 600; text-transform: uppercase; }
.invoice-info-box .value { font-weight: 700; color: #1a202c; font-size: 0.9rem; }
.invoice-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.invoice-table th { background: #1a237e; color: #fff; padding: 0.6rem 0.75rem; font-size: 0.78rem; text-align: left; }
.invoice-table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid #e2e8f0; font-size: 0.85rem; vertical-align: middle; }
.invoice-table tbody tr:nth-child(even) { background: #f8fafc; }
.invoice-table tfoot td { font-weight: 700; background: #f0f4f8; border-top: 2px solid #1a237e; }
.invoice-grand-total { background: linear-gradient(135deg, #1a237e, #283593); color: #fff; border-radius: 8px; padding: 0.75rem 1rem; }
.invoice-grand-total .gt-label { font-size: 0.85rem; opacity: 0.85; }
.invoice-grand-total .gt-value { font-size: 1.5rem; font-weight: 800; }
.bank-details-box { border: 1px dashed #b0bec5; border-radius: 8px; padding: 0.75rem 1rem; background: #fafafa; font-size: 0.8rem; }
.signature-box { border-top: 2px solid #1a237e; margin-top: 1rem; padding-top: 0.5rem; text-align: center; font-size: 0.78rem; color: #718096; }
.gst-summary-row { background: #fff3e0; border: 1px solid #ffe0b2; border-radius: 6px; padding: 0.5rem 0.75rem; font-size: 0.82rem; }

/* Toast */
.toast-container { z-index: 9999; }

/* GSTIN Highlight */
.gst-highlight {
  border: 2px solid #667eea !important;
  background: rgba(102,126,234,0.05) !important;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1) !important;
  font-weight: 600 !important;
}
.gst-highlight:focus {
  border-color: #5a67d8 !important;
  box-shadow: 0 0 0 4px rgba(102,126,234,0.2) !important;
}
.dark-mode .gst-highlight {
  background: rgba(102,126,234,0.1) !important;
  border-color: #667eea !important;
}

/* Invoice GSTIN Display Highlight */
.invoice-gstin-highlight {
  background: linear-gradient(135deg, rgba(102,126,234,0.1), rgba(118,75,162,0.1));
  border: 1px solid #667eea;
  border-left: 3px solid #667eea;
  border-radius: 6px;
  padding: 4px 10px;
  font-weight: 700;
  color: #667eea;
  display: inline-block;
  margin-top: 4px;
}
