/* Theme System - Light/Dark Mode Support */

/* ========================================
   DARK MODE (Default)
   ======================================== */
:root {
  /* Background Colors */
  --bg-primary: #0f0f12;
  --bg-secondary: #18181c;
  --bg-card: #1e1e24;
  --bg-elevated: #252530;
  
  /* Foreground Colors */
  --fg-primary: #f5f5f7;
  --fg-secondary: #9898a0;
  --fg-muted: #5c5c66;
  
  /* Accent Colors */
  --accent: #ff6b35;
  --accent-glow: rgba(255, 107, 53, 0.3);
  --accent-secondary: #00d4aa;
  
  /* Border & Shadows */
  --border: rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  
  /* Other */
  --card-radius: 20px;
  --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Calendar Colors */
  --calendar-level-0: #161b22;
  --calendar-level-1: #0e4429;
  --calendar-level-2: #006d32;
  --calendar-level-3: #26a641;
  --calendar-level-4: #39d353;
  
  /* Gradient Backgrounds */
  --gradient-ambient-1: rgba(255, 107, 53, 0.08);
  --gradient-ambient-2: rgba(0, 212, 170, 0.06);
  
  /* Header Background */
  --header-bg: rgba(15, 15, 18, 0.8);
  
  /* Modal Backdrop */
  --modal-backdrop-bg: rgba(0, 0, 0, 0.7);
}

/* ========================================
   LIGHT MODE
   ======================================== */
[data-theme="light"] {
  /* Background Colors */
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-elevated: #f1f3f5;
  
  /* Foreground Colors */
  --fg-primary: #1a1a2e;
  --fg-secondary: #4a4a5a;
  --fg-muted: #8a8a9a;
  
  /* Accent Colors (keep consistent) */
  --accent: #ff6b35;
  --accent-glow: rgba(255, 107, 53, 0.25);
  --accent-secondary: #00d4aa;
  
  /* Border & Shadows */
  --border: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.1);
  
  /* Calendar Colors (lighter versions) */
  --calendar-level-0: #ebedf0;
  --calendar-level-1: #9be9a8;
  --calendar-level-2: #40c463;
  --calendar-level-3: #30a14e;
  --calendar-level-4: #216e39;
  
  /* Gradient Backgrounds (subtle) */
  --gradient-ambient-1: rgba(255, 107, 53, 0.05);
  --gradient-ambient-2: rgba(0, 212, 170, 0.04);
  
  /* Header Background */
  --header-bg: rgba(255, 255, 255, 0.85);
  
  /* Modal Backdrop */
  --modal-backdrop-bg: rgba(0, 0, 0, 0.4);
}

/* ========================================
   THEME TOGGLE BUTTON STYLES
   ======================================== */
.theme-toggle {
  width: 48px;
  height: 48px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 22px;
  transition: all 0.2s var(--transition-smooth);
  color: var(--fg-secondary);
}

.theme-toggle:hover {
  background: var(--bg-card);
  color: var(--fg-primary);
  transform: scale(1.05);
  box-shadow: var(--shadow-sm);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* ========================================
   SMOOTH THEME TRANSITIONS
   ======================================== */
body,
.app-container,
.sidebar,
.page-header,
.overview-card,
.section,
.stat-box,
.modal,
.chat-window,
.toast,
input,
button,
select,
textarea {
  transition: background-color 0.3s ease, 
              color 0.3s ease, 
              border-color 0.3s ease,
              box-shadow 0.3s ease;
}

/* ========================================
   LIGHT MODE SPECIFIC ADJUSTMENTS
   ======================================== */
[data-theme="light"] body::before {
  background: 
    radial-gradient(ellipse 80% 50% at 20% 0%, var(--gradient-ambient-1) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%, var(--gradient-ambient-2) 0%, transparent 50%);
}

[data-theme="light"] .page-header {
  background: rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .brand-name {
  background: linear-gradient(135deg, var(--fg-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="light"] .overview-card {
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .overview-card:hover {
  box-shadow: var(--shadow-md);
}

[data-theme="light"] .candidate-table tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .nav-item.active,
[data-theme="light"] .nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .user-card {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .chat-message.agent {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .modal {
  box-shadow: var(--shadow-lg);
}

[data-theme="light"] .toast {
  box-shadow: var(--shadow-md);
}

[data-theme="light"] .stat-bar-bg {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .chat-input,
[data-theme="light"] .form-input,
[data-theme="light"] .form-select {
  background: var(--bg-primary);
  border-color: var(--border);
}

[data-theme="light"] .agent-item {
  background: var(--bg-elevated);
}

[data-theme="light"] .agent-item:hover {
  background: var(--bg-primary);
}

/* ========================================
   MOBILE RESPONSIVE UTILITIES
   ======================================== */

/* Mobile-first touch optimization */
@media (max-width: 768px) {
  /* Improve touch targets */
  button, .btn, .nav-item, .candidate-card, .skill-card, .position-card {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Form elements touch friendly */
  input, select, textarea {
    font-size: 16px !important; /* Prevent zoom on iOS */
    min-height: 44px;
  }
  
  /* Safe area for notched phones */
  .page-header {
    padding-top: max(16px, env(safe-area-inset-top)) !important;
    padding-left: max(16px, env(safe-area-inset-left)) !important;
    padding-right: max(16px, env(safe-area-inset-right)) !important;
  }
  
  /* Toast positioning for mobile */
  .toast {
    left: 16px !important;
    right: 16px !important;
    bottom: max(16px, env(safe-area-inset-bottom)) !important;
    text-align: center;
    justify-content: center;
  }
  
  /* Modal full-screen on mobile */
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 90vh !important;
    margin: 0 16px;
  }
  
  /* Chat window mobile sizing */
  .chat-window {
    width: calc(100% - 32px) !important;
    right: 16px !important;
    left: 16px !important;
    height: 60vh !important;
    max-height: 500px !important;
  }
}

/* Smaller screens */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }
  
  .page-title {
    font-size: 22px !important;
  }
  
  /* Stack form elements */
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Smaller padding */
  .page-content {
    padding: 16px !important;
  }
  
  /* Full-width buttons */
  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .modal {
    max-height: 95vh !important;
  }
  
  .chat-window {
    height: 80vh !important;
  }
}

/* Disable animations on low-power devices */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support for mobile browsers */
@media (prefers-color-scheme: dark) {
  /* System-level dark mode preference */
}
