/* Marseille Tracker - Styles responsive */

/* Responsive pour mobile */
@media (max-width: 768px) {

    /* Header mobile fixe */
    .mobile-header {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 2000;
        background: rgba(15, 23, 42, 0.98);
        /* Plus opaque pour éviter l'effet grisâtre */
        backdrop-filter: blur(16px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        /* Bordure nette */
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
        /* Ombre plus marquée */
        padding: 6px 12px;
        /* Plus compact */
        min-height: 48px;
        /* Hauteur réduite standard */
    }

    .mobile-header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        max-width: 100%;
        gap: 8px;
    }

    .mobile-title {
        flex: 1 1 auto;
    }

    .mobile-title h1 {
        font-size: 24px !important;
        font-weight: 700 !important;
        margin: 0;
        color: #f1f5f9;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        line-height: 1.1;
        display: flex;
        align-items: center;
        gap: 10px;
        justify-content: flex-start;
        width: 100%;
    }

    .mobile-title .title-text {
        flex: 1 1 auto;
    }

    .mobile-title .title-logos {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        margin-left: auto;
    }

    .mobile-title .marseillegrand-logo {
        height: 36px;
        width: auto;
        display: block;
        padding: 3px;
        background: rgba(255, 255, 255, 0.72);
        border-radius: 999px;
    }

    .mobile-title .elysee-logo {
        height: 24px;
        width: auto;
    }

    .mobile-title .subtitle {
        display: none;
    }

    .mobile-stats {
        display: flex;
        flex-shrink: 0;
        gap: 8px;
    }

    .mobile-stat {
        text-align: center;
        background: radial-gradient(circle at top, rgba(51, 65, 85, 0.6) 0%, rgba(30, 41, 59, 0.8) 100%);
        backdrop-filter: blur(10px);
        border-radius: 6px;
        /* Réduit de 8px */
        padding: 6px 10px;
        /* Réduit de 8px 12px */
        border: 1px solid rgba(148, 163, 184, 0.2);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
        min-width: 50px;
        /* Réduit de 60px */
    }

    .mobile-stat .number {
        font-size: 14px;
        /* Réduit de 16px */
        font-weight: 300;
        color: #93c5fd;
        margin-bottom: 1px;
        /* Réduit de 2px */
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        line-height: 1;
    }

    .mobile-stat .label {
        font-size: 8px;
        /* Réduit de 9px */
        color: #94a3b8;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        /* Réduit de 0.5px */
        line-height: 1;
    }

    .container {
        flex-direction: column;
        height: 100vh;
        position: relative;
        overflow: hidden;
        padding-top: 48px;
        /* Correspond à la nouvelle hauteur du header */
    }

    .map-panel {
        height: 100vh;
        flex-shrink: 0;
        box-shadow: none;
        position: relative;
        z-index: 1;
    }

    .info-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: auto !important;
        height: calc(100vh - 48px);
        /* Ajusté */
        transform: translateY(8vh);
        /* Position plus haute pour exposer le haut (photo) */
        padding: 0;
        padding-bottom: 0;
        /* On gère le padding dans le content pour le fond */
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
        overflow-y: auto;
        overflow-x: hidden;
        display: flex;
        flex-direction: column;
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(20px);
        border-radius: 20px 20px 0 0;
        border: none;
        /* Supprime le fin séparateur horizontal en haut du panneau */
        z-index: 1000;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .resize-handle {
        display: none;
    }

    .info-panel.expanded {
        transform: translateY(8vh);
        /* Position plus haute */
    }

    .info-panel.full {
        transform: translateY(6vh);
        /* Laisser la poignée visible et ne pas couvrir le header */
        border-radius: 12px 12px 0 0;
    }

    .info-panel.minimized {
        transform: translateY(75vh);
        /* Ajusté pour plus d'espace */
    }

    .info-panel.partial {
        transform: translateY(65vh);
        /* Ajusté pour plus d'espace */
    }

    .drag-area {
        display: block;
        padding: 12px 15px;
        cursor: grab;
        flex-shrink: 0;
        user-select: none;
        position: sticky;
        top: 0;
        z-index: 1200;
        /* Z-index modéré pour ne pas couper les cartes */
        background: rgba(15, 23, 42, 0.98);
        touch-action: none;
        /* Empêcher les gestes par défaut du navigateur */
        -webkit-touch-callout: none;
        /* Empêcher le menu contextuel sur iOS */
    }

    .drag-area:active {
        cursor: grabbing;
    }

    .drag-handle {
        display: block;
        width: 50px;
        height: 5px;
        background: #ccc;
        border-radius: 3px;
        margin: 0 auto;
        pointer-events: none;
        /* Laisser les événements passer au parent */
        transition: background-color 0.2s ease;
    }

    .info-panel-content {
        flex: 1;
        overflow: visible;
        /* "Mou" important pour le scroll iOS et fond opaque pour couvrir la carte */
        padding: 8px 20px 200px !important;
        display: flex;
        flex-direction: column;
        background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(15, 23, 42, 1) 100%);
        /* Fond opaque garanti en bas */
        min-height: 100%;
    }

    .info-panel-header {
        display: none;
        /* Masqué sur mobile car le titre est maintenant dans le header fixe */
    }

    .desktop-stats {
        display: none;
        /* Masqué sur mobile */
    }

    .info-panel-header:active {
        cursor: grabbing;
    }

    .info-panel-header::after {
        content: '⋮⋮';
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        color: #ccc;
        font-size: 16px;
        letter-spacing: -2px;
        opacity: 0.6;
        pointer-events: none;
    }

    /* Graphiques récap - mobile */
    .guided-chart-body {
        padding: 0 10px;
    }

    .guided-chart-bars {
        padding: 0 58px 0 26px;
        gap: 3px;
        grid-auto-columns: minmax(14px, 1fr);
    }

    .guided-chart-axis {
        padding: 0 58px 0 26px;
        gap: 3px;
        grid-auto-columns: minmax(14px, 1fr);
    }

    .guided-chart {
        overflow: hidden;
    }

    .info-panel h1 {
        font-size: 20px;
        margin-bottom: 2px;
        line-height: 1.1;
    }

    .info-panel .subtitle {
        font-size: 11px;
        margin-bottom: 0;
        line-height: 1.2;
    }

    .stats-container {
        display: none;
        /* Masqué sur mobile car les stats sont maintenant dans le header fixe */
    }

    .stat-card {
        border-radius: 6px;
        padding: 8px 12px;
        flex: 1;
        min-width: 0;
    }

    .stat-card .number {
        font-size: 16px;
        margin-bottom: 2px;
    }

    .stat-card .label {
        font-size: 9px;
        line-height: 1.1;
    }

    #projectCards {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
        overflow: visible;
        /* Pas de scroll imbriqué, laissons le parent gérer */
        padding-top: 15px;
        /* Plus d'espace pour le halo de la première carte */
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        /* Espace adaptatif pour le bas de liste */
        flex: 1;
        min-height: 0;
        grid-template-columns: none !important;
    }

    /* Ajoute un espace de fin suffisant en mode guidé pour ne jamais tronquer la dernière carte */
    body.guided-mode #projectCards::after {
        content: '';
        display: block;
        height: 32vh;
    }

    .project-card {
        width: 100%;
        max-width: none;
        min-width: 0;
        /* Supprimer le min-width pour éviter le débordement horizontal */
        flex-shrink: 0;
        padding: 12px;
        margin-bottom: 0;
        height: fit-content;
        position: relative;
        box-sizing: border-box;
        /* S'assurer que le padding est inclus dans la largeur */
    }

    .project-card.selected {
        border: 2px solid #1976d2;
        box-shadow: 0 2px 12px rgba(25, 118, 210, 0.2);
        transform: translateY(-1px);
    }

    .project-card:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transform: translateY(-1px);
    }

    .project-card img {
        height: 80px;
        margin-bottom: 8px;
    }

    .project-card h3 {
        font-size: 15px;
        margin-bottom: 5px;
        line-height: 1.2;
    }

    .project-card .type {
        padding: 2px 8px;
        font-size: 10px;
        margin-bottom: 6px;
    }

    .project-card .description {
        font-size: 11px;
        line-height: 1.3;
    }

    .timeline-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        margin: 0;
        padding: 15px 20px;
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(25px);
        border: none;
        border-top: 1px solid rgba(148, 163, 184, 0.3);
        border-radius: 0;
        z-index: 1010;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2), 0 -2px 8px rgba(59, 130, 246, 0.1);
    }

    .project-detail-overlay.map-overlay {
        position: fixed;
        left: 12px;
        right: 12px;
        top: auto;
        bottom: calc(120px + env(safe-area-inset-bottom, 0px));
        max-height: 65vh;
        width: auto;
        max-width: none;
        padding: 16px 16px 18px;
        border-radius: 14px;
        /* Ombre "infinie" pour assombrir tout l'arrière-plan + ombre portée standard */
        box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.75), 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(148, 163, 184, 0.15);
        z-index: 3000;
        /* Assurer qu'il est au-dessus */
    }

    .project-detail-overlay.mobile-overlay {
        width: calc(100% - 24px);
    }

    .mobile-panel-heading {
        display: block;
        font-size: 20px;
        font-weight: 700;
        letter-spacing: 0.2px;
        color: #e2e8f0;
        margin-top: 8px;
        margin-bottom: 16px;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }

    .timeline-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 15px;
        margin-bottom: 12px;
    }

    .current-date {
        font-size: 18px;
        font-weight: 400;
        flex: 1;
        min-width: 0;
    }

    .timeline-controls {
        flex-shrink: 0;
        gap: 8px;
    }

    .timeline-controls button {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 70px;
    }

    .timeline-controls button.start-button {
        background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 50%, #1e40af 100%);
        color: #ffffff;
        border: 2px solid #3b82f6;
        border-radius: 10px;
        padding: 10px 20px;
        font-size: 14px;
        font-weight: 600;
        min-width: 120px;
        box-shadow: 0 6px 24px rgba(59, 130, 246, 0.4), 0 3px 12px rgba(59, 130, 246, 0.2);
        animation: startButtonGlow 2s ease-in-out infinite;
    }

    .timeline-controls button.start-button:hover,
    .timeline-controls button.start-button:active {
        background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #1d4ed8 100%);
        border-color: #60a5fa;
        transform: translateY(-1px) scale(1.01);
        box-shadow: 0 7px 26px rgba(59, 130, 246, 0.4), 0 4px 14px rgba(59, 130, 246, 0.25);
    }

    .timeline-slider-container {
        margin-bottom: 15px;
    }

    .timeline-years {
        margin-top: 8px;
        font-size: 11px;
    }

    /* Marqueur de date du jour responsive */
    .current-date-marker {
        height: 16px;
        width: 1px;
    }

    .current-date-marker::before {
        width: 5px;
        height: 5px;
    }

    /* Labels de statut responsive */
    .project-card .status-label {
        font-size: 9px;
        padding: 2px 6px;
        margin-bottom: 6px;
        margin-left: 4px;
    }

    /* Cartes de projet */

    /* Responsive pour la popup - Contraintes anti-débordement seulement */
    .welcome-overlay {
        padding: 10px;
        overflow: hidden;
    }

    .welcome-modal {
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    /* Grille en une colonne sur mobile pour les features */
    .welcome-features {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Contraintes anti-débordement pour tous les éléments */
    .welcome-modal,
    .welcome-header,
    .welcome-content,
    .feature-card {
        box-sizing: border-box;
        overflow-x: hidden;
    }

    /* CTA sans overflow pour laisser l'ombre du bouton visible */
    .welcome-cta {
        box-sizing: border-box;
    }

    /* Refonte du panneau "Commencer" (Guided Welcome) sur Mobile */
    .guided-welcome {
        position: relative;
        /* Changed from sticky */
        margin-top: 24px;
        /* Push to bottom if flex container */
        margin-left: 0;
        /* Compensate parent padding */
        margin-right: 0;
        margin-bottom: 0;
        /* Compensate parent padding-bottom */
        padding: 20px;
        /* Reduced from 24px */
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(8px);
        border-radius: 16px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        /* Reduced from 16px */
        text-align: center;
        border: 1px solid rgba(148, 163, 184, 0.15);
    }

    /* Gradient overlay pour adoucir la coupure avec le contenu */
    .guided-welcome::before {
        content: '';
        position: absolute;
        top: -40px;
        /* Reduced from -60px */
        left: 0;
        right: 0;
        height: 40px;
        /* Reduced from 60px */
        background: linear-gradient(to bottom, transparent, rgba(15, 23, 42, 0.9));
        /* More opaque end */
        pointer-events: none;
    }

    .guided-welcome-text {
        color: #e2e8f0;
        font-size: 13px;
        /* Reduced from 15px */
        line-height: 1.4;
        margin-bottom: 4px;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
        padding: 0 10px;
        opacity: 0.9;
    }

    .guided-welcome-actions {
        width: 100%;
    }

    #guidedStartButton {
        width: 100%;
        display: block;
        padding: 12px;
        /* Reduced from 16px */
        font-size: 15px;
        /* Reduced from 16px */
        font-weight: 600;
        border-radius: 12px;
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: white;
        transition: transform 0.2s;
    }

    #guidedStartButton:active {
        transform: scale(0.98);
        background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    }

    .guided-hero {
        margin: 0 -20px 15px;
        /* Reduced margin */
        border-radius: 0;
    }

    .guided-hero-image {
        width: 100%;
        height: 180px;
        /* Reduced height */
        object-fit: cover;
        object-position: center 75%;
        mask-image: none;
        -webkit-mask-image: none;
    }

    .guided-hero-intro {
        font-size: 16px;
        line-height: 1.6;
        color: #cbd5e1;
        margin: 8px 0 24px 0;
        padding: 0 4px;
    }
}

