/**
 * Theme Presets System
 * Allows users to choose from multiple color themes
 * Overrides existing --color-primary variables for seamless integration
 * Compatible with existing dark/light mode system
 */

/* ========== Theme Preset Variable Overrides ========== */

/* Default (Blue) - No override needed, matches existing design */
/* [data-theme-preset="default"] uses the page's native --color-primary */

/* Ocean Blue Theme */
[data-theme-preset="ocean"] {
  --color-primary: #0EA5E9;
  --color-primary-light: #38BDF8;
  --color-primary-dark: #0284C7;
}
[data-theme="dark"][data-theme-preset="ocean"] {
  --color-primary: #38BDF8;
  --color-primary-light: #7DD3FC;
  --color-primary-dark: #0EA5E9;
}

/* Forest Green Theme */
[data-theme-preset="forest"] {
  --color-primary: #059669;
  --color-primary-light: #10B981;
  --color-primary-dark: #047857;
}
[data-theme="dark"][data-theme-preset="forest"] {
  --color-primary: #34D399;
  --color-primary-light: #6EE7B7;
  --color-primary-dark: #10B981;
}

/* Sunset Orange Theme */
[data-theme-preset="sunset"] {
  --color-primary: #EA580C;
  --color-primary-light: #F97316;
  --color-primary-dark: #C2410C;
}
[data-theme="dark"][data-theme-preset="sunset"] {
  --color-primary: #FB923C;
  --color-primary-light: #FDBA74;
  --color-primary-dark: #F97316;
}

/* Royal Purple Theme */
[data-theme-preset="royal"] {
  --color-primary: #7C3AED;
  --color-primary-light: #8B5CF6;
  --color-primary-dark: #6D28D9;
}
[data-theme="dark"][data-theme-preset="royal"] {
  --color-primary: #A78BFA;
  --color-primary-light: #C4B5FD;
  --color-primary-dark: #8B5CF6;
}

/* Rose Pink Theme */
[data-theme-preset="rose"] {
  --color-primary: #E11D48;
  --color-primary-light: #F43F5E;
  --color-primary-dark: #BE123C;
}
[data-theme="dark"][data-theme-preset="rose"] {
  --color-primary: #FDA4AF;
  --color-primary-light: #FECDD3;
  --color-primary-dark: #F43F5E;
}

/* Amber Gold Theme */
[data-theme-preset="amber"] {
  --color-primary: #D97706;
  --color-primary-light: #F59E0B;
  --color-primary-dark: #B45309;
}
[data-theme="dark"][data-theme-preset="amber"] {
  --color-primary: #FBBF24;
  --color-primary-light: #FCD34D;
  --color-primary-dark: #F59E0B;
}

/* Teal Theme */
[data-theme-preset="teal"] {
  --color-primary: #0D9488;
  --color-primary-light: #14B8A6;
  --color-primary-dark: #0F766E;
}
[data-theme="dark"][data-theme-preset="teal"] {
  --color-primary: #2DD4BF;
  --color-primary-light: #5EEAD4;
  --color-primary-dark: #14B8A6;
}

/* ========== Theme Transition ========== */

