/* CSS Custom Properties for Theming */

/* Base Theme Variables */
:root {
    /* Primary Brand Colors */
    --primary-color: #3b82f6;
    --primary-color-dark: #2563eb;
    --primary-color-light: #93c5fd;
    --primary-color-alpha: rgba(59, 130, 246, 0.1);
    
    /* Accent Colors */
    --accent-color: #8b5cf6;
    --accent-color-dark: #7c3aed;
    --accent-color-light: #c4b5fd;
    --accent-color-alpha: rgba(139, 92, 246, 0.1);
    
    /* Status Colors */
    --success-color: #10b981;
    --success-color-light: #34d399;
    --success-color-dark: #059669;
    --success-color-alpha: rgba(16, 185, 129, 0.1);
    
    --error-color: #ef4444;
    --error-color-light: #f87171;
    --error-color-dark: #dc2626;
    --error-color-alpha: rgba(239, 68, 68, 0.1);
    
    --warning-color: #f59e0b;
    --warning-color-light: #fbbf24;
    --warning-color-dark: #d97706;
    --warning-color-alpha: rgba(245, 158, 11, 0.1);
    
    --info-color: #06b6d4;
    --info-color-light: #22d3ee;
    --info-color-dark: #0891b2;
    --info-color-alpha: rgba(6, 182, 212, 0.1);
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    --bg-active: #cbd5e1;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    
    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --text-disabled: #cbd5e1;
    --text-inverse: #ffffff;
    
    /* Border Colors */
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    --border-heavy: #94a3b8;
    --border-focus: var(--primary-color);
    
    /* Shadow Colors */
    --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);
    
    /* Tool-specific Colors */
    --json-valid: var(--success-color);
    --json-invalid: var(--error-color);
    --json-background: var(--bg-secondary);
    
    /* Interactive States */
    --button-primary-bg: var(--primary-color);
    --button-primary-hover: var(--primary-color-dark);
    --button-secondary-bg: var(--bg-secondary);
    --button-secondary-hover: var(--bg-hover);
    
    /* Input States */
    --input-bg: var(--bg-primary);
    --input-border: var(--border-medium);
    --input-focus: var(--primary-color);
    --input-error: var(--error-color);
    --input-success: var(--success-color);
    
    /* Code syntax highlighting */
    --code-bg: var(--bg-secondary);
    --code-text: var(--text-primary);
    --code-keyword: var(--primary-color);
    --code-string: var(--success-color);
    --code-number: var(--accent-color);
    --code-property: var(--info-color);
    --code-operator: var(--text-secondary);
    --code-comment: var(--text-tertiary);
    --code-error: var(--error-color);
}

/* Dark Theme */
[data-theme="dark"] {
    /* Background Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #475569;
    --bg-active: #64748b;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-disabled: #64748b;
    --text-inverse: #1e293b;
    
    /* Border Colors */
    --border-light: #334155;
    --border-medium: #475569;
    --border-heavy: #64748b;
    
    /* Shadow Colors */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    
    /* Adjust alpha colors for dark theme */
    --primary-color-alpha: rgba(59, 130, 246, 0.2);
    --accent-color-alpha: rgba(139, 92, 246, 0.2);
    --success-color-alpha: rgba(16, 185, 129, 0.2);
    --error-color-alpha: rgba(239, 68, 68, 0.2);
    --warning-color-alpha: rgba(245, 158, 11, 0.2);
    --info-color-alpha: rgba(6, 182, 212, 0.2);
    
    /* Tool-specific Colors */
    --json-background: var(--bg-tertiary);
    
    /* Interactive States */
    --button-secondary-bg: var(--bg-tertiary);
    --button-secondary-hover: var(--bg-hover);
    
    /* Input States */
    --input-bg: var(--bg-tertiary);
    --input-border: var(--border-medium);
    
    /* Code highlighting for dark theme */
    --code-keyword: var(--primary-color-light);
    --code-string: var(--success-color-light);
    --code-number: var(--accent-color-light);
    --code-property: var(--info-color-light);
}