/* Responsive pour tablettes */
@media (max-width: 1200px) {
    :root {
        --info-panel-width: 500px;
    }

    .info-panel {
        width: 500px;
    }

    /* Forcer le positionnement correct de la timeline pour éviter les conflits de media queries */
    .timeline-container {
        right: 520px !important;
        /* 500px (panneau) + 20px (marge) */
    }

    /* Supprimer la règle fixe pour .wide - le redimensionnement libre prendra le dessus */
    /* .info-panel.wide {
        width: 600px;
    } */

    /* Laisser le système auto-fit gérer les colonnes */
    #projectCards {
        /* grid-template-columns géré automatiquement par auto-fit */
        gap: 18px;
    }

    /* Supprimer la règle spécifique pour .wide car auto-fit s'en charge */
    /* .info-panel.wide #projectCards {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    } */

    .project-card {
        padding: 16px;
    }

    .project-card img {
        height: 140px;
    }
}

/* Responsive pour écrans standards (entre 1200px et 1920px) */
@media (min-width: 1201px) and (max-width: 1919px) {
    :root {
        --info-panel-width: 600px;
    }

    .timeline-container {
        right: 620px !important;
        /* 600px (panneau) + 20px (marge) */
    }
}

/* Responsive pour grands écrans */
@media (min-width: 1920px) {
    :root {
        --info-panel-width: 700px;
    }

    .info-panel {
        width: 700px;
    }

    /* Forcer le positionnement correct de la timeline pour éviter les conflits de media queries */
    .timeline-container {
        right: 720px !important;
        /* 700px (panneau) + 20px (marge) */
    }

    /* Supprimer la règle fixe pour .wide - le redimensionnement libre prendra le dessus */
    /* .info-panel.wide {
        width: 900px;
    } */

    .info-panel h1 {
        font-size: 32px;
    }

    .info-panel .subtitle {
        font-size: 16px;
    }

    .project-card {
        padding: 24px;
    }

    .project-card img {
        height: 200px;
    }

    .project-card h3 {
        font-size: 20px;
    }

    .project-card .description {
        font-size: 14px;
    }
}

