/**
 * =========================================================================
 * ARBIMASTER - GLOBAL THEME SYSTEM
 * File: assets/css/global-theme.css
 * Versione: 1.0 - Sistema tema globale per tutto il sito
 * =========================================================================
 */

/* === CSS VARIABLES GLOBALI === */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --transition-speed: 0.3s;
    --border-radius: 0.5rem;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* === THEME VARIABLES === */
[data-theme="light"] {
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-quaternary: #e5e7eb;
    --bg-gradient-start: #f8fafc;
    --bg-gradient-end: #e2e8f0;
    
    /* Text Colors */
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --text-inverse: #ffffff;
    --text-muted: #d1d5db;
    
    /* Border & Dividers */
    --border-color: #e5e7eb;
    --border-color-light: #f3f4f6;
    --border-color-strong: #d1d5db;
    --divider-color: #e5e7eb;
    
    /* Shadows & Effects */
    --shadow-sm: rgba(0, 0, 0, 0.05);
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-md: rgba(0, 0, 0, 0.15);
    --shadow-lg: rgba(0, 0, 0, 0.2);
    --shadow-xl: rgba(0, 0, 0, 0.25);
    
    /* Overlays */
    --overlay-light: rgba(255, 255, 255, 0.8);
    --overlay-medium: rgba(0, 0, 0, 0.5);
    --overlay-dark: rgba(0, 0, 0, 0.75);
    
    /* Form Elements */
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-border-focus: #3b82f6;
    --input-placeholder: #9ca3af;
    --input-disabled: #f3f4f6;
    
    /* Status Colors */
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --success-border: #a7f3d0;
    --success-accent: #10b981;
    
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --error-border: #fca5a5;
    --error-accent: #ef4444;
    
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --warning-border: #fcd34d;
    --warning-accent: #f59e0b;
    
    --info-bg: #dbeafe;
    --info-text: #1e40af;
    --info-border: #93c5fd;
    --info-accent: #3b82f6;
}

[data-theme="dark"] {
    /* Backgrounds */
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-tertiary: #374151;
    --bg-quaternary: #4b5563;
    --bg-gradient-start: #1e293b;
    --bg-gradient-end: #0f172a;
    
    /* Text Colors */
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --text-inverse: #1f2937;
    --text-muted: #6b7280;
    
    /* Border & Dividers */
    --border-color: #374151;
    --border-color-light: #4b5563;
    --border-color-strong: #6b7280;
    --divider-color: #374151;
    
    /* Shadows & Effects */
    --shadow-sm: rgba(0, 0, 0, 0.2);
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-md: rgba(0, 0, 0, 0.4);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --shadow-xl: rgba(0, 0, 0, 0.7);
    
    /* Overlays */
    --overlay-light: rgba(31, 41, 55, 0.8);
    --overlay-medium: rgba(0, 0, 0, 0.7);
    --overlay-dark: rgba(0, 0, 0, 0.9);
    
    /* Form Elements */
    --input-bg: #374151;
    --input-border: #4b5563;
    --input-border-focus: #60a5fa;
    --input-placeholder: #9ca3af;
    --input-disabled: #4b5563;
    
    /* Status Colors - Dark Theme Optimized */
    --success-bg: rgba(16, 185, 129, 0.15);
    --success-text: #34d399;
    --success-border: rgba(16, 185, 129, 0.3);
    --success-accent: #10b981;
    
    --error-bg: rgba(239, 68, 68, 0.15);
    --error-text: #f87171;
    --error-border: rgba(239, 68, 68, 0.3);
    --error-accent: #ef4444;
    
    --warning-bg: rgba(245, 158, 11, 0.15);
    --warning-text: #fbbf24;
    --warning-border: rgba(245, 158, 11, 0.3);
    --warning-accent: #f59e0b;
    
    --info-bg: rgba(59, 130, 246, 0.15);
    --info-text: #60a5fa;
    --info-border: rgba(59, 130, 246, 0.3);
    --info-accent: #3b82f6;
}

/* === GLOBAL THEME APPLICATION === */
* {
    font-family: var(--font-family);
}

html {
    transition: background-color var(--transition-speed) ease;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    transition: all var(--transition-speed) ease;
    line-height: 1.6;
}

/* === LAYOUT CONTAINERS === */
.themed-container {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--border-color);
    transition: all var(--transition-speed) ease;
}

.themed-card {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px var(--shadow);
    transition: all var(--transition-speed) ease;
}

