/* ========================================
   GreenAdmin Theme System
   Supports: Light, Dark, Mix modes
   + Multiple Tailwind-inspired color palettes
   ======================================== */

/* ========================================
   Color Palettes (Tailwind-inspired)
   Each palette defines primary colors
   ======================================== */

/* Green (Default) */
[data-color="green"], :root {
  --ga-primary: #22c55e;
  --ga-primary-dark: #16a34a;
  --ga-primary-rgb: 34, 197, 94;
  --ga-primary-50: #f0fdf4;
  --ga-primary-100: #dcfce7;
  --ga-primary-200: #bbf7d0;
  --ga-primary-400: #4ade80;
  --ga-primary-600: #16a34a;
  --ga-primary-700: #15803d;
  --ga-primary-gradient: linear-gradient(135deg, #22c55e, #16a34a);
}

/* Blue */
[data-color="blue"] {
  --ga-primary: #3b82f6;
  --ga-primary-dark: #2563eb;
  --ga-primary-rgb: 59, 130, 246;
  --ga-primary-50: #eff6ff;
  --ga-primary-100: #dbeafe;
  --ga-primary-200: #bfdbfe;
  --ga-primary-400: #60a5fa;
  --ga-primary-600: #2563eb;
  --ga-primary-700: #1d4ed8;
  --ga-primary-gradient: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* Purple / Violet */
[data-color="purple"] {
  --ga-primary: #8b5cf6;
  --ga-primary-dark: #7c3aed;
  --ga-primary-rgb: 139, 92, 246;
  --ga-primary-50: #f5f3ff;
  --ga-primary-100: #ede9fe;
  --ga-primary-200: #ddd6fe;
  --ga-primary-400: #a78bfa;
  --ga-primary-600: #7c3aed;
  --ga-primary-700: #6d28d9;
  --ga-primary-gradient: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

/* Red / Rose */
[data-color="red"] {
  --ga-primary: #ef4444;
  --ga-primary-dark: #dc2626;
  --ga-primary-rgb: 239, 68, 68;
  --ga-primary-50: #fef2f2;
  --ga-primary-100: #fee2e2;
  --ga-primary-200: #fecaca;
  --ga-primary-400: #f87171;
  --ga-primary-600: #dc2626;
  --ga-primary-700: #b91c1c;
  --ga-primary-gradient: linear-gradient(135deg, #ef4444, #dc2626);
}

/* Orange */
[data-color="orange"] {
  --ga-primary: #f97316;
  --ga-primary-dark: #ea580c;
  --ga-primary-rgb: 249, 115, 22;
  --ga-primary-50: #fff7ed;
  --ga-primary-100: #ffedd5;
  --ga-primary-200: #fed7aa;
  --ga-primary-400: #fb923c;
  --ga-primary-600: #ea580c;
  --ga-primary-700: #c2410c;
  --ga-primary-gradient: linear-gradient(135deg, #f97316, #ea580c);
}

/* Teal */
[data-color="teal"] {
  --ga-primary: #14b8a6;
  --ga-primary-dark: #0d9488;
  --ga-primary-rgb: 20, 184, 166;
  --ga-primary-50: #f0fdfa;
  --ga-primary-100: #ccfbf1;
  --ga-primary-200: #99f6e4;
  --ga-primary-400: #2dd4bf;
  --ga-primary-600: #0d9488;
  --ga-primary-700: #0f766e;
  --ga-primary-gradient: linear-gradient(135deg, #14b8a6, #0d9488);
}

/* Indigo */
[data-color="indigo"] {
  --ga-primary: #6366f1;
  --ga-primary-dark: #4f46e5;
  --ga-primary-rgb: 99, 102, 241;
  --ga-primary-50: #eef2ff;
  --ga-primary-100: #e0e7ff;
  --ga-primary-200: #c7d2fe;
  --ga-primary-400: #818cf8;
  --ga-primary-600: #4f46e5;
  --ga-primary-700: #4338ca;
  --ga-primary-gradient: linear-gradient(135deg, #6366f1, #4f46e5);
}

/* Rose / Pink */
[data-color="rose"] {
  --ga-primary: #f43f5e;
  --ga-primary-dark: #e11d48;
  --ga-primary-rgb: 244, 63, 94;
  --ga-primary-50: #fff1f2;
  --ga-primary-100: #ffe4e6;
  --ga-primary-200: #fecdd3;
  --ga-primary-400: #fb7185;
  --ga-primary-600: #e11d48;
  --ga-primary-700: #be123c;
  --ga-primary-gradient: linear-gradient(135deg, #f43f5e, #e11d48);
}

/* Amber */
[data-color="amber"] {
  --ga-primary: #f59e0b;
  --ga-primary-dark: #d97706;
  --ga-primary-rgb: 245, 158, 11;
  --ga-primary-50: #fffbeb;
  --ga-primary-100: #fef3c7;
  --ga-primary-200: #fde68a;
  --ga-primary-400: #fbbf24;
  --ga-primary-600: #d97706;
  --ga-primary-700: #b45309;
  --ga-primary-gradient: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Cyan */
[data-color="cyan"] {
  --ga-primary: #06b6d4;
  --ga-primary-dark: #0891b2;
  --ga-primary-rgb: 6, 182, 212;
  --ga-primary-50: #ecfeff;
  --ga-primary-100: #cffafe;
  --ga-primary-200: #a5f3fc;
  --ga-primary-400: #22d3ee;
  --ga-primary-600: #0891b2;
  --ga-primary-700: #0e7490;
  --ga-primary-gradient: linear-gradient(135deg, #06b6d4, #0891b2);
}

/* ========================================
   MODE: Full Light
   Light sidebar + Light content
   ======================================== */
[data-theme="light"] {
  --ga-body-bg: #f1f5f9;
  --ga-card-bg: #ffffff;
  --ga-border: #e2e8f0;
  --ga-text: #1e293b;
  --ga-text-secondary: #64748b;
  --ga-text-muted: #94a3b8;
  --ga-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --ga-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --ga-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --ga-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

  --ga-sidebar-bg: #ffffff;
  --ga-sidebar-text: #334155;
  --ga-sidebar-hover: rgba(0, 0, 0, 0.04);
  --ga-sidebar-active: rgba(var(--ga-primary-rgb), 0.1);
  --ga-sidebar-border: #e2e8f0;
  --ga-sidebar-label-color: #94a3b8;
  --ga-sidebar-brand-color: #1e293b;
  --ga-sidebar-submenu-border: rgba(0,0,0,0.08);
  --ga-sidebar-submenu-dot: rgba(0,0,0,0.2);
  --ga-sidebar-submenu-dot-hover: rgba(0,0,0,0.5);
  --ga-sidebar-footer-border: #e2e8f0;
  --ga-sidebar-user-name-color: #1e293b;
  --ga-sidebar-user-role-color: #94a3b8;
}

/* ========================================
   MODE: Mix (Dark sidebar + Light content)
   This is the classic admin look
   ======================================== */
[data-theme="mix"] {
  --ga-body-bg: #f1f5f9;
  --ga-card-bg: #ffffff;
  --ga-border: #e2e8f0;
  --ga-text: #1e293b;
  --ga-text-secondary: #64748b;
  --ga-text-muted: #94a3b8;
  --ga-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --ga-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --ga-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --ga-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

  --ga-sidebar-bg: #1c2434;
  --ga-sidebar-text: #dee4ee;
  --ga-sidebar-hover: rgba(255, 255, 255, 0.06);
  --ga-sidebar-active: rgba(var(--ga-primary-rgb), 0.15);
  --ga-sidebar-border: rgba(255,255,255,0.08);
  --ga-sidebar-label-color: rgba(255,255,255,0.35);
  --ga-sidebar-brand-color: #ffffff;
  --ga-sidebar-submenu-border: rgba(255,255,255,0.08);
  --ga-sidebar-submenu-dot: rgba(255,255,255,0.25);
  --ga-sidebar-submenu-dot-hover: rgba(255,255,255,0.6);
  --ga-sidebar-footer-border: rgba(255,255,255,0.08);
  --ga-sidebar-user-name-color: #ffffff;
  --ga-sidebar-user-role-color: rgba(255,255,255,0.5);
}

/* ========================================
   MODE: Full Dark
   Dark sidebar + Dark content
   ======================================== */
[data-theme="dark"] {
  --ga-body-bg: #1e293b;
  --ga-card-bg: #334155;
  --ga-border: #475569;
  --ga-text: #f1f5f9;
  --ga-text-secondary: #cbd5e1;
  --ga-text-muted: #94a3b8;
  --ga-shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --ga-shadow: 0 1px 3px rgba(0,0,0,0.3);
  --ga-shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --ga-shadow-lg: 0 10px 15px rgba(0,0,0,0.3);

  --ga-sidebar-bg: #0f172a;
  --ga-sidebar-text: #dee4ee;
  --ga-sidebar-hover: rgba(255, 255, 255, 0.06);
  --ga-sidebar-active: rgba(var(--ga-primary-rgb), 0.15);
  --ga-sidebar-border: rgba(255,255,255,0.06);
  --ga-sidebar-label-color: rgba(255,255,255,0.3);
  --ga-sidebar-brand-color: #ffffff;
  --ga-sidebar-submenu-border: rgba(255,255,255,0.06);
  --ga-sidebar-submenu-dot: rgba(255,255,255,0.2);
  --ga-sidebar-submenu-dot-hover: rgba(255,255,255,0.5);
  --ga-sidebar-footer-border: rgba(255,255,255,0.06);
  --ga-sidebar-user-name-color: #ffffff;
  --ga-sidebar-user-role-color: rgba(255,255,255,0.45);
}

/* ========================================
   Additional sidebar styling for light mode
   (admin.css uses CSS variables for all sidebar colors,
    these add new rules not in admin.css)
   ======================================== */

/* Light mode sidebar gets a right border for visual separation */
[data-theme="light"] .ga-sidebar {
  border-right: 1px solid var(--ga-sidebar-border);
  box-shadow: 1px 0 3px rgba(0,0,0,0.04);
}

/* Avatars match the active primary color */
.ga-sidebar-avatar {
  background: linear-gradient(135deg, var(--ga-primary), var(--ga-primary-dark)) !important;
}

.ga-header-avatar {
  background: linear-gradient(135deg, var(--ga-primary), var(--ga-primary-dark)) !important;
}

.ga-profile-avatar {
  background: linear-gradient(135deg, var(--ga-primary), var(--ga-primary-dark)) !important;
}

.ga-profile-cover {
  background: linear-gradient(135deg, #1c2434 0%, var(--ga-primary-dark) 50%, var(--ga-primary) 100%) !important;
}

/* ========================================
   Dark mode overrides for alert text
   ======================================== */
[data-theme="dark"] .ga-alert-success { color: #6ee7b7; }
[data-theme="dark"] .ga-alert-warning { color: #fcd34d; }
[data-theme="dark"] .ga-alert-danger { color: #fca5a5; }
[data-theme="dark"] .ga-alert-info { color: #93c5fd; }

/* ========================================
   Theme Customizer Panel
   ======================================== */

/* Floating toggle button */
.ga-theme-toggle-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ga-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 1070;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(var(--ga-primary-rgb), 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: ga-fab-pulse 2s ease-in-out infinite;
}

.ga-theme-toggle-fab:hover {
  transform: scale(1.1) rotate(30deg);
  box-shadow: 0 6px 24px rgba(var(--ga-primary-rgb), 0.5);
}

.ga-theme-toggle-fab svg {
  width: 22px;
  height: 22px;
  transition: transform 0.3s;
}

@keyframes ga-fab-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(var(--ga-primary-rgb), 0.4); }
  50% { box-shadow: 0 4px 24px rgba(var(--ga-primary-rgb), 0.6); }
}

/* Panel overlay */
.ga-theme-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1080;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(2px);
}

.ga-theme-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Panel drawer */
.ga-theme-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  background: var(--ga-card-bg);
  z-index: 1090;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
  border-left: 1px solid var(--ga-border);
}

.ga-theme-panel.open {
  transform: translateX(0);
}

.ga-theme-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--ga-border);
  flex-shrink: 0;
}

.ga-theme-panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ga-text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.ga-theme-panel-title svg {
  width: 20px;
  height: 20px;
  color: var(--ga-primary);
}

.ga-theme-panel-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--ga-body-bg);
  color: var(--ga-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ga-theme-panel-close:hover {
  background: rgba(var(--ga-primary-rgb), 0.1);
  color: var(--ga-primary);
}

.ga-theme-panel-close svg {
  width: 18px;
  height: 18px;
}

.ga-theme-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.ga-theme-panel-body::-webkit-scrollbar { width: 4px; }
.ga-theme-panel-body::-webkit-scrollbar-thumb { background: var(--ga-border); border-radius: 4px; }

/* Section headings */
.ga-theme-section {
  margin-bottom: 28px;
}

.ga-theme-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ga-text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ga-theme-section-label svg {
  width: 14px;
  height: 14px;
}

/* Mode selector cards */
.ga-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ga-mode-card {
  border: 2px solid var(--ga-border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--ga-card-bg);
  position: relative;
}

.ga-mode-card:hover {
  border-color: var(--ga-primary);
  background: rgba(var(--ga-primary-rgb), 0.03);
}

.ga-mode-card.active {
  border-color: var(--ga-primary);
  background: rgba(var(--ga-primary-rgb), 0.06);
  box-shadow: 0 0 0 1px var(--ga-primary);
}

.ga-mode-card.active::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ga-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 10px;
  background-repeat: no-repeat;
  background-position: center;
}

/* Mini preview inside mode card */
.ga-mode-preview {
  width: 100%;
  height: 48px;
  border-radius: 6px;
  margin-bottom: 8px;
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.1);
}

.ga-mode-preview-sidebar {
  width: 30%;
  flex-shrink: 0;
}

.ga-mode-preview-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ga-mode-preview-header {
  height: 30%;
}

.ga-mode-preview-body {
  flex: 1;
}

/* Light preview */
.ga-mode-card[data-mode="light"] .ga-mode-preview-sidebar { background: #f8fafc; }
.ga-mode-card[data-mode="light"] .ga-mode-preview-header { background: #ffffff; }
.ga-mode-card[data-mode="light"] .ga-mode-preview-body { background: #f1f5f9; }

/* Dark preview */
.ga-mode-card[data-mode="dark"] .ga-mode-preview-sidebar { background: #0f172a; }
.ga-mode-card[data-mode="dark"] .ga-mode-preview-header { background: #334155; }
.ga-mode-card[data-mode="dark"] .ga-mode-preview-body { background: #1e293b; }

/* Mix preview */
.ga-mode-card[data-mode="mix"] .ga-mode-preview-sidebar { background: #1c2434; }
.ga-mode-card[data-mode="mix"] .ga-mode-preview-header { background: #ffffff; }
.ga-mode-card[data-mode="mix"] .ga-mode-preview-body { background: #f1f5f9; }

.ga-mode-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ga-text-secondary);
}

.ga-mode-card.active .ga-mode-label {
  color: var(--ga-primary);
}

/* Color palette grid */
.ga-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.ga-color-swatch {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ga-color-swatch:hover {
  transform: scale(1.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ga-color-swatch.active {
  border-color: var(--ga-text);
  box-shadow: 0 0 0 2px var(--ga-card-bg), 0 0 0 4px var(--ga-text);
}

.ga-color-swatch.active::after {
  content: '';
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.ga-color-swatch[data-color="green"] { background: linear-gradient(135deg, #22c55e, #16a34a); }
.ga-color-swatch[data-color="blue"] { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.ga-color-swatch[data-color="purple"] { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.ga-color-swatch[data-color="red"] { background: linear-gradient(135deg, #ef4444, #dc2626); }
.ga-color-swatch[data-color="orange"] { background: linear-gradient(135deg, #f97316, #ea580c); }
.ga-color-swatch[data-color="teal"] { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.ga-color-swatch[data-color="indigo"] { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.ga-color-swatch[data-color="rose"] { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.ga-color-swatch[data-color="amber"] { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ga-color-swatch[data-color="cyan"] { background: linear-gradient(135deg, #06b6d4, #0891b2); }

.ga-color-swatch-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ga-text-muted);
  text-align: center;
  margin-top: 6px;
  text-transform: capitalize;
}

/* Color swatch wrapper for label */
.ga-color-swatch-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Panel footer reset */
.ga-theme-panel-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--ga-border);
  flex-shrink: 0;
}

.ga-theme-reset-btn {
  width: 100%;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--ga-border);
  background: var(--ga-body-bg);
  color: var(--ga-text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  font-family: inherit;
}

.ga-theme-reset-btn:hover {
  border-color: var(--ga-primary);
  color: var(--ga-primary);
  background: rgba(var(--ga-primary-rgb), 0.05);
}

.ga-theme-reset-btn svg {
  width: 16px;
  height: 16px;
}

/* Current theme info badge */
.ga-theme-current {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(var(--ga-primary-rgb), 0.06);
  border: 1px solid rgba(var(--ga-primary-rgb), 0.15);
  border-radius: 8px;
  margin-bottom: 24px;
}

.ga-theme-current-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ga-primary);
  flex-shrink: 0;
  animation: ga-dot-pulse 2s ease-in-out infinite;
}

@keyframes ga-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ga-theme-current-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ga-text-secondary);
}

.ga-theme-current-text strong {
  color: var(--ga-primary);
  text-transform: capitalize;
}

/* ========================================
   Smooth transitions when changing themes
   ======================================== */
html.ga-theme-transitioning,
html.ga-theme-transitioning *,
html.ga-theme-transitioning *::before,
html.ga-theme-transitioning *::after {
  transition: background-color 0.35s ease,
              color 0.35s ease,
              border-color 0.35s ease,
              box-shadow 0.35s ease !important;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
  .ga-theme-panel {
    width: 100%;
    max-width: 100%;
  }

  .ga-theme-toggle-fab {
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
  }

  .ga-color-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }
}
