/* =================================================================
   CARTE PROFESSEURS - STYLES
   Plugin WordPress pour afficher une carte interactive des professeurs
================================================================= */

/* ---------- Layout principal ---------- */
#ipf-wrapper {
    display: flex;
    width: 100%;
    height: calc(100vh - var(--header-high, 80px) - var(--y-padding, 40px));

}

/* ---------- Sidebar ---------- */
#ipf-sidebar {
    flex: 0 0 380px;
    max-width: 380px;
    min-width: 220px;
    width: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1.5px 0 rgba(0, 0, 0, 0.03);
    border-radius: 18px;
    margin: 18px 12px 18px 0;
    padding: 0 0 12px 0;

    z-index: 2;
    border: none;
    transition: box-shadow 0.3s, background 0.3s;
}

#ipf-sidebar * {
    max-width: 100%;
    box-sizing: border-box;
}

#ipf-sidebar .sidebar-header {
    padding: 28px 24px 18px 24px;
    background: transparent;
    border-bottom: none;
    box-shadow: none;
}

#ipf-sidebar .sidebar-title {
    font-size: 22px;
    gap: 12px;
    color: var(--bricks-color-couleur-sombre, #222);
}

/* Classe pour masquer visuellement mais garder accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* barre de recherche */
#ipf-form {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    position: relative;
}

#ipf-search {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--couleur-bordure, #e0e0e0);
    border-radius: 8px;
    color: var(--couleur-sombre, #333);
    background: var(--couleur-clair, #fff);
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

#ipf-search::placeholder {
    color: var(--couleur-attenuee, #888);
    font-size: 13px;
}

#ipf-search:focus {
    outline: 0;
    border-color: var(--couleur-primaire, #bfa77a);
    box-shadow: 0 0 0 3px rgba(191, 167, 122, 0.1);
}

#ipf-form button {
    flex: 0 0 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: var(--couleur-primaire, #bfa77a);
    color: #fff;
    transition: all 0.2s ease;
    font-size: 14px;
}

#ipf-form button:hover {
    background: color-mix(in srgb, var(--couleur-primaire, #bfa77a) 90%, #000);
    transform: translateY(-1px);
}

#ipf-form button:active {
    transform: translateY(0);
}

/* ---------- Liste + accordéon ---------- */
#ipf-sidebar .sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px 0 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--couleur-bordure, #e0e0e0) #f8f9fa;
}

#ipf-sidebar .sidebar-content::-webkit-scrollbar {
    width: 7px;
}

#ipf-sidebar .sidebar-content::-webkit-scrollbar-thumb {
    background: var(--couleur-bordure, #e0e0e0);
    border-radius: 4px;
}

#ipf-sidebar .sidebar-content::-webkit-scrollbar-track {
    background: #f8f9fa;
}

#ipf-liste-profs {
    margin: 0;
    padding: 0;
    list-style: none;
}

#ipf-liste-profs li {
    margin: 8px 0;
    border: 1px solid var(--couleur-bordure);
    border-radius: 12px;
    background: #fff;
    list-style: none;
    cursor: pointer;
    transition: all 0.25s ease;
    overflow: hidden;
    scroll-margin-top: 20px;
}

#ipf-liste-profs li:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

#ipf-liste-profs li.open {
    border-color: var(--couleur-primaire);
    background: color-mix(in srgb, var(--couleur-primaire) 8%, #fff);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* entête carte prof */
.teacher-card {
    padding: 16px 18px;
}

.teacher-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.teacher-avatar,
.teacher-avatar-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--couleur-bordure);
    flex-shrink: 0;
}

.teacher-avatar-placeholder {
    background: var(--bricks-color-couleur-sombre, #222);
    color: #fff;
    font-weight: 700;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.teacher-info {
    flex: 1;
    min-width: 0;
}

.teacher-name {
    font: 600 16px/1.3 var(--font-primary, "Segoe UI", sans-serif);
    color: var(--couleur-sombre);
    margin: 0 0 4px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.teacher-location {
    font-size: 13px;
    color: var(--couleur-attenuee);
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.teacher-expand {
    font-size: 18px;
    color: var(--couleur-attenuee);
    transition: 0.25s;
    flex-shrink: 0;
}

li.open .teacher-expand {
    transform: rotate(180deg);
    color: var(--couleur-primaire);
}

/* détails accordéon */
.teacher-details {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.4s ease;
}

li.open .teacher-details {
    max-height: 800px;
    opacity: 1;
    padding-top: 16px;
    border-top: 1px solid var(--couleur-bordure);
    margin-top: 8px;
}

.detail-section {
    margin-bottom: 16px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-label {
    font: 600 12px/1.2 var(--font-primary, "Segoe UI", sans-serif);
    color: var(--couleur-sombre);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.detail-value {
    font-size: 14px;
    color: var(--couleur-sombre);
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.detail-value a {
    color: var(--couleur-secondaire);
    text-decoration: none;
    transition: 0.2s;
    word-break: break-all;
}

.detail-value a:hover {
    text-decoration: underline;
    color: var(--couleur-primaire);
}

.courses-tag {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bricks-color-couleur-sombre, #222);
    color: #fff;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px 0;
}

.links-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.link-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--couleur-secondaire);
    text-decoration: none;
    transition: 0.2s;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.02);
}

.link-item:hover {
    color: var(--couleur-primaire);
    text-decoration: underline;
    background: rgba(0, 0, 0, 0.05);
}

/* état vide & loading */
.no-results,
.loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--couleur-attenuee);
    font-style: italic;
}

.no-results i {
    font-size: 24px;
    margin-bottom: 10px;
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--couleur-bordure);
    border-top-color: var(--couleur-sombre);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

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

/* ---------- Carte ---------- */
#map-professeurs {
    flex: 1;
    position: relative;
    background: #e9e9ee;
    z-index: 1;
    width: 100%;
    height: 100%;
    border-radius: 18px;
    overflow: hidden;
}

/* S'assurer que Mapbox utilise toute la zone disponible */
#map-professeurs .mapboxgl-map {
    width: 100% !important;
    height: 100% !important;
}

