* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Inter',sans-serif; transition: background-color 0.4s ease, color 0.4s ease; }
.font-inter { font-family:'Inter',sans-serif; }

:root {
  /* Default: Midnight Glow (Dark) */
  --bg-primary: #0b0e14;
  --bg-secondary: #0f1219;
  --bg-accent: rgba(255, 255, 255, 0.05);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --border-color: rgba(255, 255, 255, 0.1);
  --primary-color: #3b82f6;
  --glass-bg: rgba(11, 14, 20, 0.8);
}

.theme-forest {
  --bg-primary: #06110e;
  --bg-secondary: #0a1a16;
  --primary-color: #10b981;
  --bg-accent: rgba(16, 185, 129, 0.05);
}

.theme-sunset {
  --bg-primary: #120b0b;
  --bg-secondary: #1a0f0f;
  --primary-color: #f43f5e;
  --bg-accent: rgba(244, 63, 94, 0.05);
}

.theme-cyber {
  --bg-primary: #020617;
  --bg-secondary: #0f172a;
  --primary-color: #d946ef;
  --bg-accent: rgba(217, 70, 239, 0.05);
}

.theme-ocean {
  --bg-primary: #020c1b;
  --bg-secondary: #0a192f;
  --primary-color: #64ffda;
  --bg-accent: rgba(100, 255, 218, 0.05);
}

.theme-gold {
  --bg-primary: #0a0a05;
  --bg-secondary: #14140a;
  --primary-color: #fbbf24;
  --bg-accent: rgba(251, 191, 36, 0.05);
}

.theme-lavender {
  --bg-primary: #0d0a14;
  --bg-secondary: #140f1f;
  --primary-color: #a78bfa;
  --bg-accent: rgba(167, 139, 250, 0.05);
}

.theme-light {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-accent: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary-color: #2563eb;
  --glass-bg: rgba(255, 255, 255, 0.9);
}

body { background-color: var(--bg-primary) !important; color: var(--text-main) !important; }
#sidebar { background: var(--bg-secondary) !important; border-right: 1px solid var(--border-color) !important; }
header { background: var(--glass-bg) !important; backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-color) !important; }
#login-screen, #license-screen, #company-screen { background: var(--bg-primary) !important; }
#login-screen > div, #license-screen > div, #company-screen > div, .card, .stat-card, .modal-content { 
  background: var(--bg-secondary) !important; 
  border: 1px solid var(--border-color) !important; 
  color: var(--text-main) !important;
}

/* Fix text colors for light mode */
.theme-light h1, .theme-light h2, .theme-light h3, .theme-light p, .theme-light span, .theme-light div {
  color: var(--text-main);
}
.theme-light .text-gray-300, .theme-light .text-gray-400, .theme-light .text-gray-500, .theme-light .text-gray-600 {
  color: var(--text-muted) !important;
}
.theme-light .border-white\/10, .theme-light .border-white\/5 {
  border-color: var(--border-color) !important;
}
.theme-light .text-blue-400 {
  color: var(--primary-color) !important;
}
.theme-light .bg-gray-800, .theme-light .bg-gray-900, .theme-light .bg-white\/5 {
  background-color: var(--bg-accent) !important;
}
.theme-light input, .theme-light select, .theme-light textarea {
  background-color: var(--bg-secondary) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

.nav-btn { color: var(--text-muted); text-align:left; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; transition: all 0.2s ease; }
.nav-btn:hover { background: var(--bg-accent); color: var(--text-main); }
.nav-btn.active { background: color-mix(in srgb, var(--primary-color), transparent 90%); color: var(--primary-color); font-weight: bold; border-left: 0; }

/* Grouped Sidebar Styles */
.sidebar-group { margin-bottom: 4px; }
.group-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  border-radius: 12px;
}
.group-header:hover { background: var(--bg-accent); color: var(--text-main); }
.expanded .group-header { color: var(--primary-color); background: color-mix(in srgb, var(--primary-color), transparent 95%); }
.expanded .group-header i:first-child { color: var(--primary-color); }
.expanded .arrow { transform: rotate(180deg); color: var(--primary-color); }