/* System preference for dark theme */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* Background Colors */
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;
        --bg-hover: #475569;
        --bg-active: #64748b;
        --bg-overlay: rgba(0, 0, 0, 0.7);
        
        /* Text Colors */
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-tertiary: #94a3b8;
        --text-disabled: #64748b;
        --text-inverse: #1e293b;
        
        /* Border Colors */
        --border-light: #334155;
        --border-medium: #475569;
        --border-heavy: #64748b;
        
        /* Shadow Colors */
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
        
        /* Adjust alpha colors for dark theme */
        --primary-color-alpha: rgba(59, 130, 246, 0.2);
        --accent-color-alpha: rgba(139, 92, 246, 0.2);
        --success-color-alpha: rgba(16, 185, 129, 0.2);
        --error-color-alpha: rgba(239, 68, 68, 0.2);
        --warning-color-alpha: rgba(245, 158, 11, 0.2);
        --info-color-alpha: rgba(6, 182, 212, 0.2);
        
        /* Tool-specific Colors */
        --json-background: var(--bg-tertiary);
        
        /* Interactive States */
        --button-secondary-bg: var(--bg-tertiary);
        --button-secondary-hover: var(--bg-hover);
        
        /* Input States */
        --input-bg: var(--bg-tertiary);
        --input-border: var(--border-medium);
        
        /* Code highlighting for dark theme */
        --code-keyword: var(--primary-color-light);
        --code-string: var(--success-color-light);
        --code-number: var(--accent-color-light);
        --code-property: var(--info-color-light);
    }
}

/* High Contrast Theme */
[data-theme="high-contrast"] {
    --primary-color: #0066cc;
    --primary-color-dark: #0052a3;
    --accent-color: #7f39fb;
    --success-color: #00a86b;
    --error-color: #d63384;
    --warning-color: #fd7e14;
    --info-color: #17a2b8;
    
    --border-light: #6c757d;
    --border-medium: #495057;
    --border-heavy: #343a40;
}

/* System Theme Detection */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        color-scheme: light;
    }
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
    }
}

/* Smooth transitions for theme changes */
*, *::before, *::after {
    transition: 
        background-color 0.3s ease,
        border-color 0.3s ease,
        color 0.3s ease,
        box-shadow 0.3s ease;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

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

/* Firefox scrollbar styling */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) var(--bg-secondary);
}

/* Focus ring for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Selection colors */
::selection {
    background-color: var(--primary-color-alpha);
    color: var(--text-primary);
}

::-moz-selection {
    background-color: var(--primary-color-alpha);
    color: var(--text-primary);
}

/* Animation utilities */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% { transform: translate3d(0, 0, 0); }
    40%, 43% { transform: translate3d(0, -30px, 0); }
    70% { transform: translate3d(0, -15px, 0); }
    90% { transform: translate3d(0, -4px, 0); }
}

/* Utility classes for animations */
.fade-in { animation: fadeIn 0.3s ease-in-out; }
.fade-out { animation: fadeOut 0.3s ease-in-out; }
.slide-up { animation: slideUp 0.3s ease-out; }
.slide-down { animation: slideDown 0.3s ease-out; }
.pulse { animation: pulse 2s infinite; }
.bounce { animation: bounce 1s; }

/* Component-specific theme overrides */
.tool-container {
    background: var(--bg-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.form-input,
.form-textarea,
.form-select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px var(--primary-color-alpha);
}

.btn-primary {
    background: var(--button-primary-bg);
    color: var(--text-inverse);
    border: 1px solid var(--button-primary-bg);
}

.btn-primary:hover {
    background: var(--button-primary-hover);
    border-color: var(--button-primary-hover);
}

.btn-secondary {
    background: var(--button-secondary-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
    background: var(--button-secondary-hover);
    border-color: var(--border-heavy);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tool-card,
    .benefit-card,
    .stat-card {
        border-width: 2px;
    }
}

/* Print styles */
@media print {
    :root {
        --bg-primary: white;
        --bg-secondary: white;
        --bg-tertiary: white;
        --text-primary: black;
        --text-secondary: #333;
        --border-light: #ccc;
        --border-medium: #999;
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
        --shadow-xl: none;
    }
    
    .app-header,
    .app-footer,
    .theme-toggle,
    .help-button,
    .toast-container,
    .loading-overlay {
        display: none !important;
    }
    
    .main-content {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    .content-panel {
        display: block !important;
        page-break-inside: avoid;
    }
}