.mapboxgl-marker {
    cursor: pointer;
}

.mapboxgl-popup {
    z-index: 10;
}

.mapboxgl-popup-content {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    #ipf-wrapper {
        flex-direction: column;
        height: calc(100vh - var(--header-high, 80px) - var(--y-padding, 40px));
        min-height: calc(100vh - var(--header-high, 80px) - var(--y-padding, 40px));

    }

    #ipf-sidebar {
        flex: 0 0 auto;
        max-height: 60%;
        /* 60% de la hauteur disponible après soustraction du header */
        max-width: 100vw;
        margin: 0;
        border-radius: 20px;
        box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
        border-bottom: 1px solid var(--couleur-bordure, #e0e0e0);
        overflow: hidden;
    }

    #ipf-sidebar .sidebar-header {
        padding: 20px 18px 16px 18px;
    }

    #ipf-sidebar .sidebar-title {
        font-size: 20px;
        gap: 10px;
    }

    #ipf-sidebar .sidebar-content {
        padding: 8px 12px 12px 12px;
    }

    #map-professeurs {
        flex: 1;
        min-height: 40%;
        margin-top: 18px;
        /* 40% de la hauteur disponible */
        max-height: 40%;
        border-left: none;
        border-top: 1px solid var(--couleur-bordure, #e0e0e0);
        width: 100%;
        overflow: hidden;
    }

    /* Cartes professeurs sur mobile */
    .teacher-header {
        gap: 12px;
        align-items: center;
    }

    .teacher-avatar,
    .teacher-avatar-placeholder {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }

    .teacher-name {
        font-size: 15px;
        line-height: 1.3;
    }

    .teacher-location {
        font-size: 13px;
    }

    .teacher-card {
        padding: 14px 16px;
    }

    .teacher-expand {
        font-size: 16px;
    }

    /* Formulaire de recherche mobile */
    #ipf-form {
        margin-top: 12px;
    }

    #ipf-search {
        padding: 14px 16px;
        font-size: 16px;
        /* Éviter le zoom sur iOS */
        border-radius: 12px;
    }

    /* Amélioration des détails sur mobile */
    .detail-section {
        margin-bottom: 14px;
    }

    .detail-label {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .detail-value {
        font-size: 14px;
        line-height: 1.4;
    }

    .courses-tag {
        padding: 5px 10px;
        font-size: 11px;
    }

    .link-item {
        padding: 8px 10px;
        font-size: 14px;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    #ipf-wrapper {
        height: 100vh;
    }

    #ipf-sidebar {
        max-height: 65%;
        /* 65% de la hauteur disponible sur très petit écran */
    }

    #ipf-sidebar .sidebar-header {
        padding: 16px 14px 12px 14px;
    }

    #ipf-sidebar .sidebar-title {
        font-size: 18px;
        gap: 8px;
    }

    #ipf-sidebar .sidebar-content {
        padding: 6px 10px 10px 10px;
    }

    #map-professeurs {
        min-height: 35%;
        /* 35% de la hauteur disponible */
        max-height: 35%;
    }

    .teacher-header {
        gap: 10px;
    }

    .teacher-avatar,
    .teacher-avatar-placeholder {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .teacher-name {
        font-size: 14px;
    }

    .teacher-location {
        font-size: 12px;
    }

    .teacher-card {
        padding: 12px 14px;
    }

    #ipf-search {
        padding: 12px 14px;
        font-size: 16px;
    }

    /* Zone de clic plus large sur très petit écran */
    #ipf-liste-profs li {
        margin: 6px 0;
        border-radius: 12px;
    }

    .detail-value {
        font-size: 13px;
    }

    .courses-tag {
        padding: 4px 8px;
        font-size: 10px;
    }
}

/* Amélioration des interactions tactiles */
@media (max-width: 768px) {
    #ipf-liste-profs li {
        min-height: 48px;
        /* Taille minimum recommandée pour le tactile */
        touch-action: manipulation;
        /* Évite le double-tap zoom */
    }

    .teacher-header {
        min-height: 48px;
        padding: 4px 0;
    }

    /* Popup mapbox plus adapté au mobile */
    .mapboxgl-popup-content {
        border-radius: 12px;
        padding: 8px 12px;
        font-size: 14px;
        max-width: 200px;
    }

    /* Amélioration des contrôles Mapbox sur mobile */
    .mapboxgl-ctrl-group {
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .mapboxgl-ctrl-group button {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 900px) {
    #ipf-sidebar {
        max-width: 100vw;
        margin: 0;
        border-radius: 20px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    }
}