/**
 * KILOTRACKR - THEME.CSS (VERSION ADMIN)
 * Design moderne Tesla-like avec mode clair par défaut
 * 
 * Structure :
 * 1. Variables CSS (light + dark)
 * 2. Reset & Base
 * 3. Typographie
 * 4. Composants (cards, boutons, formulaires, etc.)
 * 5. Utilitaires
 */

/* ========================================
   1. VARIABLES CSS - MODE CLAIR (DÉFAUT)
   ======================================== */

:root,
[data-theme="light"] {
    /* === COULEURS PRINCIPALES === */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --primary-hover: #1d4ed8;
    
    /* === COULEURS SECONDAIRES === */
    --secondary: #10b981;
    --secondary-hover: #059669;
    
    /* === COULEURS STATUT === */
    --success: #10b981;
    --success-hover: #059669;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --info: #06b6d4;
    --info-hover: #0891b2;

    /* === COULEURS DE MARQUE : valeurs RVB, pour rgba(var(--primary-rgb), 0.1) ===
       Ces variables (et --accent) servent aux thèmes saisonniers : pour recolorer le site,
       il suffit de redéfinir --primary, --primary-rgb, --accent, etc. */
    --accent: #6366f1;
    --primary-rgb: 59, 130, 246;
    --success-rgb: 16, 185, 129;
    --warning-rgb: 245, 158, 11;
    --danger-rgb: 239, 68, 68;
    --info-rgb: 6, 182, 212;
    --accent-rgb: 99, 102, 241;
    
    /* === ÉCHELLE DE GRIS === */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* === COULEURS SÉMANTIQUES === */
    --bg-body: #f9fafb;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-input-focus: #ffffff;
    --bg-hover: #f3f4f6;
    
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-placeholder: #9ca3af;
    --text-inverse: #ffffff;
    
    --border-color: #e5e7eb;
    --border-color-focus: #3b82f6;
    --border-color-hover: #d1d5db;
    
    /* === OMBRES === */
    --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);
    
    /* === SPACING === */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* === BORDURES === */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    /* === TRANSITIONS === */
    --transition: all 0.2s ease;
    --transition-fast: all 0.15s ease;
    --transition-slow: all 0.3s ease;
}

/* ========================================
   MODE SOMBRE (OPTIONNEL)
   ======================================== */

html[data-theme="dark"],
body[data-theme="dark"],
[data-theme="dark"] {
    /* === COULEURS PRINCIPALES (identiques) === */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --primary-hover: #60a5fa;
    
    --secondary: #10b981;
    --secondary-hover: #34d399;
    
    /* === COULEURS STATUT (identiques) === */
    --success: #10b981;
    --success-hover: #34d399;
    --warning: #f59e0b;
    --warning-hover: #fbbf24;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --info: #06b6d4;
    --info-hover: #22d3ee;
    
    /* === ÉCHELLE DE GRIS (inversée) === */
    --gray-50: #111827;
    --gray-100: #1f2937;
    --gray-200: #374151;
    --gray-300: #4b5563;
    --gray-400: #6b7280;
    --gray-500: #9ca3af;
    --gray-600: #d1d5db;
    --gray-700: #e5e7eb;
    --gray-800: #f3f4f6;
    --gray-900: #f9fafb;
    
    /* === COULEURS SÉMANTIQUES === */
    --bg-body: #0f1419;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-input-focus: rgba(255, 255, 255, 0.08);
    --bg-hover: rgba(255, 255, 255, 0.1);
    
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --text-placeholder: #6b7280;
    --text-inverse: #111827;
    
    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-focus: #3b82f6;
    --border-color-hover: rgba(255, 255, 255, 0.2);
    
    /* === OMBRES (plus subtiles) === */
    --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.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
}

/* ========================================
   2. RESET & BASE
   ======================================== */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-body);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========================================
   3. TYPOGRAPHIE
   ======================================== */

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-md);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

strong {
    font-weight: 600;
    color: var(--text-primary);
}

small {
    font-size: 0.875em;
    color: var(--text-muted);
}

/* ========================================
   4. COMPOSANTS
   ======================================== */

