/* ===================================
   ENHANCED THEME SWITCHER CSS
   Complete version with all features
   =================================== */

/* Theme Variables - Override Layer */
.theme-applied,
body[class*="theme-"] {
    /* Original METI Theme Variables as Default */
    --primary: #ff6b6b !important;
    --secondary: #667eea !important;
    --success: #0fa968 !important;
    --warning: #f7b42c !important;
    --danger: #eb3349 !important;
    --info: #4facfe !important;
    
    /* Gradients */
    --primary-gradient: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%) !important;
    --secondary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    --success-gradient: linear-gradient(135deg, #0fa968 0%, #11c770 100%) !important;
    --warning-gradient: linear-gradient(135deg, #f7b42c 0%, #fc575e 100%) !important;
    --danger-gradient: linear-gradient(135deg, #eb3349 0%, #f45c43 100%) !important;
    --info-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%) !important;
    
    /* Dark Theme Colors */
    --dark-900: #0a0a0a !important;
    --dark-800: #111111 !important;
    --dark-700: #1a1a1a !important;
    --dark-600: #242424 !important;
    --dark-500: #2e2e2e !important;
    
    /* Text Colors */
    --text-primary: #ffffff !important;
    --text-secondary: rgba(255, 255, 255, 0.7) !important;
    --text-muted: rgba(255, 255, 255, 0.4) !important;
    
    /* Glass Effects */
    --glass: rgba(255, 255, 255, 0.02) !important;
    --glass-hover: rgba(255, 255, 255, 0.05) !important;
    --glass-active: rgba(255, 255, 255, 0.08) !important;
    
    /* Borders */
    --border: rgba(255, 255, 255, 0.06) !important;
    --border-hover: rgba(255, 255, 255, 0.1) !important;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3) !important;
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5) !important;
    --shadow-glow: 0 0 20px rgba(255, 107, 107, 0.3) !important;
    --glow: 0 0 20px rgba(255, 107, 107, 0.3) !important;
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    --transition-speed: 300ms !important;
    
    /* Layout */
    --border-radius: 12px !important;
}

/* Theme Switcher Panel - Floating Design */
.theme-switcher-wrapper {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif !important;
}

.theme-switcher-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.theme-switcher-toggle:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.5);
}

.theme-switcher-toggle svg {
    width: 24px;
    height: 24px;
    color: white;
    animation: rotate-icon 10s linear infinite;
}

@keyframes rotate-icon {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.theme-switcher-panel {
    position: fixed;
    right: -420px;
    top: 50%;
    transform: translateY(-50%);
    width: 400px;
    max-height: 90vh;
    background: rgba(20, 20, 24, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.theme-switcher-wrapper.active .theme-switcher-panel {
    right: 80px;
}

.theme-panel-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.theme-panel-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-close-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
}

.theme-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    transform: rotate(90deg);
}

.theme-panel-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
    color: #ffffff;
}

.theme-panel-body::-webkit-scrollbar {
    width: 8px;
}

.theme-panel-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.theme-panel-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 4px;
}

/* Theme Section */
.theme-section {
    margin-bottom: 2rem;
}

.theme-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* Theme Presets Grid */
.theme-presets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.theme-preset-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.theme-preset-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
}

.theme-preset-card.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: #6366f1;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.theme-preset-preview {
    width: 100%;
    height: 40px;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    position: relative;
    overflow: hidden;
}

.theme-preset-name {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* Preset Theme Gradients */
.preset-original { background: linear-gradient(135deg, #ff6b6b, #667eea); }
.preset-midnight { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.preset-ocean { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.preset-sunset { background: linear-gradient(135deg, #f97316, #fb923c); }
.preset-forest { background: linear-gradient(135deg, #10b981, #059669); }
.preset-neon { background: linear-gradient(135deg, #d946ef, #a21caf); }
.preset-cyberpunk { background: linear-gradient(135deg, #ff00ff, #00ffff); }
.preset-vampire { background: linear-gradient(135deg, #dc143c, #8b0000); }
.preset-aurora { background: linear-gradient(135deg, #00c6ff, #0072ff); }

/* Color Controls */
.color-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.color-control-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.color-control-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.color-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
}

.color-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-picker {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    background: transparent;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-hex {
    width: 80px;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    text-align: center;
}

.color-hex:focus {
    outline: none;
    border-color: #6366f1;
    background: rgba(0, 0, 0, 0.5);
}

/* Settings Sliders */
.settings-controls {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.slider-control {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
}

.slider-value {
    color: #6366f1;
    font-weight: 600;
    font-size: 0.75rem;
}

.theme-slider {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.theme-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
    transition: all 0.3s ease;
}

.theme-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 15px rgba(99, 102, 241, 0.5);
}

/* Toggle Switches */
.toggle-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.toggle-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #ffffff;
}

/* Action Buttons */
.theme-actions {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.theme-btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.theme-btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    grid-column: span 2;
}

.theme-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

.theme-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.theme-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Compact Mode Styles */
body.compact-mode {
    font-size: 14px !important;
}

body.compact-mode .sidebar {
    width: 200px !important;
}

body.compact-mode .nav-item {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.8rem !important;
}

body.compact-mode .nav-section-title {
    font-size: 0.7rem !important;
    padding: 0.3rem 0.5rem !important;
}

body.compact-mode .stat-card {
    padding: 1rem !important;
}

body.compact-mode .stat-value {
    font-size: 1.5rem !important;
}

body.compact-mode .page-header {
    padding: 1rem 0 !important;
}

body.compact-mode .page-title {
    font-size: 1.5rem !important;
}

body.compact-mode .content,
body.compact-mode .main-content,
body.compact-mode .page-content {
    padding: 1rem !important;
}

body.compact-mode .chart-card {
    padding: 1rem !important;
}

body.compact-mode .btn,
body.compact-mode button {
    padding: 0.5rem 1rem !important;
    font-size: 0.8rem !important;
}

/* No Gradient Text */
body.no-gradient-text * {
    background: none !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: unset !important;
    background-clip: unset !important;
}

/* Animations Disabled */
body.animations-disabled * {
    animation: none !important;
    transition: none !important;
}

/* High Contrast Mode */
body.high-contrast {
    filter: contrast(1.2) !important;
}

body.high-contrast * {
    border-color: rgba(255, 255, 255, 0.3) !important;
}

/* Particle Canvas */
#themeParticleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.4;
}

/* Force Color Application */
body[class*="theme-"] .primary,
body[class*="theme-"] [class*="primary"] {
    background: var(--primary) !important;
    color: white !important;
}

body[class*="theme-"] [style*="gradient"] {
    background-image: var(--primary-gradient) !important;
}

body[class*="theme-"] .sidebar {
    background: var(--dark-800) !important;
}

body[class*="theme-"] .cosmic-bg {
    opacity: var(--bg-opacity, 1);
}

/* Responsive */
@media (max-width: 768px) {
    .theme-switcher-panel {
        width: 90vw;
        right: -100vw;
    }
    
    .theme-switcher-wrapper.active .theme-switcher-panel {
        right: 5vw;
    }
    
    .theme-presets-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .theme-actions {
        grid-template-columns: 1fr;
    }
    
    .theme-btn-primary {
        grid-column: span 1;
    }
}

/* Animations */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(99, 102, 241, 0.6);
    }
}

.theme-switcher-toggle.pulse {
    animation: pulse-glow 2s infinite;
}

/* Notification Styles */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}