/* Theme System */
:root {
    /* Default (Light) Theme */
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    --warning-color: #ef4444;
    --success-color: #10b981;
    --info-color: #3b82f6;
    
    /* Text Colors - Light Theme */
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-inverse: #ffffff;
    --text-accent: #4f46e5;
    
    /* Background Colors - Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-code: #1e293b;
    --bg-card: #ffffff;
    --bg-modal: rgba(0, 0, 0, 0.8);
    --bg-hover: rgba(99, 102, 241, 0.1);
    --bg-active: rgba(99, 102, 241, 0.2);
    
    /* Border Colors - Light Theme */
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    --border-dark: #374151;
    --border-focus: #6366f1;
    
    /* Code Theme Colors - Light Theme */
    --code-bg: #f8fafc;
    --code-text: #334155;
    --code-comment: #64748b;
    --code-keyword: #0ea5e9;
    --code-string: #059669;
    --code-number: #dc2626;
    --code-function: #7c3aed;
    --code-variable: #ea580c;
}

/* Dark Theme */
.theme-dark {
    /* Primary Colors - Dark Theme */
    --primary-color: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --secondary-color: #34d399;
    --accent-color: #fbbf24;
    --warning-color: #f87171;
    --success-color: #34d399;
    --info-color: #60a5fa;
    
    /* Text Colors - Dark Theme */
    --text-primary: #ffffff;
    --text-secondary: #e5e7eb;
    --text-muted: #d1d5db;
    --text-inverse: #111827;
    --text-accent: #a5b4fc;
    
    /* Background Colors - Dark Theme */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-code: #0f172a;
    --bg-card: #1e293b;
    --bg-modal: rgba(0, 0, 0, 0.9);
    --bg-hover: rgba(129, 140, 248, 0.1);
    --bg-active: rgba(129, 140, 248, 0.2);
    
    /* Border Colors - Dark Theme */
    --border-light: #334155;
    --border-medium: #475569;
    --border-dark: #64748b;
    --border-focus: #818cf8;
    
    /* Code Theme Colors - Dark Theme */
    --code-bg: #0f172a;
    --code-text: #e2e8f0;
    --code-comment: #64748b;
    --code-keyword: #38bdf8;
    --code-string: #4ade80;
    --code-number: #fb7185;
    --code-function: #a78bfa;
    --code-variable: #fb923c;
    
    /* Shadows - Dark Theme */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

/* Light Theme Explicit */
.theme-light {
    /* Primary Colors - Light Theme */
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    --warning-color: #ef4444;
    --success-color: #10b981;
    --info-color: #3b82f6;
    
    /* Text Colors - Light Theme */
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-inverse: #ffffff;
    --text-accent: #4f46e5;
    
    /* Background Colors - Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-code: #f8fafc;
    --bg-card: #ffffff;
    --bg-modal: rgba(0, 0, 0, 0.8);
    --bg-hover: rgba(99, 102, 241, 0.1);
    --bg-active: rgba(99, 102, 241, 0.2);
    
    /* Border Colors - Light Theme */
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    --border-dark: #374151;
    --border-focus: #6366f1;
    
    /* Code Theme Colors - Light Theme */
    --code-bg: #f8fafc;
    --code-text: #334155;
    --code-comment: #64748b;
    --code-keyword: #0ea5e9;
    --code-string: #059669;
    --code-number: #dc2626;
    --code-function: #7c3aed;
    --code-variable: #ea580c;
    
    /* Shadows - Light Theme */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Theme Transition */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle {
    position: relative;
    overflow: hidden;
}

.theme-icon {
    transition: transform 0.3s ease;
}

.theme-dark .theme-icon {
    transform: rotate(180deg);
}

.theme-light .theme-toggle .theme-icon::before {
    content: '☀️';
}

.theme-dark .theme-toggle .theme-icon::before {
    content: '🌙';
}

/* Code Syntax Highlighting Themes */
.theme-light .code-input {
    background: var(--code-bg);
    color: var(--code-text);
}

.theme-dark .code-input {
    background: var(--code-bg);
    color: var(--code-text);
}

/* Prism.js Theme Override */
.theme-dark pre[class*="language-"] {
    background: var(--code-bg) !important;
    color: var(--code-text) !important;
}

.theme-dark .token.comment,
.theme-dark .token.prolog,
.theme-dark .token.doctype,
.theme-dark .token.cdata {
    color: var(--code-comment) !important;
}

.theme-dark .token.keyword,
.theme-dark .token.selector,
.theme-dark .token.important,
.theme-dark .token.atrule {
    color: var(--code-keyword) !important;
}

.theme-dark .token.string,
.theme-dark .token.char,
.theme-dark .token.attr-value,
.theme-dark .token.regex,
.theme-dark .token.variable {
    color: var(--code-string) !important;
}

.theme-dark .token.number,
.theme-dark .token.boolean,
.theme-dark .token.constant {
    color: var(--code-number) !important;
}

.theme-dark .token.function,
.theme-dark .token.method,
.theme-dark .token.function-name {
    color: var(--code-function) !important;
}

.theme-dark .token.property,
.theme-dark .token.tag,
.theme-dark .token.constant,
.theme-dark .token.symbol,
.theme-dark .token.deleted {
    color: var(--code-variable) !important;
}

/* Light Theme Prism.js Override */
.theme-light pre[class*="language-"] {
    background: var(--code-bg) !important;
    color: var(--code-text) !important;
}

.theme-light .token.comment,
.theme-light .token.prolog,
.theme-light .token.doctype,
.theme-light .token.cdata {
    color: var(--code-comment) !important;
}

.theme-light .token.keyword,
.theme-light .token.selector,
.theme-light .token.important,
.theme-light .token.atrule {
    color: var(--code-keyword) !important;
}

.theme-light .token.string,
.theme-light .token.char,
.theme-light .token.attr-value,
.theme-light .token.regex,
.theme-light .token.variable {
    color: var(--code-string) !important;
}

.theme-light .token.number,
.theme-light .token.boolean,
.theme-light .token.constant {
    color: var(--code-number) !important;
}

.theme-light .token.function,
.theme-light .token.method,
.theme-light .token.function-name {
    color: var(--code-function) !important;
}

.theme-light .token.property,
.theme-light .token.tag,
.theme-light .token.constant,
.theme-light .token.symbol,
.theme-light .token.deleted {
    color: var(--code-variable) !important;
}

/* Pattern Card Theme Adjustments */
.theme-dark .pattern-card-full {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.theme-dark .pattern-card-full:hover {
    border-color: var(--border-medium);
}

.theme-light .pattern-card-full {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.theme-light .pattern-card-full:hover {
    border-color: var(--border-medium);
}

/* Modal Theme Adjustments */
.theme-dark .modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.theme-light .modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

/* Playground Theme Adjustments */
.theme-dark .playground-container {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.theme-light .playground-container {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

/* Search Results Theme */
.theme-dark .search-results {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.theme-light .search-results {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

/* Scrollbar Theming */
.theme-dark ::-webkit-scrollbar {
    width: 8px;
}

.theme-dark ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.theme-dark ::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.theme-dark ::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

.theme-light ::-webkit-scrollbar {
    width: 8px;
}

.theme-light ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.theme-light ::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.theme-light ::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

/* Selection Colors */
.theme-dark ::selection {
    background: var(--primary-color);
    color: var(--text-inverse);
}

.theme-light ::selection {
    background: var(--primary-color);
    color: var(--text-inverse);
}

/* Focus Ring Colors */
.theme-dark *:focus {
    outline-color: var(--primary-color);
}

.theme-light *:focus {
    outline-color: var(--primary-color);
}

/* Gradient Backgrounds */
.theme-dark .hero {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.theme-light .hero {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* Auto Theme Detection */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #818cf8;
        --primary-dark: #6366f1;
        --primary-light: #a5b4fc;
        --secondary-color: #34d399;
        --accent-color: #fbbf24;
        --warning-color: #f87171;
        --success-color: #34d399;
        --info-color: #60a5fa;
        
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-muted: #9ca3af;
        --text-inverse: #111827;
        --text-accent: #818cf8;
        
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;
        --bg-code: #0f172a;
        --bg-card: #1e293b;
        --bg-modal: rgba(0, 0, 0, 0.9);
        --bg-hover: rgba(129, 140, 248, 0.1);
        --bg-active: rgba(129, 140, 248, 0.2);
        
        --border-light: #334155;
        --border-medium: #475569;
        --border-dark: #64748b;
        --border-focus: #818cf8;
        
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    }
}

/* Theme Transition Animation */
.theme-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .theme-dark {
        --bg-primary: #000000;
        --bg-secondary: #1a1a1a;
        --bg-card: #1a1a1a;
        --text-primary: #ffffff;
        --border-light: #666666;
        --border-medium: #888888;
    }
    
    .theme-light {
        --bg-primary: #ffffff;
        --bg-secondary: #f0f0f0;
        --bg-card: #ffffff;
        --text-primary: #000000;
        --border-light: #666666;
        --border-medium: #333333;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .theme-transition {
        transition: none;
    }
    
    .theme-icon {
        transition: none;
    }
}

/* Print Theme */
@media print {
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
}

/* Modern Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes checkmark {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--bg-tertiary) 50%,
        var(--bg-secondary) 75%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
    border-radius: 8px;
}

/* Interactive Tooltips */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-code);
    color: var(--text-inverse);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: var(--z-tooltip);
}

.tooltip:hover::after {
    opacity: 1;
}

/* Enhanced Focus States */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

/* Interactive Progress Bar */
.progress-ring {
    position: relative;
    width: 120px;
    height: 120px;
}

.progress-ring__circle {
    stroke: var(--border-light);
    fill: transparent;
}

.progress-ring__circle--progress {
    stroke: var(--primary-color);
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    transition: stroke-dashoffset 0.5s ease;
}

/* Notification Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 1rem;
    transform: translateX(calc(100% + 2rem));
    transition: transform 0.3s ease;
    z-index: var(--z-tooltip);
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-error {
    border-left: 4px solid var(--warning-color);
}

.toast-info {
    border-left: 4px solid var(--info-color);
} 