/* Reset et variables */
:root {
    --primary: #1db954;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --success: #2ecc71;
    --secondary: #95a5a6;
    --dark: #191414;
    --light: #ffffff;
    --gray: #b3b3b3;
    --bg: #121212;
    --card-bg: #1e1e1e;
    --border: #282828;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--light);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    padding: 12px 20px;
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary);
    opacity: 0.8;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Admin Badge */
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-badge:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.2);
    padding: 12px 24px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray);
    animation: pulse 2s infinite;
}

.status-dot.active {
    background: var(--success);
}

.status-dot.error {
    background: var(--danger);
}

.status-dot.syncing {
    background: var(--warning);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text {
    font-weight: 600;
    font-size: 1.1rem;
}

/* Dashboard Grid */
.dashboard {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary);
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
    padding: 3px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #1aa34a);
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Info Banner */
.info-banner {
    background: linear-gradient(135deg, rgba(29, 185, 84, 0.2), rgba(26, 163, 74, 0.2));
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    text-align: center;
    font-weight: 600;
    color: var(--primary);
    animation: fadeIn 0.5s ease;
}

/* Spotify Play Button Style */
.spotify-play-button {
    background-color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
}

.spotify-play-button svg {
    width: 24px;
    height: 24px;
    fill: #000;
    transition: transform 0.1s ease;
}

.spotify-play-button:hover {
    background-color: #1fdf64;
    transform: scale(1.06);
}

.spotify-play-button:active {
    transform: scale(1);
}

.spotify-play-button:active svg {
    transform: scale(0.92);
}

/* Variante plus large pour le lecteur */
.spotify-play-button-large {
    width: 56px;
    height: 56px;
}

.spotify-play-button-large svg {
    width: 28px;
    height: 28px;
}

/* Radio Player Compact */
.radio-player-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--bg);
    border-radius: 8px;
    border: none;
    transition: all 0.3s ease;
}

.radio-player-compact:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.radio-player-compact .spotify-play-button {
    width: 32px;
    height: 32px;
}

.radio-player-compact .spotify-play-button svg {
    width: 16px;
    height: 16px;
}

