/* CSS variables for consistent premium design system */
:root {
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #020617 100%);
  --panel-bg: rgba(30, 41, 59, 0.45);
  --panel-border: rgba(255, 255, 255, 0.06);
  --panel-glow: rgba(99, 102, 241, 0.05);
  
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-primary-glow: rgba(99, 102, 241, 0.25);
  
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.1);
  --color-success-border: rgba(16, 185, 129, 0.2);
  
  --color-danger: #f43f5e;
  --color-danger-bg: rgba(244, 63, 94, 0.1);
  --color-danger-border: rgba(244, 63, 94, 0.2);
  
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.1);
  
  --color-info: #0ea5e9;
  --color-info-bg: rgba(14, 165, 233, 0.1);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-light: rgba(255, 255, 255, 0.08);
  
  --font-family-title: 'Outfit', 'Inter', sans-serif;
  --font-family-body: 'Inter', system-ui, sans-serif;
  
  --sidebar-width: 280px;
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

html {
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-family-body);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Scrollbar styles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Layout shell */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
  position: relative;
}

/* Sidebar styling */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(15, 23, 42, 0.8);
  border-right: 1px solid var(--border-light);
  backdrop-filter: blur(20px);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: var(--transition-smooth);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
}

.brand-icon {
  background: linear-gradient(135deg, var(--color-primary) 0%, #a855f7 100%);
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--color-primary-glow);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.brand-name {
  font-family: var(--font-family-title);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
}

.nav-item {
  width: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--border-radius-md);
  transition: var(--transition-smooth);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  transition: var(--transition-smooth);
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.nav-item.active .nav-link {
  color: #ffffff;
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: inset 0 0 12px rgba(99, 102, 241, 0.1);
}

.nav-item.active .nav-link svg {
  color: var(--color-primary);
  transform: scale(1.1);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border-light);
  padding-top: 1.5rem;
}

/* Main Content Area */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2.5rem 3rem;
  min-width: 0; /* Prevents flex items from breaking layout on smaller viewports */
}

/* Header section styling */
.content-header {
  margin-bottom: 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title h1 {
  font-family: var(--font-family-title);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.header-title p {
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-size: 1rem;
}

.header-actions {
  display: flex;
  gap: 1rem;
}

/* Section Switching styling */
.content-section {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.content-section.active {
  display: block;
}

/* Keyframe animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Glassmorphic Cards */
.glass-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 1.75rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3), 
              inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  margin-bottom: 1.75rem;
  position: relative;
  overflow: hidden;
}

.card-kpi-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

.glass-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: radial-gradient(circle at top right, var(--panel-glow), transparent 60%);
  pointer-events: none;
}

.card-title {
  font-family: var(--font-family-title);
  font-size: 1.25rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Grid Layouts */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 1.75rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 1024px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

/* Metric Card specific styling */
.metric-card {
  display: flex;
  flex-direction: column;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.metric-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-value {
  font-family: var(--font-family-title);
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
  margin: 0.25rem 0;
  letter-spacing: -0.5px;
}

.metric-change {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.metric-change.positive {
  color: var(--color-success);
}

.metric-change.negative {
  color: var(--color-danger);
}

.metric-change.neutral {
  color: var(--text-muted);
}

/* Forms styling */
.form-group {
  margin-bottom: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1rem;
  color: white;
  font-family: var(--font-family-body);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
  background: rgba(15, 23, 42, 0.8);
}

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

fieldset {
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: rgba(30, 41, 59, 0.2);
}

legend {
  font-family: var(--font-family-title);
  font-weight: 600;
  font-size: 1.05rem;
  color: #ffffff;
  padding: 0 0.75rem;
}

/* Button UI */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
  font-family: var(--font-family-body);
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.btn-danger {
  background: var(--color-danger);
  color: white;
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: #e11d48;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--border-radius-sm);
}

/* Tables styling */
.table-container {
  width: 100%;
  overflow-x: auto;
  margin-top: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: rgba(15, 23, 42, 0.4);
  padding: 1rem 1.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  letter-spacing: 0.5px;
}

/* Sortable table headers */
th.sortable {
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: color 0.2s ease, background-color 0.2s ease;
}

th.sortable:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

body.light-theme th.sortable:hover {
  background: rgba(15, 23, 42, 0.04);
}

th.sortable::after {
  content: ' ↕';
  font-size: 0.8em;
  opacity: 0.4;
  margin-left: 0.35rem;
}

th.sortable.sort-asc::after {
  content: ' ↑';
  opacity: 0.9;
  color: var(--color-primary);
}

th.sortable.sort-desc::after {
  content: ' ↓';
  opacity: 0.9;
  color: var(--color-primary);
}

td {
  padding: 1.15rem 1.25rem;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

tr:last-child td {
  border-bottom: none;
}

/* Badges styling */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  line-height: 1;
}

.badge-tech { background: rgba(99, 102, 241, 0.12); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.25); }
.badge-health { background: rgba(16, 185, 129, 0.12); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.25); }
.badge-energy { background: rgba(245, 158, 11, 0.12); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.25); }
.badge-retail { background: rgba(6, 182, 212, 0.12); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.25); }
.badge-custom { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); border: 1px solid var(--border-light); }

