/* Theme & Styles for Dark/Light Mode + Language Settings */

/* Dark Mode Overrides */
[data-theme="dark"] {
  --bg-color: #0b1329;       /* Deep dark navy background */
  --text-main: #f1f5f9;      /* Light gray for readable text */
  --text-muted: #94a3b8;     /* Lighter slate for muted text */
  --surface: #111e3b;        /* Dark blue-gray card surface */
  --border: #1e293b;         /* Slate border */
  
  /* Dashboard Specific & Inline Variables */
  --navy: #f1f5f9;           /* Text color */
  --muted: #94a3b8;          /* Muted text color */
  --border: #1e293b;         /* Border color */
  --primary-soft: #112836;   /* Dark teal soft accent */
  --bg-surface: #111e3b;     /* Chart card background */
  --border-color: #1e293b;   /* Chart card border */
}

/* Explicit body overrides for dark mode */
[data-theme="dark"] body {
  background: #0b1329 !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .sidebar {
  background: #090e1d !important;
  border-right-color: #1e293b !important;
}

[data-theme="dark"] .sidebar__header {
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .sidebar__link {
  color: #94a3b8 !important;
}

[data-theme="dark"] .sidebar__link.is-active,
[data-theme="dark"] .sidebar__link:hover {
  background: #112836 !important;
  color: #23b8ae !important;
}

[data-theme="dark"] .mockup-container {
  background: #111e3b !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .floating-card {
  background: rgba(17, 30, 59, 0.9) !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .prompt-card,
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .quick-actions,
[data-theme="dark"] .metric-card,
[data-theme="dark"] .header-card,
[data-theme="dark"] .assistant-chat-container,
[data-theme="dark"] .chat-card,
[data-theme="dark"] .data-table-card {
  background: #111e3b !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .navbar {
  background: rgba(11, 19, 41, 0.9) !important;
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .feature-card {
  background: #111e3b !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] footer {
  background: #090e1d !important;
  border-top-color: #1e293b !important;
}

/* Control Components styles */
.settings-control {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
}

.theme-toggle-btn {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 100px;
  padding: 4px 12px;
  height: 42px;
  width: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--text-main, var(--navy));
  transition: all 0.3s ease;
  position: relative;
}

[data-theme="dark"] .theme-toggle-btn {
  background: var(--surface, #111e3b);
  border-color: var(--border, #1e293b);
}

.theme-toggle-btn:hover {
  border-color: #94a3b8;
  background: var(--surface, #fff);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

[data-theme="dark"] .theme-toggle-btn:hover {
  border-color: #475569;
  background: var(--surface, #111e3b);
}

.theme-toggle-btn i {
  font-size: 18px;
  color: #f59e0b;
  transition: transform 0.3s ease, color 0.3s ease;
}

.theme-toggle-btn.is-light i {
  color: #f59e0b;
}

[data-theme="dark"] .theme-toggle-btn i {
  color: #cbd5e1;
}

.theme-switch-track {
  width: 40px;
  height: 22px;
  background-color: #e2e8f0;
  border-radius: 12px;
  position: relative;
  transition: background-color 0.3s ease;
  display: inline-block;
}

[data-theme="dark"] .theme-switch-track {
  background-color: #1e293b;
}

.theme-switch-knob {
  width: 16px;
  height: 16px;
  background-color: #0284c7;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
}

.theme-toggle-btn.is-dark .theme-switch-knob {
  transform: translateX(18px);
  background-color: #38bdf8;
}

.theme-toggle-btn.is-dark .theme-switch-track {
  background-color: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Custom Language Selector */
.custom-lang-selector {
  position: relative;
  display: inline-block;
  font-family: inherit;
}

.custom-lang-trigger {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 100px;
  padding: 4px 14px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-main, var(--navy));
  font-size: 15px;
  font-weight: 500;
  transition: all 0.3s ease;
}

[data-theme="dark"] .custom-lang-trigger {
  background: var(--surface, #111e3b);
  border-color: var(--border, #1e293b);
}

.custom-lang-trigger:hover {
  border-color: #94a3b8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

[data-theme="dark"] .custom-lang-trigger:hover {
  border-color: #475569;
}

.custom-lang-flag {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.custom-lang-flag svg {
  width: 100%;
  height: 100%;
  display: block;
}

.custom-lang-label {
  font-weight: 600;
  color: var(--text-main, var(--navy));
}

.custom-lang-chevron {
  font-size: 11px;
  color: #64748b;
  transition: transform 0.2s ease;
}

[data-theme="dark"] .custom-lang-chevron {
  color: #cbd5e1;
}

.custom-lang-selector.is-open .custom-lang-chevron {
  transform: rotate(180deg);
}

/* Custom premium scale for logos across all headers and sidebars */
.brand div,
.brand--dark div,
.dashboard-brand div {
  width: 72px !important;
  height: 72px !important;
  transition: all 0.3s ease;
}
.brand div img,
.brand--dark div img,
.dashboard-brand div img {
  width: 68px !important;
  height: 68px !important;
  transform: scale(1.9) !important;
  transition: all 0.3s ease;
}

/* Dropdown Menu */
.custom-lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  min-width: 100px;
  display: none;
  flex-direction: column;
  padding: 6px;
  z-index: 1000;
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="dark"] .custom-lang-dropdown {
  background: #111e3b;
  border-color: #1e293b;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.custom-lang-selector.is-open .custom-lang-dropdown {
  display: flex;
}

.custom-lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 14px;
  font-weight: 500;
}

.custom-lang-option:hover {
  background-color: var(--primary-soft, rgba(35, 184, 174, 0.08));
}

[data-theme="dark"] .custom-lang-option:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.custom-lang-option.is-selected {
  background-color: var(--primary-soft, rgba(35, 184, 174, 0.15));
  color: var(--primary, #23b8ae);
}

/* Hide original native selector */
.lang-selector.is-hidden {
  display: none !important;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Utility to override text color to navy in dark mode if explicitly set */
[data-theme="dark"] .text-navy {
  color: #f1f5f9 !important;
}

/* Dashboard Elements Dark Mode Styling */
[data-theme="dark"] .dashboard-header {
  background: rgba(17, 30, 59, 0.92) !important;
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .dashboard-header strong {
  color: #ffffff !important;
}

[data-theme="dark"] .filters-container {
  background: #111e3b !important;
  border-color: #1e293b !important;
  box-shadow: none !important;
}

[data-theme="dark"] .filter-select {
  background-color: #1a2c54 !important;
  color: #f1f5f9 !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .filter-select:hover {
  background-color: #203562 !important;
  border-color: #23b8ae !important;
}

[data-theme="dark"] .summary-grid article {
  background: #111e3b !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .summary-grid article:hover {
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .summary-grid span {
  color: #cbd5e1 !important;
}

[data-theme="dark"] .summary-grid strong {
  color: #ffffff !important;
}

[data-theme="dark"] .chart-card {
  background: #111e3b !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .chart-card h3 {
  color: #ffffff !important;
}

[data-theme="dark"] label {
  color: #94a3b8 !important;
}

[data-theme="dark"] .sidebar__footer button {
  background: #112836 !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .sidebar__footer button:hover {
  background: #1b384b !important;
}

[data-theme="dark"] .sidebar__user strong {
  color: #ffffff !important;
}

[data-theme="dark"] .sidebar__user div span {
  color: #94a3b8 !important;
}

[data-theme="dark"] .filter-group label {
  color: #94a3b8 !important;
}

/* Other Pages Dark Mode Overrides (Users Table, Mock Cards, Modals) */
[data-theme="dark"] .mock-card {
  background: #111e3b !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .mock-card h3,
[data-theme="dark"] .mock-card h4 {
  color: #ffffff !important;
}

[data-theme="dark"] .users-grid {
  background: #111e3b !important;
  border-color: #1e293b !important;
  box-shadow: none !important;
}

[data-theme="dark"] .users-table th {
  background: #15223f !important;
  color: #f1f5f9 !important;
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .users-table td {
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .modal-content {
  background: #111e3b !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .modal-header {
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .form-group label {
  color: #94a3b8 !important;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select {
  background: #15223f !important;
  color: #f1f5f9 !important;
  border-color: #1e293b !important;
}

/* Assets Page Dark Mode Overrides */
[data-theme="dark"] .asset-card {
  background: #111e3b !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .asset-card h3,
[data-theme="dark"] .asset-card h4,
[data-theme="dark"] .asset-card h5 {
  color: #ffffff !important;
}

[data-theme="dark"] .depreciation-section,
[data-theme="dark"] .asset-list-item {
  background: #15223f !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .asset-list-item .dot-label {
  color: #cbd5e1 !important;
}

[data-theme="dark"] .asset-list-item strong {
  color: #ffffff !important;
}

[data-theme="dark"] .depreciation-track {
  background: #1e293b !important;
}

/* Reports Page Dark Mode Overrides */
[data-theme="dark"] .repo-toolbar,
[data-theme="dark"] .report-row {
  background: #111e3b !important;
  border-color: #1e293b !important;
  box-shadow: none !important;
}

[data-theme="dark"] .search-box input {
  background: #15223f !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .chip {
  background: #15223f !important;
  border-color: #1e293b !important;
  color: #cbd5e1 !important;
}

[data-theme="dark"] .chip.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
}

[data-theme="dark"] .report-title-text {
  color: #ffffff !important;
}

/* Global Table Row Hover Dark Mode Overrides */
[data-theme="dark"] tr:hover,
[data-theme="dark"] .users-table tr:hover,
[data-theme="dark"] .debt-table tr:hover,
[data-theme="dark"] .audit-table tr:hover {
  background: #1a2c54 !important;
}

/* Debt Table Specific Dark Mode Overrides */
[data-theme="dark"] .debt-table th {
  background: #15223f !important;
  color: #cbd5e1 !important;
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .debt-table td {
  color: #cbd5e1 !important;
  border-bottom-color: #1e293b !important;
}

/* AI Assistant Page Dark Mode Overrides */
[data-theme="dark"] .chat-container {
  background-color: #0b1329 !important;
}

[data-theme="dark"] .chat-welcome h2 {
  color: #ffffff !important;
}

[data-theme="dark"] .chat-welcome p {
  color: #94a3b8 !important;
}

[data-theme="dark"] .chat-input-area {
  background: #111e3b !important;
  border-top-color: #1e293b !important;
}

[data-theme="dark"] #chat-input {
  background: #15223f !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] #chat-input:focus {
  border-color: #23b8ae !important;
}

[data-theme="dark"] .bubble {
  background-color: #111e3b !important;
  color: #cbd5e1 !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .bubble strong {
  color: #ffffff !important;
}

[data-theme="dark"] .bubble code {
  background: #15223f !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .user-message .bubble {
  background: linear-gradient(135deg, #1e40af, #1e3a8a) !important;
  border-color: #1d4ed8 !important;
  color: #ffffff !important;
}

[data-theme="dark"] .session-item:hover {
  background-color: #15223f !important;
}

[data-theme="dark"] .session-item.active {
  background-color: #112836 !important;
  border-color: #23b8ae !important;
}

[data-theme="dark"] .session-title {
  color: #cbd5e1 !important;
}

[data-theme="dark"] .session-item.active .session-title {
  color: #23b8ae !important;
}

[data-theme="dark"] .sidebar-header-section {
  border-bottom-color: #1e293b !important;
}

/* Report View Button Dark Mode Overrides */
[data-theme="dark"] .btn-view {
  background: #15223f !important;
  color: #cbd5e1 !important;
}

[data-theme="dark"] .btn-view:hover {
  background: #203562 !important;
  color: #ffffff !important;
}

/* Sidebar AI Q&A Button Dark Mode Override */
[data-theme="dark"] .sidebar__link--ai {
  color: #ffffff !important;
}

[data-theme="dark"] .sidebar__link--ai svg {
  fill: #ffffff !important;
}

/* Sidebar Avatar Dark Mode Override */
[data-theme="dark"] .sidebar__avatar {
  background: #112836 !important;
  color: #23b8ae !important;
}

/* Document Preview Modal Dark Mode Overrides */
[data-theme="dark"] .preview-modal-content {
  background: #111e3b !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4) !important;
}

[data-theme="dark"] #preview-modal-title {
  color: #ffffff !important;
}

[data-theme="dark"] .preview-table th {
  background: #15223f !important;
  color: #cbd5e1 !important;
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .preview-table td {
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .preview-table tr:hover {
  background: #1a2c54 !important;
}

/* ==========================================
   Landing / Introduction Page Dark Mode Overrides
   ========================================== */
[data-theme="dark"] .hero h1 {
  background: linear-gradient(to right, #f8fafc, #cbd5e1) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

[data-theme="dark"] .btn-secondary {
  background: #111e3b !important;
  color: #f1f5f9 !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .btn-secondary:hover {
  background: #1e293b !important;
  border-color: #23b8ae !important;
}

[data-theme="dark"] .features {
  background: #090e1d !important;
  border-top: 1px solid #1e293b !important;
}

[data-theme="dark"] .section-header h2 {
  color: #ffffff !important;
}

[data-theme="dark"] .feature-card:hover {
  background: #1a2c54 !important;
  border-color: #23b8ae !important;
}

[data-theme="dark"] .mockup-chat {
  background: #1e293b !important;
  color: #f1f5f9 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .mockup-chart {
  background: linear-gradient(180deg, #111e3b 0%, #1e293b 100%) !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .mockup-line {
  background: #334155 !important;
}

/* ==========================================
   Responsive Scrollable Charts on Mobile
   ========================================== */
@media (max-width: 850px) {
  .chart-wrapper {
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    display: block !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .chart-wrapper canvas#barChart,
  .chart-wrapper canvas#revenueDeptBarChart,
  .chart-wrapper canvas#expenseDeptBarChart,
  .chart-wrapper canvas#revenueLineChart,
  .chart-wrapper canvas#expenseLineChart,
  .chart-wrapper canvas#budgetChart {
    width: 1000px !important;
    min-width: 1000px !important;
    height: 340px !important;
    display: block !important;
  }
}

/* ==========================================
   Liabilities Page (Báo cáo Công nợ) Dark Mode
   ========================================== */
[data-theme="dark"] .kpi-card.receivables {
  background: rgba(35, 184, 174, 0.12) !important;
  border-color: rgba(35, 184, 174, 0.3) !important;
}

[data-theme="dark"] .kpi-card.receivables .amount {
  color: #23b8ae !important;
}

[data-theme="dark"] .kpi-card.receivables p {
  color: #a1a1aa !important;
}

[data-theme="dark"] .kpi-card.payables {
  background: rgba(220, 38, 38, 0.12) !important;
  border-color: rgba(220, 38, 38, 0.3) !important;
}

[data-theme="dark"] .kpi-card.payables .amount {
  color: #f87171 !important;
}

[data-theme="dark"] .kpi-card.payables p {
  color: #a1a1aa !important;
}

[data-theme="dark"] .kpi-card h3 {
  color: #e2e8f0 !important;
}

/* Table layout adjustments */
.type-badge {
  white-space: nowrap !important;
}

@media (max-width: 768px) {
  .debt-table {
    min-width: 650px !important;
  }
}

[data-theme="dark"] .table-container {
  border-color: #1e293b !important;
}

[data-theme="dark"] .debt-table th {
  background: #111e35 !important;
  color: #e2e8f0 !important;
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .debt-table td {
  border-bottom-color: #1e293b !important;
  color: #cbd5e1 !important;
}

[data-theme="dark"] .debt-table tr:hover {
  background: #1a2c54 !important;
}

[data-theme="dark"] .type-badge.receivable {
  background: rgba(3, 105, 161, 0.2) !important;
  color: #38bdf8 !important;
}

[data-theme="dark"] .type-badge.payable {
  background: rgba(107, 33, 168, 0.2) !important;
  color: #c084fc !important;
}

[data-theme="dark"] .tab-btn:hover {
  background: #1a2c54 !important;
  color: #ffffff !important;
}

[data-theme="dark"] .filter-tabs {
  border-bottom-color: #1e293b !important;
}

/* Mobile Optimization for Theme & Language toggle buttons (Top Right Header) */
@media (max-width: 768px) {
  .theme-toggle-btn {
    height: 34px !important;
    width: 66px !important;
    padding: 2px 8px !important;
  }
  .theme-toggle-btn i {
    font-size: 14px !important;
  }
  .theme-switch-track {
    width: 30px !important;
    height: 18px !important;
  }
  .theme-switch-knob {
    width: 14px !important;
    height: 14px !important;
    top: 2px !important;
    left: 2px !important;
  }
  .theme-toggle-btn.is-dark .theme-switch-knob {
    transform: translateX(12px) !important;
  }
  .custom-lang-trigger {
    height: 34px !important;
    padding: 2px 8px !important;
    gap: 5px !important;
    font-size: 13px !important;
  }
  .custom-lang-flag {
    width: 18px !important;
    height: 18px !important;
  }
}

/* Premium Skeleton Loading Animation */
.skeleton {
  position: relative;
  overflow: hidden;
  background-color: #e2e8f0 !important;
  color: transparent !important;
  border-radius: 6px;
  display: inline-block;
  min-height: 24px;
  min-width: 120px;
  pointer-events: none;
}

[data-theme="dark"] .skeleton {
  background-color: #1e293b !important;
}

.skeleton::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateX(-100%);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.4) 20%,
    rgba(255, 255, 255, 0.7) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: shimmer-effect 1.5s infinite;
  content: '';
}

[data-theme="dark"] .skeleton::after {
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.05) 20%,
    rgba(255, 255, 255, 0.15) 60%,
    rgba(255, 255, 255, 0) 100%
  );
}

@keyframes shimmer-effect {
  100% {
    transform: translateX(100%);
  }
}


