/* =============================================================================
   ECLIPSEFAN MOBILE - LEFT PANEL (Desktop)
   =============================================================================
   Desktop left panel layout, tabs, weather stats, fan diagram, skyline,
   help section, map offset, and responsive adjustments.
   ============================================================================= */

/* =====================================================
   PANNEAU LATÉRAL GAUCHE - DESKTOP UNIQUEMENT
   (>= 768px et hauteur >= 501px)
   ===================================================== */
@media (min-width: 768px) and (min-height: 501px) {

    /* Afficher le panneau latéral gauche */
    .left-panel {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 50vw;
        background: white;
        box-shadow: 2px 0 20px rgba(0,0,0,0.15);
        z-index: 1000;
        overflow: hidden;
    }

    /* Header du panneau */
    .left-panel-header {
        padding: 16px;
        border-bottom: 1px solid #eee;
        background: #f9f9f9;
    }

    .lp-header-content {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    /* Ligne 1 : Nom du lieu */
    .lp-header-row1 {
        display: flex;
        align-items: center;
    }

    .lp-location-name {
        font-size: var(--text-lg);
        font-weight: 600;
        color: #333;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Ligne 2 : Badge + durée + heure */
    .lp-header-row2 {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }

    .lp-type-badge {
        display: inline-flex;
        align-items: center;
        padding: 4px 12px;
        border-radius: 12px;
        font-size: var(--text-sm);
        font-weight: 600;
        white-space: nowrap;
    }

    .lp-type-badge.total {
        background: #800080;
        color: white;
    }

    .lp-type-badge.partial {
        background: #FFA500;
        color: white;
    }

    .lp-type-badge:empty {
        display: none;
    }

    .lp-duration {
        font-size: var(--text-base);
        font-weight: 600;
        color: #800080;
        white-space: nowrap;
    }

    .lp-duration:empty {
        display: none;
    }

    .lp-max-time {
        font-size: var(--text-base);
        font-weight: 500;
        color: #555;
        white-space: nowrap;
    }

    .lp-max-time:empty {
        display: none;
    }

    /* Bouton toggle UTC/Local dans le left panel */
    .lp-tz-toggle {
        font-size: var(--text-xs);
        color: #fff;
        background: #4A90D9;
        border: none;
        border-radius: 4px;
        padding: 4px 10px;
        font-weight: 600;
        cursor: pointer;
        margin-left: 6px;
        vertical-align: middle;
        transition: background 0.2s;
    }

    .lp-tz-toggle:hover {
        background: #357ABD;
    }

    /* Contenu du panneau */
    .left-panel-content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0 16px 16px;
    }

    /* Date de l'éclipse */
    .left-panel .lp-eclipse-date {
        text-align: center;
        padding: 10px 12px;
        font-size: var(--text-sm);
        font-weight: 600;
        color: #444;
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-bottom: 1px solid #dee2e6;
        margin: 0 -16px;
    }

    /* Onglets - réutiliser les styles bs- */
    .left-panel .lp-tabs {
        display: flex;
        gap: 0;
        border-bottom: 1px solid #eee;
        margin-bottom: 16px;
        padding-top: 12px;
        position: sticky;
        top: 0;
        background: white;
        z-index: 1;
    }

    .left-panel .lp-tab {
        flex: 1;
        padding: 12px 10px;
        border: none;
        background: transparent;
        font-size: var(--text-base);
        font-weight: 500;
        color: #666;
        cursor: pointer;
        white-space: nowrap;
        border-bottom: 2px solid transparent;
        transition: color 0.2s, border-color 0.2s;
        text-align: center;
    }

    .left-panel .lp-tab:hover {
        color: #333;
    }

    .left-panel .lp-tab.active {
        color: #800080;
        border-bottom-color: #800080;
        font-weight: 600;
    }

    /* Contenu des onglets */
    .left-panel .lp-tab-content {
        min-height: 200px;
    }

    .left-panel .lp-tab-pane {
        display: none;
        padding: 4px 0;
    }

    .left-panel .lp-tab-pane.active {
        display: block;
    }

    /* Section horaires compacte */
    .left-panel .lp-compact-times {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .left-panel .lp-compact-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .left-panel .lp-compact-item {
        display: flex;
        align-items: baseline;
        gap: 8px;
    }

    .left-panel .lp-compact-label {
        font-size: var(--text-base);
        color: #666;
    }

    .left-panel .lp-compact-value {
        font-size: var(--text-md);
        font-weight: 600;
        font-family: monospace;
        color: #333;
    }

    /* Statistiques météo - réutiliser le même style */
    .left-panel .lp-weather-stats-section {
        margin-top: 16px;
        padding-top: 16px;
        border-top: 1px solid #eee;
    }

    .left-panel .lp-weather-stats-title {
        font-size: var(--text-base);
        font-weight: 600;
        color: #333;
        margin-bottom: 12px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .left-panel .lp-weather-stats {
        background: #f9f9f9;
        border-radius: 8px;
        padding: 12px;
    }

    .left-panel .lp-weather-stats-placeholder,
    .left-panel .lp-weather-stats-loading,
    .left-panel .lp-weather-stats-error {
        font-size: var(--text-sm);
        color: #888;
        text-align: center;
        padding: 10px 0;
    }

    .left-panel .lp-weather-stats-error {
        color: #c00;
    }

    .left-panel .lp-weather-stat-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }

    .left-panel .lp-weather-stat-row:last-child {
        border-bottom: none;
    }

    .left-panel .lp-weather-stat-label {
        font-size: var(--text-base);
        color: #555;
    }

    .left-panel .lp-weather-stat-value {
        font-size: var(--text-base);
        font-weight: 600;
        color: #333;
    }

    .left-panel .lp-weather-stat-value.good {
        color: #2e7d32;
    }

    .left-panel .lp-weather-stat-value.medium {
        color: #f57c00;
    }

    .left-panel .lp-weather-stat-value.bad {
        color: #c62828;
    }

    /* Détail par année */
    .left-panel .lp-weather-years {
        margin-top: 12px;
    }

    .left-panel .lp-weather-years-title {
        font-size: var(--text-xs);
        font-weight: 600;
        color: #666;
        margin-bottom: 8px;
    }

    .left-panel .lp-weather-years-grid {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .left-panel .lp-weather-year-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        background: #f5f5f5;
        border-radius: 6px;
        padding: 6px 4px;
    }

    .left-panel .lp-weather-year-label {
        font-size: var(--text-xs);
        color: #888;
    }

    .left-panel .lp-weather-year-value {
        font-size: var(--text-xs);
        font-weight: 600;
        color: #333;
    }

    .left-panel .lp-weather-year-value.good {
        color: #2e7d32;
    }

    .left-panel .lp-weather-year-value.medium {
        color: #f57c00;
    }

    .left-panel .lp-weather-year-value.bad {
        color: #c62828;
    }

    /* Onglet Fan - conteneur */
    .left-panel .lp-fan-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px 0;
        min-height: 200px;
    }

    /* Conteneur diagramme + contrôles */
    .left-panel .lp-fan-controls-row {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        margin: 8px 0;
    }

    .left-panel .lp-fan-ctrl-col {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        flex: 1;
    }

    .left-panel .lp-fan-ctrl-btns {
        display: flex;
        gap: 8px;
    }

    .left-panel .lp-fan-ctrl-btn {
        width: 36px;
        height: 36px;
        border: 2px solid #800080;
        border-radius: 6px;
        background: white;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }

    .left-panel .lp-fan-ctrl-btn:hover {
        background: #f5f0f5;
    }

    .left-panel .lp-fan-ctrl-btn:active {
        transform: scale(0.95);
    }

    .left-panel #lp-fan-current-time {
        font-size: var(--text-xl);
        font-weight: 700;
        color: #800080;
        font-family: monospace;
    }

    .left-panel #lp-fan-diagram-container {
        transform: scale(1.8);
        margin: 16px 24px;
    }

    .left-panel .lp-fan-safety-col {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        flex: 1;
    }

    .left-panel .lp-fan-safety-img {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        object-fit: cover;
    }

    .left-panel .lp-fan-safety-text {
        font-size: var(--text-sm, 13px);
        color: #666;
        text-align: center;
        line-height: 1.3;
        font-weight: 600;
    }

    /* Slider timeline */
    .left-panel .lp-fan-slider-container {
        width: 100%;
        margin-top: 8px;
        padding: 0 24px;
        box-sizing: border-box;
    }

    .left-panel #lp-fan-slider {
        -webkit-appearance: none;
        appearance: none;
        width: 100%;
        height: 8px;
        background: linear-gradient(to right, #ccc 0%, #800080 50%, #ccc 100%);
        border-radius: 4px;
        outline: none;
        cursor: pointer;
    }

    .left-panel #lp-fan-slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 24px;
        height: 24px;
        background: #800080;
        border-radius: 50%;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(128, 0, 128, 0.5);
        border: 3px solid white;
    }

    .left-panel #lp-fan-slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
        background: #800080;
        border-radius: 50%;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(128, 0, 128, 0.5);
        border: 3px solid white;
    }

    /* Onglet Horizon */
    .left-panel .lp-skyline-canvas-container {
        width: 100%;
        overflow: hidden;
        border-radius: 8px;
        background: #f5f5f5;
    }

    .left-panel .lp-skyline-canvas-container canvas {
        display: block;
        width: 100%;
        height: auto;
        max-width: 100%;
    }

    /* Grille de visibilité skyline */
    .left-panel .lp-visibility-grid .visibility-table {
        font-size: var(--text-xs);
        width: 100%;
    }

    .left-panel .lp-visibility-grid .visibility-table td {
        padding: 4px 6px;
    }

    /* Section aide en ligne */
    .left-panel .lp-help-section {
        margin-top: 16px;
        padding-top: 8px;
    }

    /* Masquer les anciens panneaux desktop sur le côté gauche */
    .leaflet-top.leaflet-left .eclipse-calc-box,
    .leaflet-top.leaflet-left .time-control,
    .leaflet-top.leaflet-left .weather-history-control,
    .leaflet-top.leaflet-left .skyline-control-v2 {
        display: none !important;
    }

    /* Décaler la carte pour laisser place au panneau */
    #map {
        position: absolute !important;
        left: 50vw !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: auto !important;
        height: 100% !important;
    }

    /* Zoom en haut à gauche de la carte (position par défaut Leaflet) */
    .leaflet-top.leaflet-left {
        left: 10px !important;
        top: 10px !important;
    }

    /* Icônes de couches centrées en bas de la carte (fixe aussi) */
    .leaflet-bottom.leaflet-left .custom-layers-control {
        left: 75vw !important;
        transform: translateX(-50%) !important;
    }

    /* Timeline centrée sur la zone carte */
    .unified-timeline {
        left: 75vw !important;
        transform: translateX(-50%) !important;
    }

    /* Top-bar (Partager, Aide) en haut à droite de la carte */
    .leaflet-top.leaflet-right {
        right: 10px !important;
        top: 10px !important;
    }

    /* Contrôles en bas à droite (échelle) */
    .leaflet-bottom.leaflet-right {
        right: 10px !important;
        bottom: 10px !important;
    }
}

/* Desktop large : plafonner le panneau gauche à 500px */
@media (min-width: 1000px) and (min-height: 501px) {
    .left-panel {
        width: 500px;
    }

    #map {
        left: 500px !important;
    }

    .leaflet-bottom.leaflet-left .custom-layers-control {
        left: calc(50vw + 250px) !important;
    }

    .unified-timeline {
        left: calc(50vw + 250px) !important;
    }
}

/* Masquer le panneau sur mobile et paysage mobile */
@media (max-width: 767px), (max-height: 500px) {
    .left-panel {
        display: none !important;
    }
}