/* Dynamic industry badge colors for custom/other categories (Dark Theme defaults) */
.badge-ind-0 { background: rgba(99, 102, 241, 0.12); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.25); }
.badge-ind-1 { background: rgba(16, 185, 129, 0.12); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.25); }
.badge-ind-2 { background: rgba(245, 158, 11, 0.12); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.25); }
.badge-ind-3 { background: rgba(6, 182, 212, 0.12); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.25); }
.badge-ind-4 { background: rgba(236, 72, 153, 0.12); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.25); }
.badge-ind-5 { background: rgba(168, 85, 247, 0.12); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.25); }
.badge-ind-6 { background: rgba(249, 115, 22, 0.12); color: #ff9d5c; border: 1px solid rgba(249, 115, 22, 0.25); }
.badge-ind-7 { background: rgba(20, 184, 166, 0.12); color: #2dd4bf; border: 1px solid rgba(20, 184, 166, 0.25); }

/* Control panel for filters */
.filter-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-group label {
  margin-bottom: 0;
  white-space: nowrap;
}

/* Modal styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(2, 6, 17, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: #0f172a;
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  transform: translateY(30px);
  transition: var(--transition-smooth);
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

.modal-header {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: var(--font-family-title);
  font-size: 1.3rem;
  font-weight: 700;
  color: white;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.modal-body {
  padding: 1.75rem;
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Company directory tabs */
.tab-container {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1.5rem;
  gap: 1.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.85rem 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  position: relative;
  transition: var(--transition-smooth);
  font-family: var(--font-family-title);
}

.tab-btn:hover {
  color: white;
}

.tab-btn.active {
  color: var(--color-primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary);
}

/* Financial statement table adjustments */
.table-financials td.num,
.table-financials th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-financials tr.total-row td {
  font-weight: 700;
  background: rgba(99, 102, 241, 0.05);
  border-top: 2px solid rgba(99, 102, 241, 0.2);
  border-bottom: 2px solid rgba(99, 102, 241, 0.2);
  color: white;
}

/* Common Size Bar chart UI */
.horizontal-progress-bar {
  background: rgba(255, 255, 255, 0.05);
  height: 8px;
  border-radius: 99px;
  width: 100px;
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.5rem;
  overflow: hidden;
}

.horizontal-progress-fill {
  height: 100%;
  border-radius: 99px;
}

.horizontal-progress-fill.primary { background: var(--color-primary); }
.horizontal-progress-fill.success { background: var(--color-success); }
.horizontal-progress-fill.danger { background: var(--color-danger); }
.horizontal-progress-fill.warning { background: var(--color-warning); }

/* Custom Switch for light/dark mode if we want it */
.theme-toggle {
  margin-left: auto;
}

/* Alert notifications styles */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10000;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--border-radius-md);
  padding: 1rem 1.5rem;
  color: white;
  min-width: 300px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideInRight 0.3s ease-out forwards;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success { border-left-color: var(--color-success); }
.toast.danger { border-left-color: var(--color-danger); }

/* Responsive adjustments */
@media (max-width: 900px) {
  body {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: 1.5rem;
  }
  
  .brand-section {
    margin-bottom: 1.5rem;
  }
  
  .nav-menu {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }
  
  .nav-link {
    padding: 0.6rem 1rem;
    white-space: nowrap;
  }
  
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
  }
  
  .sidebar-footer {
    display: none;
  }
}

/* Home Welcome Panel style */
.welcome-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%), var(--panel-bg);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.welcome-card h2 {
  font-family: var(--font-family-title);
  font-size: 1.6rem;
  color: white;
  margin-bottom: 0.5rem;
}

.welcome-card p {
  color: var(--text-secondary);
  max-width: 700px;
}

.badge-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Search bar styling */
.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 250px;
}