.themed-panel {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

/* === FORM ELEMENTS === */
.themed-input,
input[type="text"]:not(.no-theme),
input[type="email"]:not(.no-theme),
input[type="password"]:not(.no-theme),
input[type="number"]:not(.no-theme),
input[type="search"]:not(.no-theme),
input[type="tel"]:not(.no-theme),
input[type="url"]:not(.no-theme),
textarea:not(.no-theme),
select:not(.no-theme) {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
    transition: all var(--transition-speed) ease;
}

.themed-input::placeholder,
input::placeholder:not(.no-theme),
textarea::placeholder:not(.no-theme) {
    color: var(--input-placeholder) !important;
}

.themed-input:focus,
input:focus:not(.no-theme),
textarea:focus:not(.no-theme),
select:focus:not(.no-theme) {
    border-color: var(--input-border-focus) !important;
    background-color: var(--input-bg) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    outline: none !important;
}

.themed-input:disabled,
input:disabled:not(.no-theme),
textarea:disabled:not(.no-theme),
select:disabled:not(.no-theme) {
    background-color: var(--input-disabled) !important;
    opacity: 0.6;
    cursor: not-allowed;
}

/* === BUTTONS === */
.btn-themed {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) ease;
}

.btn-themed:hover:not(:disabled) {
    background-color: var(--bg-quaternary);
    transform: translateY(-1px);
}

.btn-themed:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* === ALERTS & STATUS MESSAGES === */
.alert-themed {
    border-radius: var(--border-radius);
    padding: 1rem;
    border-width: 1px;
    transition: all var(--transition-speed) ease;
}

.alert-success {
    background-color: var(--success-bg) !important;
    color: var(--success-text) !important;
    border-color: var(--success-border) !important;
}

.alert-error,
.alert-danger {
    background-color: var(--error-bg) !important;
    color: var(--error-text) !important;
    border-color: var(--error-border) !important;
}

.alert-warning {
    background-color: var(--warning-bg) !important;
    color: var(--warning-text) !important;
    border-color: var(--warning-border) !important;
}

.alert-info {
    background-color: var(--info-bg) !important;
    color: var(--info-text) !important;
    border-color: var(--info-border) !important;
}

/* === TABLES === */
.themed-table,
table:not(.no-theme) {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--border-color);
    border-collapse: collapse;
    width: 100%;
}

.themed-table th,
table:not(.no-theme) th {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
    font-weight: 600;
}

.themed-table td,
table:not(.no-theme) td {
    border-color: var(--border-color);
    color: var(--text-primary);
}

.themed-table tr:hover,
table:not(.no-theme) tr:hover {
    background-color: var(--bg-secondary);
}

/* === MODALS & OVERLAYS === */
.themed-modal {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px var(--shadow-xl);
}

.themed-overlay {
    background-color: var(--overlay-medium);
    backdrop-filter: blur(4px);
}

/* === NAVIGATION & LINKS === */
.themed-link {
    color: var(--primary-color);
    transition: all var(--transition-speed) ease;
}

.themed-link:hover {
    color: var(--secondary-color);
    text-decoration: none;
}

/* === TAILWIND OVERRIDES === */
.bg-white { background-color: var(--bg-primary) !important; }
.bg-gray-50 { background-color: var(--bg-secondary) !important; }
.bg-gray-100 { background-color: var(--bg-tertiary) !important; }
.bg-gray-200 { background-color: var(--bg-quaternary) !important; }

.text-gray-900 { color: var(--text-primary) !important; }
.text-gray-800 { color: var(--text-primary) !important; }
.text-gray-700 { color: var(--text-primary) !important; }
.text-gray-600 { color: var(--text-secondary) !important; }
.text-gray-500 { color: var(--text-tertiary) !important; }
.text-gray-400 { color: var(--text-muted) !important; }

.border-gray-200 { border-color: var(--border-color) !important; }
.border-gray-300 { border-color: var(--border-color) !important; }
.border-gray-400 { border-color: var(--border-color-strong) !important; }

.divide-gray-200 > * + * { border-color: var(--border-color) !important; }

/* === PAGE-SPECIFIC OVERRIDES === */

/* Login/Register Pages */
.login-section,
.register-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
    min-height: 100vh;
}