.radio-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.radio-volume-compact {
    flex: 1;
    max-width: 100px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Controls Grid */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Buttons */
.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-secondary { background: var(--secondary); color: white; }

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Grid Layout */
.stats-card {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
}

.controls-card:not(:has(#spotify-embed-container)) {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

/* Playlist Container */
.playlist-card {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
}

.controls-card:has(#spotify-embed-container) {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    display: flex;
    flex-direction: column;
}

.controls-card:has(#spotify-embed-container) #spotify-embed-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.controls-card:has(#spotify-embed-container) #spotify-embed-container iframe {
    flex: 1;
    height: 100% !important;
    min-height: 600px;
}

.playlist-container {
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.playlist-item {
    display: grid;
    grid-template-columns: 40px 30px 50px 80px 1fr 100px;
    gap: 12px;
    padding: 16px;
    margin-bottom: 8px;
    background: var(--card-bg);
    border-radius: 8px;
    border-left: 4px solid var(--border);
    transition: all 0.2s;
    cursor: move;
}

.playlist-item:hover {
    transform: translateX(4px);
    border-left-color: var(--primary);
}

.playlist-item.dragging {
    opacity: 0.5;
    transform: scale(1.05);
    box-shadow: 0 12px 24px rgba(29, 185, 84, 0.4);
    border: 2px solid var(--primary);
    z-index: 1000;
}

/* Désactiver les pointer events sur les enfants pour faciliter le drop */
.playlist-item > * {
    pointer-events: none;
}

/* Réactiver les pointer events sur les boutons pour qu'ils restent cliquables */
.playlist-item .btn-action {
    pointer-events: auto;
}

.playlist-item.drag-over {
    border: 3px dashed var(--primary);
    background: linear-gradient(90deg, rgba(29, 185, 84, 0.2), transparent);
    transform: scale(1.02);
    margin: 12px 0;
}

.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: grab;
    user-select: none;
    opacity: 0.7;
    transition: all 0.2s;
    padding: 4px;
    border-radius: 4px;
}

.drag-handle:hover {
    opacity: 1;
    color: var(--primary);
    background: rgba(29, 185, 84, 0.1);
    transform: scale(1.2);
}

.playlist-item:active .drag-handle {
    cursor: grabbing;
}

.playlist-item:hover .drag-handle {
    opacity: 1;
}

.playlist-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-action {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.1);
}

/* Bouton Play avec SVG */
.btn-action-play {
    background: #ffffff;
    border: 1px solid #ffffff;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-action-play svg {
    width: 18px;
    height: 18px;
    fill: #000;
}

.btn-action-play:hover {
    background: #1fdf64;
    border-color: #1fdf64;
}

.btn-select {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.playlist-item.playing {
    border-left-color: var(--primary);
    background: linear-gradient(90deg, rgba(29, 185, 84, 0.1), transparent);
    animation: playingPulse 2s infinite;
}

@keyframes playingPulse {
    0%, 100% { background: linear-gradient(90deg, rgba(29, 185, 84, 0.1), transparent); }
    50% { background: linear-gradient(90deg, rgba(29, 185, 84, 0.2), transparent); }
}

.playlist-item.passed {
    opacity: 0.5;
    border-left-color: var(--gray);
}

.playlist-item.upcoming {
    border-left-color: var(--info);
}

.playlist-number {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--primary);
    background: rgba(29, 185, 84, 0.1);
    border-radius: 6px;
    min-width: 40px;
}

.playlist-time {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.1rem;
}

.playlist-track {
    color: var(--light);
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.playlist-track .xml-version {
    color: var(--light);
    font-weight: 500;
}

.playlist-track .spotify-version {
    color: var(--primary);
    font-size: 0.85rem;
    font-style: italic;
    opacity: 0.9;
    padding-left: 8px;
    border-left: 2px solid var(--primary);
}

.playlist-album-art {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}

.playlist-album-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.playlist-album-art.no-image {
    font-size: 1.5rem;
    color: var(--gray);
}

.track-duration {
    font-size: 0.75rem;
    color: var(--gray);
    margin-top: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.duration-xml {
    color: var(--light);
}

.duration-spotify {
    color: var(--primary);
}

.track-duration.duration-mismatch {
    color: var(--warning);
    font-weight: 600;
}

.track-duration.duration-mismatch::before {
    content: '⚠️ ';
    font-size: 0.8rem;
}

/* Logs */
.logs-card {
    grid-column: 1 / -1;
    grid-row: 3 / 4;
}

.logs-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px;
    background: var(--bg);
    border-radius: 8px;
}

.logs-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
}

.log-entry {
    display: grid;
    grid-template-columns: 80px 30px 1fr;
    gap: 12px;
    padding: 8px;
    margin-bottom: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.log-entry:hover {
    background: var(--card-bg);
}

.log-time {
    color: var(--gray);
    font-size: 0.85rem;
}

.log-icon {
    font-size: 1rem;
}

.log-message {
    color: var(--light);
}

.log-info { border-left: 3px solid var(--info); }
.log-success { border-left: 3px solid var(--success); }
.log-warning { border-left: 3px solid var(--warning); }
.log-error { border-left: 3px solid var(--danger); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

/* Modal Choisir une Version - Z-index plus élevé pour s'afficher au-dessus du modal Admin */
#version-modal {
    z-index: 1100;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    padding: 32px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 800px;
}

.modal-xlarge {
    width: calc(100vw - 40px);
    height: calc(100vh - 40px);
    max-width: none;
    max-height: none;
    margin: 20px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    position: absolute;
    right: 6px;
    top: -14px;
    font-size: 2rem;
    font-weight: bold;
    color: var(--gray);
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: var(--light);
}

/* Version Selection */
.version-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
}

.version-item:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.version-album-art {
    width: 64px;
    height: 64px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.version-album-art.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    font-size: 2rem;
    color: var(--gray);
}

.version-info {
    flex: 1;
}

.version-name {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--light);
}

.version-details {
    font-size: 0.9rem;
    color: var(--gray);
}

.version-popularity {
    display: inline-block;
    margin-left: 12px;
    padding: 4px 8px;
    background: rgba(29, 185, 84, 0.2);
    border-radius: 4px;
    color: var(--primary);
    font-weight: 600;
}

.version-actions {
    display: flex;
    gap: 8px;
}

.no-results, .error {
    text-align: center;
    padding: 40px;
    color: var(--gray);
}

/* Spotify Player */
.spotify-player {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 400px;
    background: var(--card-bg);
    border: 2px solid var(--primary);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
}

.spotify-player.active {
    display: block;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary), #1aa34a);
    border-radius: 10px 10px 0 0;
}

.player-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.btn-close-player {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-player:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.player-body {
    padding: 16px;
}

.player-info {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.player-album-art {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
}

.player-album-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.player-track-name {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: var(--light);
}

.player-artist-name {
    color: var(--gray);
    font-size: 0.9rem;
}

.player-progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    margin-bottom: 12px;
}

.player-time {
    font-size: 0.85rem;
    color: var(--gray);
    min-width: 40px;
    text-align: center;
}

.progress-bar {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.progress-bar::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(29, 185, 84, 0.6);
}

.progress-bar::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.progress-bar::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(29, 185, 84, 0.6);
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.btn-player {
    background: var(--primary);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-player:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(29, 185, 84, 0.5);
}

.player-volume {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.player-volume input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
}

.player-volume input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.player-volume input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray);
    font-style: italic;
}

/* Unfound Tracks */
.unfound-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--card-bg);
    border-radius: 8px;
    border-left: 4px solid var(--danger);
}

.unfound-info {
    flex: 1;
}

.unfound-time {
    color: var(--danger);
    font-weight: 700;
    margin-bottom: 4px;
}

.unfound-track {
    color: var(--light);
}

.unfound-actions {
    margin-left: 16px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--danger);
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    margin-left: 8px;
}

/* Responsive */
@media (max-width: 1200px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .stats-card,
    .controls-card,
    .playlist-card,
    .logs-card {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }

    .controls-card:has(#spotify-embed-container) #spotify-embed-container iframe {
        min-height: 400px;
    }
}

/* Compte à rebours */
.stat-highlight {
    background: linear-gradient(135deg, var(--bg) 0%, rgba(255, 107, 107, 0.1) 100%);
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.countdown-value {
    color: #ff6b6b !important;
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .playlist-item {
        grid-template-columns: 30px 40px 60px 1fr 80px;
        font-size: 0.85rem;
        gap: 8px;
        padding: 12px;
    }

    .playlist-album-art {
        width: 40px;
        height: 40px;
    }

    .drag-handle {
        font-size: 1.2rem;
    }
}