/* === CARDS === */
.card,
.dashboard-card,
.profile-card,
.settings-section,
.car-card,
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover,
.dashboard-card:hover,
.profile-card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.card-body {
    color: var(--text-secondary);
}

.card-footer {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

/* === BOUTONS === */
.btn,
button[type="submit"],
button[type="button"],
.user-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.625rem 1.25rem;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-family: inherit;
}

/* Bouton primaire */
.btn-primary,
.user-button {
    background: var(--primary);
    color: white;
}

.btn-primary:hover,
.user-button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Bouton secondaire */
.btn-secondary {
    background: var(--gray-100);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

html[data-theme="dark"] .btn-secondary, body[data-theme="dark"] .btn-secondary, [data-theme="dark"] .btn-secondary {
    background: rgba(255, 255, 255, 0.05);
}

.btn-secondary:hover {
    background: var(--gray-200);
    border-color: var(--border-color-hover);
}

html[data-theme="dark"] .btn-secondary:hover, body[data-theme="dark"] .btn-secondary:hover, [data-theme="dark"] .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Bouton danger */
.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Bouton success */
.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Boutons désactivés */
button:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* === FORMULAIRES === */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
textarea,
select,
.user-input,
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-placeholder);
}

input:focus,
textarea:focus,
select:focus,
.user-input:focus,
.form-control:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

input:disabled,
textarea:disabled,
select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Select natif */
select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

html[data-theme="dark"] select, body[data-theme="dark"] select, [data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

/* === MESSAGES D'ALERTE === */
.alert,
.message,
.user-message,
.message-box {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 14px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success,
.message.success,
.user-message.success,
.message-box.success-message {
    background: rgba(var(--success-rgb), 0.1);
    border: 1px solid rgba(var(--success-rgb), 0.3);
    color: var(--success);
}

.alert-error,
.message.error,
.user-message.error,
.message-box.error-message {
    background: rgba(var(--danger-rgb), 0.1);
    border: 1px solid rgba(var(--danger-rgb), 0.3);
    color: var(--danger);
}

.alert-warning {
    background: rgba(var(--warning-rgb), 0.1);
    border: 1px solid rgba(var(--warning-rgb), 0.3);
    color: var(--warning);
}

.alert-info {
    background: rgba(var(--info-rgb), 0.1);
    border: 1px solid rgba(var(--info-rgb), 0.3);
    color: var(--info);
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.25rem 0.75rem;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-success {
    background: rgba(var(--success-rgb), 0.1);
    color: var(--success);
}

.badge-danger,
.badge-error {
    background: rgba(var(--danger-rgb), 0.1);
    color: var(--danger);
}

.badge-warning {
    background: rgba(var(--warning-rgb), 0.1);
    color: var(--warning);
}

.badge-info {
    background: rgba(var(--info-rgb), 0.1);
    color: var(--info);
}

.badge-primary {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

/* === TABLES === */
.data-table,
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead tr {
    border-bottom: 2px solid var(--border-color);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--gray-50);
}

html[data-theme="dark"] .data-table th, body[data-theme="dark"] .data-table th, [data-theme="dark"] .data-table th {
    background: rgba(255, 255, 255, 0.02);
}

.data-table td {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.data-table tr:hover {
    background: var(--bg-hover);
}

/* ========================================
   5. UTILITAIRES
   ======================================== */

.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }

.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.hidden { display: none !important; }
.visible { display: block !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-sm { margin-bottom: var(--space-sm) !important; }
.mb-md { margin-bottom: var(--space-md) !important; }
.mb-lg { margin-bottom: var(--space-lg) !important; }
.mb-xl { margin-bottom: var(--space-xl) !important; }

.mt-0 { margin-top: 0 !important; }
.mt-sm { margin-top: var(--space-sm) !important; }
.mt-md { margin-top: var(--space-md) !important; }
.mt-lg { margin-top: var(--space-lg) !important; }
.mt-xl { margin-top: var(--space-xl) !important; }

/* ========================================
   6. TRANSITIONS DOUCES
   ======================================== */

body,
.card,
.btn,
input,
textarea,
select {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

/* ===== Animations partagées (une seule définition, utilisée par toutes les pages) ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}