/* Smooth transition for theme preset changes */
html.theme-preset-transition,
html.theme-preset-transition *,
html.theme-preset-transition *::before,
html.theme-preset-transition *::after {
  transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              fill 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              stroke 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ========== Theme Selector UI ========== */

.theme-selector {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
}

.theme-selector-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs, 6px);
  background: var(--bg-card, #fff);
  color: var(--text-primary, #1E293B);
  cursor: pointer;
  font-size: 0.8rem;
  min-height: 36px;
  min-width: 36px;
  transition: all 0.2s ease;
  font-family: inherit;
  line-height: 1;
}

.theme-selector-trigger:hover {
  border-color: var(--color-primary, #0284C7);
  background: var(--hover-bg, #F1F5F9);
}

.theme-selector-trigger:focus-visible {
  outline: 2px solid var(--color-primary, #0284C7);
  outline-offset: 2px;
}

.theme-selector-trigger[aria-expanded="true"] {
  border-color: var(--color-primary, #0284C7);
}

.theme-selector-preview {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.theme-selector-label {
  font-size: 0.75rem;
  white-space: nowrap;
}

.theme-selector-arrow {
  font-size: 0.65rem;
  opacity: 0.6;
  transition: transform 0.2s ease;
}

.theme-selector-trigger[aria-expanded="true"] .theme-selector-arrow {
  transform: rotate(180deg);
}

.theme-selector-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 220px;
  border-radius: var(--radius-sm, 10px);
  overflow: hidden;
  z-index: 10001;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg, 0 8px 30px rgba(0,0,0,0.15));
  background: var(--bg-card, #fff);
  animation: theme-dropdown-in 0.2s ease;
}

@keyframes theme-dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.theme-selector-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-size: 0.85rem;
  color: var(--text-primary, #1E293B);
  font-family: inherit;
  border-bottom: 1px solid var(--border-color);
}

.theme-selector-option:last-child {
  border-bottom: none;
}

.theme-selector-option:hover {
  background: var(--hover-bg, #F1F5F9);
}

.theme-selector-option:focus-visible {
  outline: 2px solid var(--color-primary, #0284C7);
  outline-offset: -2px;
}

.theme-selector-option.selected {
  color: #fff;
  font-weight: 500;
}

.theme-selector-option[data-theme-preset="default"].selected {
  background: linear-gradient(135deg, #38BDF8, #0284C7);
}

.theme-selector-option[data-theme-preset="ocean"].selected {
  background: linear-gradient(135deg, #38BDF8, #0EA5E9);
}

.theme-selector-option[data-theme-preset="forest"].selected {
  background: linear-gradient(135deg, #34D399, #10B981);
}

.theme-selector-option[data-theme-preset="sunset"].selected {
  background: linear-gradient(135deg, #FB923C, #F97316);
}

.theme-selector-option[data-theme-preset="royal"].selected {
  background: linear-gradient(135deg, #A78BFA, #8B5CF6);
}

.theme-selector-option[data-theme-preset="rose"].selected {
  background: linear-gradient(135deg, #FDA4AF, #F43F5E);
}

.theme-selector-option[data-theme-preset="amber"].selected {
  background: linear-gradient(135deg, #FBBF24, #F59E0B);
}

.theme-selector-option[data-theme-preset="teal"].selected {
  background: linear-gradient(135deg, #2DD4BF, #14B8A6);
}

.theme-selector-option .theme-selector-preview {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
}

.theme-selector-name {
  font-weight: 500;
  white-space: nowrap;
}

.theme-selector-desc {
  font-size: 0.7rem;
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

/* Dark mode dropdown */
[data-theme="dark"] .theme-selector-trigger {
  background: var(--bg-card, #1e293b);
  color: var(--text-primary, #e2e8f0);
  border-color: var(--border-color, #334155);
}

[data-theme="dark"] .theme-selector-trigger:hover {
  border-color: var(--color-primary, #38BDF8);
  background: var(--hover-bg, #334155);
}

[data-theme="dark"] .theme-selector-dropdown {
  background: var(--bg-card, #1e293b);
  border-color: var(--border-color, #334155);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

[data-theme="dark"] .theme-selector-option {
  color: var(--text-primary, #e2e8f0);
  border-bottom-color: var(--border-color, #334155);
}

[data-theme="dark"] .theme-selector-option:hover {
  background: var(--hover-bg, #334155);
}

/* Mobile responsive */
@media (max-width: 640px) {
  .theme-selector-label,
  .theme-selector-desc,
  .theme-selector-arrow {
    display: none;
  }
  .theme-selector-trigger {
    padding: 4px;
  }
  .theme-selector-dropdown {
    min-width: 180px;
    right: -20px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  html.theme-preset-transition,
  html.theme-preset-transition *,
  html.theme-preset-transition *::before,
  html.theme-preset-transition *::after {
    transition: none !important;
  }
  .theme-selector-dropdown {
    animation: none;
  }
}