.login-card,
.register-card {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Admin Panel */
.admin-container {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
    min-height: 100vh;
}

.admin-card,
.admin-wrapper > *,
.users-section {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* User Management */
.users-table,
.user-row {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.users-header {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

/* === SCROLLBAR THEMING === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color-strong);
    border-radius: 4px;
    transition: background-color var(--transition-speed) ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

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

/* === SELECTION STYLING === */
::selection {
    background-color: var(--primary-color);
    color: white;
}

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

/* === FOCUS STYLES === */
.themed-focus:focus,
*:focus:not(.no-theme) {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* === ANIMATIONS & TRANSITIONS === */
.theme-transition {
    transition: all var(--transition-speed) ease;
}

.theme-transition-colors {
    transition: background-color var(--transition-speed) ease, 
                color var(--transition-speed) ease,
                border-color var(--transition-speed) ease;
}

/* === RESPONSIVE ADJUSTMENTS === */
@media (max-width: 768px) {
    :root {
        --transition-speed: 0.2s; /* Faster on mobile */
    }
    
    body {
        font-size: 14px;
    }
    
    .themed-card {
        border-radius: calc(var(--border-radius) * 0.75);
    }
}

@media (max-width: 480px) {
    body {
        font-size: 13px;
    }
    
    .themed-card {
        border-radius: calc(var(--border-radius) * 0.5);
        padding: 1rem;
    }
}

/* === PRINT STYLES === */
@media print {
    [data-theme="dark"] {
        --bg-primary: #ffffff !important;
        --bg-secondary: #f9fafb !important;
        --text-primary: #000000 !important;
        --text-secondary: #333333 !important;
        --border-color: #cccccc !important;
    }
    
    .themed-card,
    .themed-container {
        box-shadow: none !important;
        border: 1px solid #cccccc !important;
    }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --border-color-strong: #000000;
    }
    
    .themed-card,
    .themed-container,
    .themed-input {
        border-width: 2px !important;
    }
    
    .themed-link {
        text-decoration: underline !important;
    }
}

/* === UTILITY CLASSES === */
.theme-bg-primary { background-color: var(--bg-primary) !important; }
.theme-bg-secondary { background-color: var(--bg-secondary) !important; }
.theme-bg-tertiary { background-color: var(--bg-tertiary) !important; }

.theme-text-primary { color: var(--text-primary) !important; }
.theme-text-secondary { color: var(--text-secondary) !important; }
.theme-text-tertiary { color: var(--text-tertiary) !important; }

.theme-border { border-color: var(--border-color) !important; }
.theme-border-strong { border-color: var(--border-color-strong) !important; }

.theme-shadow { box-shadow: 0 1px 3px var(--shadow) !important; }
.theme-shadow-lg { box-shadow: 0 10px 25px var(--shadow-lg) !important; }

/* === COMPONENT-SPECIFIC FIXES === */

/* Dropdown Menus */
.dropdown-themed,
.select-dropdown {
    background-color: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: 0 10px 25px var(--shadow-lg);
}

.dropdown-themed option,
.select-dropdown option {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Loading Spinners */
.spinner-themed {
    border-color: var(--border-color);
    border-top-color: var(--primary-color);
}

/* Tooltips */
.tooltip-themed {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px var(--shadow);
}

/* Progress Bars */
.progress-themed {
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.progress-bar-themed {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    transition: width var(--transition-speed) ease;
}

/* Badges */
.badge-themed {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.badge-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
}

/* Code Blocks */
.code-themed,
code:not(.no-theme),
pre:not(.no-theme) {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: calc(var(--border-radius) * 0.5);
}

/* Blockquotes */
.blockquote-themed,
blockquote:not(.no-theme) {
    border-left: 4px solid var(--primary-color);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1rem;
    margin: 1rem 0;
}

/* Horizontal Rules */
.hr-themed,
hr:not(.no-theme) {
    border-color: var(--border-color);
    background-color: var(--border-color);
}

/* === THEME-SPECIFIC ANIMATIONS === */
@keyframes theme-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.theme-fade-in {
    animation: theme-fade-in 0.3s ease-out;
}

/* === DARK MODE SPECIFIC ADJUSTMENTS === */
[data-theme="dark"] {
    /* Enhance contrast for dark mode */
    color-scheme: dark;
}

[data-theme="dark"] img {
    opacity: 0.9;
    transition: opacity var(--transition-speed) ease;
}

[data-theme="dark"] img:hover {
    opacity: 1;
}

/* === LIGHT MODE SPECIFIC ADJUSTMENTS === */
[data-theme="light"] {
    color-scheme: light;
}

/* === CUSTOM PROPERTIES FOR EXTENSIONS === */
.theme-surface-1 { background-color: var(--bg-primary); }
.theme-surface-2 { background-color: var(--bg-secondary); }
.theme-surface-3 { background-color: var(--bg-tertiary); }
.theme-surface-4 { background-color: var(--bg-quaternary); }

.theme-on-surface { color: var(--text-primary); }
.theme-on-surface-variant { color: var(--text-secondary); }

/* === DEBUGGING CLASSES (Remove in production) === */
.debug-theme {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 12px;
    z-index: 9999;
    box-shadow: 0 4px 6px var(--shadow);
} 