/* Styles pour les écrans très petits */
@media (max-width: 480px) {
    .welcome-overlay {
        padding: 8px;
        align-items: center;
        justify-content: center;
    }

    .welcome-modal {
        max-height: 95vh;
        border-radius: 12px;
    }

    .welcome-header {
        padding: 18px 12px 12px;
        border-radius: 12px 12px 0 0;
    }

    .welcome-header h1 {
        font-size: 22px;
    }

    .welcome-header .subtitle {
        font-size: 12px;
    }

    .welcome-content {
        padding: 12px;
        padding-bottom: 20px;
    }

    .welcome-description {
        font-size: 13px;
        margin-bottom: 18px;
    }

    .welcome-features {
        gap: 12px;
        margin-bottom: 20px;
    }

    .feature-card {
        padding: 12px;
    }

    .feature-icon {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .feature-title {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .feature-description {
        font-size: 11px;
    }

    .welcome-cta {
        padding: 18px 12px;
        margin: 0 -12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .start-button {
        padding: 14px 24px;
        font-size: 15px;
    }

    .mobile-header {
        padding: 6px 12px;
        /* Encore plus compact sur très petits écrans */
    }

    .mobile-title h1 {
        font-size: 15px;
        /* Réduit de 16px */
    }

    .mobile-title .subtitle {
        font-size: 8px;
        /* Réduit de 9px */
    }

    .container {
        padding-top: 55px;
        /* Réduit encore pour très petits écrans */
    }

    .info-panel {
        height: calc(100vh - 55px);
        /* Ajusté */
        padding-bottom: 110px;
        /* Réduit encore */
    }

    .timeline-container {
        padding: 6px 10px;
        /* Encore plus compact */
    }

    .timeline-header {
        margin-bottom: 8px;
        /* Réduit */
    }

    .current-date {
        font-size: 14px;
        /* Réduit de 16px */
    }

    .timeline-controls button.start-button {
        padding: 6px 12px;
        /* Réduit */
        font-size: 11px;
        /* Réduit */
        min-width: 80px;
        /* Réduit */
    }

    .timeline-years {
        font-size: 9px;
        /* Réduit */
    }
}

@media (max-width: 1024px) {
    .guided-metrics {
        grid-template-columns: 1fr;
    }

    .guided-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .guided-intro {
        padding: 16px;
    }

    body.guided-mode .info-panel {
        width: 100% !important;
    }

    body.guided-mode {
        --info-panel-width: 100%;
    }

    .guided-welcome {
        margin-top: 6px;
    }
}
