/* =============================================================================
   ECLIPSEFAN MOBILE - PORTRAIT UI (Weather Stats, Map Controls, Search, Help)
   =============================================================================
   Weather statistics, map control positioning, search bar, geocoder,
   share/eclipsefan buttons, modal, and help sections for portrait mobile.
   ============================================================================= */

@media (max-width: 767px) {

    /* =====================================================
       STATISTIQUES MÉTÉO
       ===================================================== */
    .bs-weather-stats-section {
        padding: 4px 0;
    }
    .bs-weather-stats-title {
        font-size: var(--text-sm);
        font-weight: 600;
        color: #333;
        margin-bottom: 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .bs-weather-stats {
        background: #f9f9f9;
        border-radius: 8px;
        padding: 12px;
    }
    .bs-weather-stats-placeholder,
    .bs-weather-stats-loading,
    .bs-weather-stats-error {
        font-size: var(--text-sm);
        color: #888;
        text-align: center;
        padding: 8px 0;
    }
    .bs-weather-stats-error {
        color: #c00;
    }
    .bs-weather-stat-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid #eee;
    }
    .bs-weather-stat-row:last-child {
        border-bottom: none;
    }
    .bs-weather-stat-label {
        font-size: var(--text-base);
        color: #555;
    }
    .bs-weather-stat-value {
        font-size: var(--text-base);
        font-weight: 600;
        color: #333;
    }
    .bs-weather-stat-value.good {
        color: #2e7d32;
    }
    .bs-weather-stat-value.medium {
        color: #f57c00;
    }
    .bs-weather-stat-value.bad {
        color: #c62828;
    }

    /* Détail par année */
    .bs-weather-years {
        margin-top: 12px;
    }
    .bs-weather-years-title {
        font-size: var(--text-xs);
        font-weight: 600;
        color: #666;
        margin-bottom: 8px;
    }
    .bs-weather-years-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    .bs-weather-year-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        background: #f5f5f5;
        border-radius: 6px;
        padding: 6px 4px;
    }
    .bs-weather-year-label {
        font-size: var(--text-xs);
        color: #888;
    }
    .bs-weather-year-value {
        font-size: var(--text-xs);
        font-weight: 600;
        color: #333;
    }
    .bs-weather-year-value.good {
        color: #2e7d32;
    }
    .bs-weather-year-value.medium {
        color: #f57c00;
    }
    .bs-weather-year-value.bad {
        color: #c62828;
    }

    /* =====================================================
       MASQUER LES PANNEAUX LEAFLET SUR MOBILE
       ===================================================== */
    .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;
    }

    /* =====================================================
       REPOSITIONNER LES CONTRÔLES CARTE
       ===================================================== */
    /* S'assurer que les contrôles en haut à droite sont au-dessus du bottom sheet */
    .leaflet-top.leaflet-right {
        z-index: 1001 !important;
    }

    /* Remonter zoom et scale au-dessus du bottom sheet et du bouton géoloc */
    .leaflet-bottom.leaflet-right {
        bottom: 155px !important;
    }

    /* Attribution/copyright juste au-dessus du bottom sheet (peek = 80px) */
    .leaflet-control-attribution.leaflet-control {
        position: fixed !important;
        bottom: 80px !important;
        left: auto !important;
        right: 0 !important;
        font-size: 10px !important;
        background: rgba(255,255,255,0.7) !important;
        padding: 1px 4px !important;
        margin: 0 !important;
        /* Prevent collision with icons - crop from left, show right part */
        max-width: 100vw !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        direction: rtl !important;
        text-overflow: ellipsis !important;
    }

    [data-theme="dark"] .leaflet-control-attribution.leaflet-control,
    [data-theme="astro"] .leaflet-control-attribution.leaflet-control {
        background: rgba(0,0,0,0.7) !important;
        color: #aaa !important;
    }

    [data-theme="dark"] .leaflet-control-attribution.leaflet-control a,
    [data-theme="astro"] .leaflet-control-attribution.leaflet-control a {
        color: #aaa !important;
    }

    /* =====================================================
       BOUTON GÉOLOCALISATION FLOTTANT
       ===================================================== */
    .geolocate-btn {
        position: fixed;
        right: 10px;
        bottom: 95px;
        z-index: 999;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: white;
        border: none;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: #666;
        transition: background 0.2s, color 0.2s;
    }
    .geolocate-btn:hover,
    .geolocate-btn:active {
        background: #f0f0f0;
    }
    .geolocate-btn.locating {
        color: #4A90D9;
    }
    .geolocate-btn.locating svg {
        animation: pulse 1.5s ease-in-out infinite;
    }
    @keyframes pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.5; }
    }

    /* ----- PANNEAU ECLIPSE (topleft - premier) ----- */
    .eclipse-calc-box {
        max-width: calc(100vw - 20px) !important;
        font-size: var(--text-xs);
    }

    .eclipse-calc-box h3 {
        font-size: var(--text-sm);
    }

    .eclipse-calc-box .calc-row {
        font-size: var(--text-xs);
    }

    /* ----- PANNEAU OMBRES (topleft) ----- */
    .time-control {
        max-width: calc(100vw - 20px) !important;
        font-size: var(--text-xs);
    }

    .time-control h4 {
        font-size: var(--text-xs);
    }

    .time-control .btn-row button {
        padding: 4px 6px;
        font-size: var(--text-xs);
    }

    /* ----- PANNEAU SKYLINE (topleft) ----- */
    .skyline-control-v2 {
        max-width: calc(100vw - 20px) !important;
        font-size: var(--text-xs);
    }

    .skyline-control-v2 .skyline-canvas-container {
        max-width: 100%;
    }

    .skyline-control-v2 #skyline-canvas-v2 {
        max-width: 100%;
        height: auto;
    }

    .skyline-control-v2 .visibility-table {
        font-size: var(--text-xs);
    }

    /* ----- PANNEAU MÉTÉO (topleft) ----- */
    .weather-history-control {
        max-width: calc(100vw - 20px) !important;
        font-size: var(--text-xs);
    }

    .weather-history-control .weather-select {
        font-size: var(--text-xs);
        padding: 4px 6px;
    }

    .weather-history-control .weather-nav-btn {
        padding: 4px 8px;
        font-size: var(--text-xs);
    }

    /* ----- CONTRÔLES EN HAUT À DROITE ----- */

    /* Search control et son conteneur Leaflet - centré horizontalement */
    .leaflet-control:has(.search-control),
    .leaflet-control.leaflet-control-geocoder,
    .search-control {
        position: fixed !important;
        top: 8px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        margin: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    .search-control {
        gap: 4px;
    }

    /* Top bar control (partager, aide, thème) - fond transparent */
    .leaflet-control:has(.top-bar-control),
    .top-bar-control {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    .search-control input {
        width: 110px;
        height: 26px;
        padding: 0 10px;
        font-size: var(--text-xs);
        border-radius: 13px;
    }
    .search-geolocate-btn {
        width: 26px;
        height: 26px;
    }
    .search-geolocate-btn svg {
        width: 14px;
        height: 14px;
    }
    .search-suggestions {
        max-height: 150px;
    }
    .search-suggestions li {
        padding: 10px 12px;
        font-size: var(--text-xs);
    }

    /* Cacher l'ancien bouton géolocalisation en bas */
    #geolocate-btn.geolocate-btn {
        display: none !important;
    }

    /* Top bar (partager, aide) - aligné avec search et zoom */
    .top-bar-control {
        margin-top: 10px !important;
        margin-right: 8px !important;
    }
    .top-bar-control .top-bar-btn {
        width: 32px;
        height: 32px;
    }
    .top-bar-control .top-bar-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Geocoder - compact for mobile */
    .leaflet-control-geocoder {
        max-width: 110px !important;
    }

    .leaflet-control-geocoder.leaflet-control-geocoder-expanded {
        max-width: 150px !important;
    }

    .leaflet-control-geocoder input {
        font-size: var(--text-xs) !important;
        padding: 4px 5px !important;
        width: 70px !important;
    }

    .leaflet-control-geocoder-expanded input {
        width: 110px !important;
    }

    /* Boutons Partager et Eclipsefan - plus compacts */
    .share-control,
    .eclipsefan-control {
        padding: 5px 8px !important;
    }

    .share-btn,
    .eclipsefan-btn {
        padding: 6px 10px !important;
        font-size: var(--text-xs) !important;
    }

    .share-btn span,
    .eclipsefan-btn span {
        display: none; /* Cacher le texte, garder l'icône */
    }

    .share-btn svg,
    .eclipsefan-btn svg {
        width: 18px !important;
        height: 18px !important;
    }

    /* Sélecteur de couches - replié par défaut */
    .leaflet-control-layers {
        max-width: 44px;
    }

    .leaflet-control-layers-expanded {
        max-width: 200px;
    }

    /* ----- MODAL ECLIPSEFAN ----- */
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }

}

@media (max-width: 767px) {
    .bs-help-section {
        margin-top: 16px;
        padding-top: 8px;
    }

    .bs-help-section .inline-help {
        border-top: 1px solid #eee;
        margin-top: 0;
    }

    .bs-help-section .inline-help-toggle {
        padding: 10px 0;
        font-size: var(--text-sm);
    }

    .bs-help-section .inline-help-body {
        padding-bottom: 12px;
    }

    .bs-help-section .help-content {
        font-size: var(--text-xs);
    }

    .bs-help-section .help-content h1 {
        font-size: var(--text-md);
    }

    .bs-help-section .help-content h2 {
        font-size: var(--text-base);
    }

    .bs-help-section .help-content h3 {
        font-size: var(--text-sm);
    }

    .bs-help-section .help-content p,
    .bs-help-section .help-content li {
        font-size: var(--text-xs);
        line-height: 1.5;
    }

    .bs-help-section .help-content table {
        font-size: var(--text-xs);
    }

    .bs-help-section .help-content img {
        border-radius: 4px;
    }

}