.search-wrapper input {
  padding-left: 2.5rem;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Analysis Recommendations container */
.analysis-card {
  border-left: 4px solid var(--color-info);
}

.analysis-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.analysis-item {
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 1.25rem;
  transition: var(--transition-smooth);
}

.analysis-item:hover {
  border-color: rgba(14, 165, 233, 0.3);
  transform: translateY(-2px);
}

.analysis-item-title {
  font-weight: 700;
  color: white;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.analysis-item-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.analysis-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--color-info-bg);
  color: var(--color-info);
  padding: 0.15rem 0.45rem;
  border-radius: var(--border-radius-sm);
}

/* Grid comparisons in Company Detail */
.benchmark-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.benchmark-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.benchmark-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.benchmark-values {
  display: flex;
  gap: 2rem;
  font-weight: 600;
}

.benchmark-company {
  color: white;
}

.benchmark-industry {
  color: var(--color-info);
}

.comparison-indicator {
  font-size: 0.8rem;
  font-weight: bold;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.comparison-indicator.worse {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* ==========================================================================
   LIGHT THEME OVERRIDES
   ========================================================================== */
body.light-theme {
  --bg-gradient: #f8fafc; /* Much brighter solid background */
  --panel-bg: #ffffff; /* Solid white background for cards */
  --panel-border: rgba(15, 23, 42, 0.06); /* Very subtle card border */
  --panel-glow: transparent;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-light: rgba(15, 23, 42, 0.06);
  
  --color-primary-glow: rgba(99, 102, 241, 0.06);
}

body.light-theme .badge-tech { background: rgba(79, 70, 229, 0.08); color: #4f46e5; border: 1px solid rgba(79, 70, 229, 0.18); }
body.light-theme .badge-health { background: rgba(5, 150, 105, 0.08); color: #059669; border: 1px solid rgba(5, 150, 105, 0.18); }
body.light-theme .badge-energy { background: rgba(217, 119, 6, 0.08); color: #b45309; border: 1px solid rgba(217, 119, 6, 0.18); }
body.light-theme .badge-retail { background: rgba(8, 145, 178, 0.08); color: #0891b2; border: 1px solid rgba(8, 145, 178, 0.18); }
body.light-theme .badge-custom { background: rgba(15, 23, 42, 0.05); color: var(--text-secondary); border: 1px solid rgba(15, 23, 42, 0.1); }

body.light-theme .badge-ind-0 { background: rgba(79, 70, 229, 0.08); color: #4f46e5; border: 1px solid rgba(79, 70, 229, 0.18); }
body.light-theme .badge-ind-1 { background: rgba(5, 150, 105, 0.08); color: #059669; border: 1px solid rgba(5, 150, 105, 0.18); }
body.light-theme .badge-ind-2 { background: rgba(217, 119, 6, 0.08); color: #b45309; border: 1px solid rgba(217, 119, 6, 0.18); }
body.light-theme .badge-ind-3 { background: rgba(8, 145, 178, 0.08); color: #0891b2; border: 1px solid rgba(8, 145, 178, 0.18); }
body.light-theme .badge-ind-4 { background: rgba(219, 39, 119, 0.08); color: #db2777; border: 1px solid rgba(219, 39, 119, 0.18); }
body.light-theme .badge-ind-5 { background: rgba(124, 58, 237, 0.08); color: #7c3aed; border: 1px solid rgba(124, 58, 237, 0.18); }
body.light-theme .badge-ind-6 { background: rgba(234, 88, 12, 0.08); color: #ea580c; border: 1px solid rgba(234, 88, 12, 0.18); }
body.light-theme .badge-ind-7 { background: rgba(13, 148, 136, 0.08); color: #0d9488; border: 1px solid rgba(13, 148, 136, 0.18); }

body.light-theme .card-kpi-row {
  background: rgba(15, 23, 42, 0.02);
  border-color: rgba(15, 23, 42, 0.05);
}

body.light-theme .glass-card {
  box-shadow: 0 4px 12px 0 rgba(15, 23, 42, 0.04), 
              0 1px 2px 0 rgba(15, 23, 42, 0.02); /* Softened shadows */
}

body.light-theme .sidebar {
  background: rgba(241, 245, 249, 0.95);
  border-right: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .brand-name {
  background: linear-gradient(to right, #0f172a, #4f46e5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.light-theme .nav-link {
  color: var(--text-secondary);
}

body.light-theme .nav-link:hover {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.03);
}

body.light-theme .nav-item.active .nav-link {
  color: var(--color-primary);
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
  box-shadow: inset 0 0 12px rgba(99, 102, 241, 0.05);
}

body.light-theme .header-title h1,
body.light-theme .card-title {
  color: #0f172a;
}

body.light-theme input[type="text"],
body.light-theme input[type="number"],
body.light-theme select,
body.light-theme textarea {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: #0f172a;
}

body.light-theme input[type="text"]:focus,
body.light-theme input[type="number"]:focus,
body.light-theme select:focus,
body.light-theme textarea:focus {
  background: #ffffff;
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.1);
}

body.light-theme fieldset {
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme legend {
  color: #0f172a;
}

body.light-theme th {
  background: rgba(241, 245, 249, 0.6);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  color: var(--text-secondary);
}

body.light-theme td {
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  color: #334155;
}

body.light-theme tr:hover td {
  background: rgba(15, 23, 42, 0.01);
}

body.light-theme .table-financials tr.total-row td {
  background: rgba(99, 102, 241, 0.04);
  border-top: 2px solid rgba(99, 102, 241, 0.15);
  border-bottom: 2px solid rgba(99, 102, 241, 0.15);
  color: #0f172a;
}

body.light-theme .table-financials tr.total-row:last-child {
  background: rgba(16, 185, 129, 0.04) !important;
}

body.light-theme .table-financials tr.total-row:last-child td {
  border-top: 2px solid rgba(16, 185, 129, 0.15) !important;
  border-bottom: 2px solid rgba(16, 185, 129, 0.15) !important;
  color: var(--color-success) !important;
}

body.light-theme .metric-value {
  color: #0f172a;
}

body.light-theme .modal-container {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

body.light-theme .modal-header {
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .modal-header h3 {
  color: #0f172a;
}

body.light-theme .modal-footer {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .analysis-item {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

body.light-theme .analysis-item:hover {
  border-color: rgba(14, 165, 233, 0.2);
}

body.light-theme .analysis-item-title {
  color: #0f172a;
}

body.light-theme .benchmark-company {
  color: #0f172a;
}

body.light-theme .btn-secondary {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text-secondary);
  border-color: rgba(15, 23, 42, 0.1);
}

body.light-theme .btn-secondary:hover {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

body.light-theme .toast {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  color: #0f172a;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  border-left: 4px solid var(--color-primary);
}

body.light-theme .toast button {
  color: var(--text-muted) !important;
}

body.light-theme .horizontal-progress-bar {
  background: rgba(15, 23, 42, 0.06);
}

body.light-theme #theme-switch-container {
  background: rgba(15, 23, 42, 0.03) !important;
  border-color: rgba(15, 23, 42, 0.08) !important;
}

/* Guest mode restrictions */
body.is-guest .admin-only {
  display: none !important;
}

/* Google AdSense Layout Styles */
.ad-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
  display: block;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

/* Sidebar Ad Box */
.sidebar-ad-box {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-light);
  border-radius: var(--border-radius-md);
  text-align: center;
  transition: var(--transition-smooth);
}

.sidebar-ad-box:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(99, 102, 241, 0.3);
}

.ad-content-mock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
}

/* Dashboard Bottom Banner */
.dashboard-ad-banner {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.03) 0%, rgba(14, 165, 233, 0.03) 100%), var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.ad-banner-content-mock {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
  gap: 1rem;
}

.ad-logo-mock {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-info) 100%);
  color: white;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
  flex-shrink: 0;
}

.ad-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
  transition: var(--transition-smooth);
}

.ad-close-btn:hover {
  color: var(--color-danger);
  transform: scale(1.1);
}

/* Light Theme Overrides for Ad Units */
body.light-theme .sidebar-ad-box {
  background: rgba(15, 23, 42, 0.02);
  border-color: rgba(15, 23, 42, 0.08);
}

body.light-theme .sidebar-ad-box:hover {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(99, 102, 241, 0.25);
}

body.light-theme .dashboard-ad-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.02) 0%, rgba(14, 165, 233, 0.02) 100%), #ffffff;
  border-color: rgba(15, 23, 42, 0.06);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
}

/* Mobile responsive adjustments */
@media (max-width: 900px) {
  .sidebar-ad-box {
    display: none; /* Hide sidebar ad box on small screens where nav scrolls horizontally */
  }
}

/* Thailand SVG Map & Spatial Analytics Styles */
.map-layout-container {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
  min-height: 480px;
}

@media (max-width: 900px) {
  .map-layout-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.map-visualization-pane {
  position: relative;
  background: rgba(15, 23, 42, 0.25);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  min-height: 400px;
}

#thailand-map-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#thailand-map-container svg {
  width: 100%;
  height: auto;
  max-height: 500px;
}

/* Style the paths inside the SVG map */
#thailand-map-container svg path {
  fill: rgba(255, 255, 255, 0.05); /* Default color for 0 revenue provinces */
  stroke: rgba(255, 255, 255, 0.15); /* Province borders */
  stroke-width: 0.8;
  cursor: pointer;
  pointer-events: fill; /* Prevent stroke expansions from glitching mouse events */
  transition: fill 0.35s ease, stroke 0.35s ease, filter 0.35s ease;
}

/* Hover state on provinces */
#thailand-map-container svg path:hover {
  stroke: #ffffff;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 8px var(--color-primary-glow));
}

/* Highlighting class for active province selections */
#thailand-map-container svg path.province-selected {
  stroke: #ffffff;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 10px var(--color-primary));
}

/* Heatmap scale for revenue density */
#thailand-map-container svg path.rev-level-1 { fill: rgba(99, 102, 241, 0.15); }
#thailand-map-container svg path.rev-level-2 { fill: rgba(99, 102, 241, 0.35); }
#thailand-map-container svg path.rev-level-3 { fill: rgba(99, 102, 241, 0.55); }
#thailand-map-container svg path.rev-level-4 { fill: rgba(99, 102, 241, 0.75); }
#thailand-map-container svg path.rev-level-5 { fill: #6366f1; }

/* Loading spinner overlays */
.map-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  border-radius: var(--border-radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Right details column container */
.inner-details-card {
  height: 100%;
  max-height: 520px; /* Prevent outer height expansion */
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 1.75rem;
  background: rgba(30, 41, 59, 0.25);
  border: 1px solid var(--border-light);
}

.details-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem; /* Allow space for scrollbar inside details body */
}

.details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.details-header h3 {
  font-family: var(--font-family-title);
  font-size: 1.4rem;
  font-weight: 700;
  color: white;
}

.province-kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.province-kpi-box {
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 1rem;
}

.province-kpi-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.province-kpi-value {
  font-family: var(--font-family-title);
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

.province-co-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  max-height: 230px;
  padding-right: 0.25rem;
}

.province-co-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1rem;
  transition: var(--transition-smooth);
  cursor: pointer;
}

.province-co-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(99, 102, 241, 0.3);
}

/* Light Theme Overrides for Map Visualization */
body.light-theme .map-visualization-pane {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(15, 23, 42, 0.06);
}

body.light-theme #thailand-map-container svg path {
  fill: #f1f5f9; /* default zero color */
  stroke: #cbd5e1; /* province borders */
}

body.light-theme #thailand-map-container svg path:hover {
  stroke: var(--color-primary);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.15));
}

