/**
 * Système de thèmes avancé avec animations fluides
 * Support complet pour thèmes clair/sombre avec transitions élégantes
 * Optimisé pour l'accessibilité et les performances
 */

/* ==========================================================================
   VARIABLES CSS POUR LES THÈMES
   ========================================================================== */

:root {
    /* Thème clair (par défaut) */
    --primary-color: #2c3e50;
    --primary-light: #3498db;
    --primary-dark: #1a252f;
    --secondary-color: #e74c3c;
    --accent-color: #f39c12;
    --success-color: #27ae60;
    --warning-color: #f1c40f;
    --danger-color: #e74c3c;
    
    /* Arrière-plans */
    --background-primary: #ffffff;
    --background-secondary: #f8f9fa;
    --background-tertiary: #e9ecef;
    --background-card: #ffffff;
    --background-overlay: rgba(0, 0, 0, 0.1);
    --background-modal: rgba(0, 0, 0, 0.5);
    
    /* Textes */
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --text-inverse: #ffffff;
    --text-link: #3498db;
    --text-link-hover: #2980b9;
    
    /* Bordures et séparateurs */
    --border-color: #dee2e6;
    --border-light: #e9ecef;
    --border-dark: #adb5bd;
    --divider-color: #e9ecef;
    
    /* Ombres */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 2rem rgba(0, 0, 0, 0.175);
    --shadow-xl: 0 2rem 4rem rgba(0, 0, 0, 0.2);
    --shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.075);
    
    /* Dégradés */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    
    /* Animations */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --animation-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Rayons de bordure */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 50%;
}

/* Thème sombre */
[data-theme="dark"] {
    /* Couleurs principales adaptées */
    --primary-color: #3498db;
    --primary-light: #5dade2;
    --primary-dark: #2980b9;
    --secondary-color: #e74c3c;
    --accent-color: #f39c12;
    --success-color: #2ecc71;
    --warning-color: #f1c40f;
    --danger-color: #e74c3c;
    
    /* Arrière-plans sombres */
    --background-primary: #1a1a1a;
    --background-secondary: #2d2d2d;
    --background-tertiary: #404040;
    --background-card: #2d2d2d;
    --background-overlay: rgba(255, 255, 255, 0.1);
    --background-modal: rgba(0, 0, 0, 0.8);
    
    /* Textes adaptés au sombre */
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --text-muted: #6c757d;
    --text-inverse: #1a1a1a;
    --text-link: #5dade2;
    --text-link-hover: #3498db;
    
    /* Bordures sombres */
    --border-color: #404040;
    --border-light: #2d2d2d;
    --border-dark: #6c757d;
    --divider-color: #404040;
    
    /* Ombres adaptées */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 1rem 2rem rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 2rem 4rem rgba(0, 0, 0, 0.6);
    --shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.3);
    
    /* Dégradés sombres */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* ==========================================================================
   BOUTON DE BASCULEMENT DE THÈME - VERSION ULTRA-MODERNE
   ========================================================================== */