.group-content { 
  display: none; 
  padding-left: 44px; 
  margin-top: 2px;
  border-left: 1px solid color-mix(in srgb, var(--primary-color), transparent 85%);
  margin-left: 26px;
}
.expanded .group-content { display: block; animation: slideDown 0.3s ease-out; }

.nav-sub-item {
  width: 100%;
  text-align: left;
  display: block;
  padding: 8px 12px;
  color: #9ca3af;
  font-size: 13px;
  transition: all 0.2s ease;
  border-radius: 8px;
  margin-bottom: 2px;
}
.nav-sub-item:hover { color: white; background: var(--bg-accent); }
.nav-sub-item.active { color: var(--primary-color); font-weight: bold; background: color-mix(in srgb, var(--primary-color), transparent 90%); }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Textures */
.texture-dots::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image: radial-gradient(var(--text-muted) 0.5px, transparent 0.5px);
  background-size: 24px 24px; opacity: 0.05;
}
.texture-grid::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image: linear-gradient(var(--border-color) 1px, transparent 1px), linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
  background-size: 40px 40px; opacity: 0.1;
}
.texture-waves::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(circle at 50% 50%, var(--bg-accent) 0%, transparent 70%);
  opacity: 0.5;
}
.texture-stripes::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image: repeating-linear-gradient(45deg, var(--bg-accent) 0, var(--bg-accent) 1px, transparent 0, transparent 50%);
  background-size: 10px 10px; opacity: 0.2;
}
.texture-noise::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.05"/></svg>');
  opacity: 0.3;
}

.page-content { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

::-webkit-scrollbar { width:5px; height:5px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius:3px; }

.stat-card { background: var(--bg-secondary); border: 1px solid var(--border-color); transition:all 0.2s ease; }
.stat-card:hover { border-color: var(--primary-color); transform:translateY(-2px); }

#sidebar { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); width: 16rem; overflow: hidden; }
.sidebar-collapsed #sidebar { width: 80px; }
.sidebar-collapsed #sidebar p, 
.sidebar-collapsed #sidebar span, 
.sidebar-collapsed #sidebar .nav-btn span,
.sidebar-collapsed #sidebar .group-header span,
.sidebar-collapsed #sidebar .group-header i:last-child,
.sidebar-collapsed #sidebar .nav-sub-item,
.sidebar-collapsed #sidebar .px-4.pt-3.pb-1, /* Hide user badge container */
.sidebar-collapsed #sidebar .text-xs.text-gray-400 { display: none !important; }

.sidebar-collapsed #sidebar .flex.items-center.gap-3.mb-3 { justify-content: center; margin-bottom: 0; }
.sidebar-collapsed #sidebar-icon { margin-right: 0; }
.sidebar-collapsed #btn-switch-company { justify-content: center; padding: 0.75rem; width: 40px; margin: 0 auto; }
.sidebar-collapsed #btn-switch-company i { margin-right: 0; }

.sidebar-collapsed .group-header { justify-content: center; padding: 12px 0; }
.sidebar-collapsed .group-header i:first-child { margin-right: 0; font-size: 1.2rem; }
.sidebar-collapsed .group-content { display: none !important; } /* Close all groups when collapsed */

/* Quick Access Toolbar */
.quick-access-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE/Edge */
}
.quick-access-wrap::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.qa-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-accent);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.qa-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Reports Dropdown */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  min-width: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  z-index: 100;
  padding: 8px;
  display: none;
  animation: slideDown 0.2s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 12px;
  transition: all 0.2s ease;
}
.dropdown-item:hover {
  background: var(--bg-accent);
  color: white;
}

.glass {
  background: var(--bg-accent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
}

@media print {
  body { background: white !important; color: black !important; }
  #app, #modal-overlay, #toast, .nav-btn, .sidebar, .top-header, .page-header, #modal-body { display: none !important; }
  #invoice-print, #generic-print { display: block !important; position: absolute; top: 0; left: 0; width: 100%; z-index: 10000; }
  .no-print { display: none !important; }
}

#invoice-print, #generic-print { display: none; }

/* Texture Overrides */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.015;
}