body.light-theme #thailand-map-container svg path.province-selected {
  stroke: var(--color-primary);
  stroke-width: 2.2;
  filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.25));
}

/* High-contrast heat map scale for light theme */
body.light-theme #thailand-map-container svg path.rev-level-1 { fill: #c7d2fe; }
body.light-theme #thailand-map-container svg path.rev-level-2 { fill: #a5b4fc; }
body.light-theme #thailand-map-container svg path.rev-level-3 { fill: #818cf8; }
body.light-theme #thailand-map-container svg path.rev-level-4 { fill: #4f46e5; }
body.light-theme #thailand-map-container svg path.rev-level-5 { fill: #312e81; }

body.light-theme .inner-details-card {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.06);
}

body.light-theme .details-header {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

body.light-theme .details-header h3 {
  color: #0f172a;
}

body.light-theme .province-kpi-box {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.02);
}

body.light-theme .province-kpi-value {
  color: #0f172a;
}

body.light-theme .province-co-item {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.02);
}

body.light-theme .province-co-item:hover {
  background: rgba(99, 102, 241, 0.03);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.06);
}

/* Company Logo Styles */
.company-logo-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family-title);
  color: white;
  text-transform: uppercase;
  user-select: none;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: var(--transition-smooth);
}

.company-logo-img {
  object-fit: contain;
  background: white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: var(--transition-smooth);
}

.company-logo-avatar.small, .company-logo-img.small {
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-light);
}

.company-logo-avatar.large, .company-logo-img.large {
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-light);
}

body.light-theme .company-logo-avatar {
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
}

body.light-theme .company-logo-img {
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
}