.theme-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 4rem;
    height: 4rem;
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(145deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    color: var(--text-inverse);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 
        0 8px 32px rgba(102, 126, 234, 0.4),
        0 4px 16px rgba(118, 75, 162, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: scale(1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

/* Effet de brillance qui se déplace */
.theme-toggle::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.theme-toggle:hover::before {
    animation: shine 0.6s ease-in-out;
}

@keyframes shine {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
        opacity: 0;
    }
}

.theme-toggle:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 
        0 12px 48px rgba(102, 126, 234, 0.6),
        0 8px 24px rgba(118, 75, 162, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    background: linear-gradient(145deg, #f093fb 0%, #f5576c 50%, #4facfe 100%);
}

.theme-toggle:active {
    transform: scale(1.05) rotate(2deg);
    transition: transform 0.15s ease;
}

.theme-toggle:focus {
    outline: none;
    box-shadow: 
        0 12px 48px rgba(102, 126, 234, 0.6),
        0 8px 24px rgba(118, 75, 162, 0.4),
        0 0 0 4px rgba(102, 126, 234, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.theme-toggle:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 4px;
}

/* Icônes du bouton avec animations fluides */
.theme-toggle .theme-icon {
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: block;
    position: absolute;
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.theme-toggle .theme-icon.hidden {
    opacity: 0;
    transform: rotate(180deg) scale(0.3);
    filter: blur(4px);
}

.theme-toggle .theme-icon:not(.hidden) {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    filter: blur(0px);
}

/* Animation de pulsation améliorée */
@keyframes pulse-theme-advanced {
    0%, 100% {
        transform: scale(1);
        box-shadow: 
            0 8px 32px rgba(102, 126, 234, 0.4),
            0 4px 16px rgba(118, 75, 162, 0.3);
    }
    25% {
        transform: scale(1.05);
        box-shadow: 
            0 12px 40px rgba(102, 126, 234, 0.5),
            0 6px 20px rgba(118, 75, 162, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 
            0 16px 48px rgba(102, 126, 234, 0.6),
            0 8px 24px rgba(118, 75, 162, 0.5);
    }
    75% {
        transform: scale(1.05);
        box-shadow: 
            0 12px 40px rgba(102, 126, 234, 0.5),
            0 6px 20px rgba(118, 75, 162, 0.4);
    }
}

.theme-toggle.pulse {
    animation: pulse-theme-advanced 3s infinite ease-in-out;
}

/* Effet de particules flottantes autour du bouton */
.theme-toggle::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent);
    border-radius: 50%;
    top: 10%;
    right: 15%;
    animation: float-particle 4s infinite ease-in-out;
    opacity: 0.7;
}

@keyframes float-particle {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.7;
    }
    25% {
        transform: translateY(-8px) rotate(90deg);
        opacity: 1;
    }
    50% {
        transform: translateY(-4px) rotate(180deg);
        opacity: 0.5;
    }
    75% {
        transform: translateY(-12px) rotate(270deg);
        opacity: 0.8;
    }
}

/* Style spécial pour le thème sombre */
[data-theme="dark"] .theme-toggle {
    background: linear-gradient(145deg, #2d3748 0%, #4a5568 50%, #667eea 100%);
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 8px 32px rgba(45, 55, 72, 0.6),
        0 4px 16px rgba(74, 85, 104, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .theme-toggle:hover {
    background: linear-gradient(145deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    box-shadow: 
        0 12px 48px rgba(102, 126, 234, 0.4),
        0 8px 24px rgba(118, 75, 162, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Tooltip informatif */
.theme-toggle[title]:hover::before {
    content: attr(title);
    position: absolute;
    bottom: 120%;
    right: 50%;
    transform: translateX(50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1001;
    opacity: 0;
    animation: tooltip-appear 0.3s ease forwards;
}

@keyframes tooltip-appear {
    from {
        opacity: 0;
        transform: translateX(50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(50%) translateY(0);
    }
}

/* Adaptation mobile améliorée */
@media (max-width: 768px) {
    .theme-toggle {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 3.5rem;
        height: 3.5rem;
        font-size: 1.25rem;
    }
}

/* Version compacte pour très petits écrans */
@media (max-width: 480px) {
    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 3rem;
        height: 3rem;
        font-size: 1rem;
    }
}

/* ==========================================================================
   TRANSITIONS GLOBALES
   ========================================================================== */

/* Transition fluide pour tous les éléments lors du changement de thème */
*,
*::before,
*::after {
    transition: 
        background-color var(--transition-normal),
        border-color var(--transition-normal),
        color var(--transition-normal),
        box-shadow var(--transition-normal),
        opacity var(--transition-normal);
}

/* Exceptions pour les éléments qui ne doivent pas avoir de transition */
.no-transition,
.no-transition *,
img,
video,
iframe,
canvas,
svg {
    transition: none !important;
}

/* ==========================================================================
   AMÉLIORATIONS VISUELLES GÉNÉRALES
   ========================================================================== */

/* Corps de la page */
body {
    background-color: var(--background-primary);
    color: var(--text-primary);
    transition: all var(--transition-normal);
}

/* Cartes et conteneurs */
.card,
.project-card,
.skill-category,
.timeline-item .card {
    background-color: var(--background-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.card:hover,
.project-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* En-têtes et titres */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
}

/* Liens */
a {
    color: var(--text-link);
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--text-link-hover);
}

/* Boutons */
.btn {
    transition: all var(--transition-normal);
    border-radius: var(--radius-md);
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
    color: var(--text-inverse);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--gradient-secondary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
}

/* Formulaires */
input,
textarea,
select {
    background-color: var(--background-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Navigation et header */
.header,
.navbar {
    background-color: var(--background-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* Footer */
.footer {
    background-color: var(--background-secondary);
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   EFFETS SPÉCIAUX ET ANIMATIONS
   ========================================================================== */

/* Animation de changement de thème */
@keyframes theme-switch {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 1;
    }
}

.theme-switching {
    animation: theme-switch 0.3s ease;
}

/* Effet de survol pour les éléments interactifs */
.interactive-hover {
    transition: all var(--transition-normal);
}

.interactive-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Effet de focus amélioré */
.focus-enhanced:focus {
    outline: none;
    box-shadow: 
        var(--shadow-md),
        0 0 0 3px rgba(52, 152, 219, 0.3);
    transform: scale(1.02);
}

/* Dégradé de texte pour les titres importants */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: bold;
}

/* ==========================================================================
   RESPONSIVE ET ACCESSIBILITÉ
   ========================================================================== */

/* Adaptation mobile */
@media (max-width: 768px) {
    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 3rem;
        height: 3rem;
        font-size: 1rem;
    }
}

/* Préférence pour mouvement réduit */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .theme-toggle:hover {
        transform: none;
    }
    
    .theme-toggle.pulse {
        animation: none;
    }
}

/* Contraste élevé */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-primary: #000000;
        --background-primary: #ffffff;
    }
    
    [data-theme="dark"] {
        --border-color: #ffffff;
        --text-primary: #ffffff;
        --background-primary: #000000;
    }
}

/* Mode sombre automatique selon les préférences système */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --primary-color: #3498db;
        --background-primary: #1a1a1a;
        --background-secondary: #2d2d2d;
        --background-card: #2d2d2d;
        --text-primary: #f8f9fa;
        --text-secondary: #adb5bd;
        --border-color: #404040;
    }
}

/* ==========================================================================
   UTILITAIRES ET CLASSES D'AIDE
   ========================================================================== */

/* Classes utilitaires pour les thèmes */
.theme-bg-primary { background-color: var(--background-primary); }
.theme-bg-secondary { background-color: var(--background-secondary); }
.theme-bg-card { background-color: var(--background-card); }

.theme-text-primary { color: var(--text-primary); }
.theme-text-secondary { color: var(--text-secondary); }
.theme-text-muted { color: var(--text-muted); }

.theme-border { border-color: var(--border-color); }
.theme-shadow-sm { box-shadow: var(--shadow-sm); }
.theme-shadow-md { box-shadow: var(--shadow-md); }

/* Indicateur de thème actuel (pour débogage) */
.theme-indicator {
    position: fixed;
    top: 1rem;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--background-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    opacity: 0.7;
    z-index: 999;
    display: none; /* Masqué par défaut */
}

/* Affichage conditionnel pour le développement */
.debug .theme-indicator {
    display: block;
}

/* ==========================================================================
   ANIMATIONS AVANCÉES
   ========================================================================== */

/* Animation d'apparition fluide */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s var(--animation-bounce);
}

/* Animation de rotation pour les icônes */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-rotate {
    animation: rotate 2s linear infinite;
}

/* Animation de battement de cœur pour les éléments favoris */
@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.animate-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

/* ==========================================================================
   PRINT STYLES (pour l'impression)
   ========================================================================== */

@media print {
    .theme-toggle {
        display: none !important;
    }
    
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
} 