/**
 * ============================================================================
 * STYLES PERSONNALISÉS - LECTEUR AUDIO SYNCHRONISÉ 🎵
 * Variables CSS pour thème light/dark + styles custom
 * ============================================================================
 */

:root {
    /* Couleurs Light Mode */
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-background: #f9fafb;
    --color-surface: #ffffff;
    --color-text: #111827;
    --color-text-secondary: #6b7280;
    --color-border: #e5e7eb;
    --color-shadow: rgba(0, 0, 0, 0.1);
}

.dark {
    /* Couleurs Dark Mode */
    --color-primary: #60a5fa;
    --color-primary-hover: #3b82f6;
    --color-background: #111827;
    --color-surface: #1f2937;
    --color-text: #f9fafb;
    --color-text-secondary: #9ca3af;
    --color-border: #374151;
    --color-shadow: rgba(0, 0, 0, 0.4);
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* ============================================================================
 * RANGE INPUTS (SLIDERS)
 * Style personnalisé pour les barres de progression et volume
 * ============================================================================ */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    height: 8px;
}

/* Track - Chrome/Safari/Edge */
input[type="range"]::-webkit-slider-track {
    background: var(--color-border);
    height: 8px;
    border-radius: 4px;
}

/* Track - Firefox */
input[type="range"]::-moz-range-track {
    background: var(--color-border);
    height: 8px;
    border-radius: 4px;
}

/* Progress fill - Chrome/Safari/Edge */
input[type="range"]::-webkit-slider-runnable-track {
    background: linear-gradient(to right, var(--color-primary) 0%, var(--color-primary) var(--range-progress, 0%), var(--color-border) var(--range-progress, 0%), var(--color-border) 100%);
    height: 8px;
    border-radius: 4px;
}

/* Thumb - Chrome/Safari/Edge */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: white;
    border: 3px solid var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    margin-top: -5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

/* Thumb - Firefox */
input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: white;
    border: 3px solid var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

/* Hover effects */
input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.15);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

input[type="range"]:hover::-moz-range-thumb {
    transform: scale(1.15);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

/* Active state */
input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.05);
}

input[type="range"]:active::-moz-range-thumb {
    transform: scale(1.05);
}

/* Disabled state */
input[type="range"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input[type="range"]:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

input[type="range"]:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

/* ============================================================================
 * ANIMATIONS
 * ============================================================================ */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

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

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

/* ============================================================================
 * PLAYLIST ITEMS
 * ============================================================================ */
.playlist-item {
    transition: all 0.2s;
}

.playlist-item:hover {
    transform: translateX(4px);
}

.playlist-item.active {
    background: var(--color-primary);
    color: white;
}

.playlist-item.active .text-gray-600,
.playlist-item.active .text-gray-400 {
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================================================
 * MODAL
 * ============================================================================ */
#upload-modal.active {
    display: flex !important;
}

/* ============================================================================
 * TRANSITIONS SMOOTH
 * ============================================================================ */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

button, input[type="range"], .playlist-item {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* ============================================================================
 * UTILITIES
 * ============================================================================ */
.shadow-glow {
    box-shadow: 0 0 20px var(--color-shadow);
}

.text-gradient {
    background: linear-gradient(to right, var(--color-primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================================================
 * PLAYLIST TOGGLE
 * ============================================================================ */
#playlist-panel.hidden {
    display: none !important;
}

/* Sur mobile, la playlist est cachée par défaut */
@media (max-width: 1024px) {
    #playlist-panel {
        display: none;
    }

    #playlist-panel:not(.hidden) {
        display: flex !important;
    }

    /* Quand la playlist est ouverte sur mobile, cacher le player */
    #playlist-panel:not(.hidden) ~ #player-panel {
        display: none;
    }

    /* Alternative: Si la playlist a le focus, cacher le player */
    body.playlist-open #player-panel {
        display: none !important;
    }

    body.playlist-open #playlist-panel {
        display: flex !important;
    }
}

/* ============================================================================
 * RESPONSIVE ADJUSTMENTS
 * ============================================================================ */
@media (max-width: 1024px) {
    body {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }

    main > div {
        flex-direction: column;
    }

    #artwork-container {
        width: 180px !important;
        height: 180px !important;
    }
}

@media (max-width: 640px) {
    header .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    /* Masquer le texte du titre sur mobile, garder juste l'icône */
    #site-title {
        font-size: 0 !important;
    }

    #site-title i {
        width: 1.5rem;
        height: 1.5rem;
    }

    #artwork-container {
        width: 150px !important;
        height: 150px !important;
    }

    #track-title {
        font-size: 1.125rem;
    }

    button {
        padding: 0.5rem;
    }
}

/* ============================================================================
 * FILE INPUT STYLING
 * ============================================================================ */
input[type="file"] {
    font-size: 14px;
}

input[type="file"]::file-selector-button {
    padding: 8px 16px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 12px;
    font-size: 14px;
}

input[type="file"]::file-selector-button:hover {
    background: var(--color-primary-hover);
}

.dark input[type="file"]::file-selector-button {
    background: var(--color-primary);
}

.dark input[type="file"]::file-selector-button:hover {
    background: var(--color-primary-hover);
}

/* ============================================================================
 * LOADING STATES
 * ============================================================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-border) 25%,
        var(--color-surface) 50%,
        var(--color-border) 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
