/* ============================================================
   ph_manager - Top bar + Profile menu + Banner cookie RGPD
   ============================================================
   Refonte "moderne neutre" :
    - Espacement aere, typo lisible
    - Panneau profile : card blanche, ombre douce, hover discret
    - Banner cookie : large pile vertical lisible, boutons clairs
   ============================================================ */

/* ============================================================
   Top info bar (#top_info)
   ============================================================ */
#top_info {
    display: flex;
    align-items: center;
    gap: var(--phm-space-3, 12px);
    line-height: 1.5;
    max-width: 100%;
    position: relative;
    padding: 0;
    margin: 0;
    list-style: none;
}

.floatleft {
    float: left;
}

#top_info > li {
    display: inline-flex;
    align-items: center;
    margin: 0;
    font-size: 0.9rem;
}

li.unlogged {
    display: flex !important;
    align-items: center;
    gap: 6px;
}

a.proceedlogin {
    color: #fff !important;
    text-decoration: none;
    font-weight: 500;
    padding: 6px var(--phm-space-3, 12px);
    border-radius: var(--phm-radius-sm, 6px);
    transition: background var(--phm-transition, 180ms ease);
}

a.proceedlogin:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ============================================================
   Top menu generique
   ============================================================ */
.top_menu {
    position: absolute;
    z-index: 90;
    display: none;
    min-width: 320px;
    padding: var(--phm-space-2, 8px);
    background: var(--phm-surface, #ffffff);
    border: 1px solid var(--phm-border, #e5e7eb);
    border-radius: var(--phm-radius-lg, 16px);
    box-shadow: var(--phm-shadow-xl, 0 20px 40px -10px rgba(15, 23, 42, 0.15), 0 8px 16px -4px rgba(15, 23, 42, 0.06));
    font-weight: 400;
}

/* ============================================================
   Profile menu top (bandeau connecte avec avatar)
   ============================================================ */
#top_info a#profile_menu_top {
    display: flex;
    align-items: center;
    gap: var(--phm-space-2, 8px);
    color: #fff !important;
    text-decoration: none;
    padding: 6px var(--phm-space-3, 12px);
    border-radius: var(--phm-radius-sm, 6px);
    transition: background var(--phm-transition, 180ms ease);
}

#top_info a#profile_menu_top:hover {
    background: rgba(255, 255, 255, 0.12);
}

#profile_menu_top > img.avatar {
    height: 28px;
    width: 28px;
    aspect-ratio: 1 / 1;
    border-radius: var(--phm-radius-full, 9999px);
    border: 2px solid rgba(255, 255, 255, 0.4);
    object-fit: cover;
    float: none;
    margin: 0;
}

#profile_menu_top .textmenu {
    font-size: 0.875rem;
    line-height: 1.4;
    white-space: nowrap;
}

/* ============================================================
   Panneau profile deroulant (#profile_menu)
   ============================================================ */
#profile_menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    /* Largeur fixe : evite que le parent <li> de #top_info ne contraigne
       le panneau. !important pour gagner contre les regles legacy plus
       specifiques qui peuvent encore trainer. */
    width: 320px !important;
    min-width: 320px;
    padding: 0;
    margin: 0;
    background: var(--phm-surface, #ffffff);
    border: 1px solid var(--phm-border, #e5e7eb);
    border-radius: var(--phm-radius-lg, 16px);
    box-shadow: var(--phm-shadow-xl, 0 20px 40px -10px rgba(15, 23, 42, 0.15), 0 8px 16px -4px rgba(15, 23, 42, 0.06));
    box-sizing: border-box;
    overflow: hidden;
    z-index: 1000;
    /* Layout interne en grille : avatar + info sur la 1ere ligne,
       links sur toute la largeur de la 2eme ligne. Cela neutralise
       l'effet du class="floatleft" present dans le template. */
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "avatar info"
        "links  links";
    column-gap: var(--phm-space-2, 8px);
    row-gap: 0;
}

/* Annulation du float: left herite du class="floatleft" dans le template,
   qui casserait le layout grid. */
#profile_menu .floatleft,
#profile_menu .profile_user_avatar,
#profile_menu .profile_user_info,
#profile_menu .profile_user_links {
    float: none !important;
    clear: none;
}

/* En tete du panneau : avatar + infos en grille */
.profile_user_avatar {
    grid-area: avatar;
    align-self: center;
    margin: var(--phm-space-4, 16px) 0 var(--phm-space-4, 16px) var(--phm-space-4, 16px);
    display: block;
}

.profile_user_info {
    grid-area: info;
    align-self: center;
    display: block;
    padding: var(--phm-space-4, 16px) var(--phm-space-3, 12px);
    min-width: 0; /* permet au texte de wrap proprement si besoin */
}

.profile_user_avatar img.avatar {
    width: 56px;
    height: 56px;
    max-width: 56px;
    border-radius: var(--phm-radius-full, 9999px);
    border: 2px solid var(--phm-border, #e5e7eb);
    object-fit: cover;
}

.profile_user_info {
    padding: var(--phm-space-4, 16px) var(--phm-space-3, 12px);
    line-height: 1.4;
}

.profile_username {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--phm-text, #111827);
}

.profile_username a {
    color: inherit;
    text-decoration: none;
}

.profile_group {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    background: var(--phm-accent-soft, #eef2ff);
    color: var(--phm-accent, #6366f1);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--phm-radius-full, 9999px);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Liste de liens (Mon compte, Mes adresses, etc.) */
.profile_user_links {
    grid-area: links;
    width: 100%;
    border-top: 1px solid var(--phm-border, #e5e7eb);
    padding: var(--phm-space-2, 8px);
    background: var(--phm-surface-alt, #f9fafb);
    box-sizing: border-box;
}

.profile_user_links ol {
    list-style: none;
    margin: 0;
    padding: 0;
    column-count: 1;
}

.profile_user_links li {
    margin: 0;
}

.profile_user_links li a {
    display: flex;
    align-items: center;
    gap: var(--phm-space-3, 12px);
    padding: 10px var(--phm-space-3, 12px);
    color: var(--phm-text, #111827);
    text-decoration: none;
    border-radius: var(--phm-radius-sm, 6px);
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: nowrap;          /* empeche le wrap sur les labels courts */
    overflow: hidden;
    text-overflow: ellipsis;      /* "Mes informations..." si vraiment trop long */
    transition: background var(--phm-transition, 180ms ease),
                color      var(--phm-transition, 180ms ease);
}

.profile_user_links li a i {
    width: 18px;
    text-align: center;
    color: var(--phm-text-muted, #6b7280);
    transition: color var(--phm-transition, 180ms ease);
}

.profile_user_links li a:hover {
    background: var(--phm-accent-soft, #eef2ff);
    color: var(--phm-accent, #6366f1);
}

.profile_user_links li a:hover i {
    color: var(--phm-accent, #6366f1);
}

/* Lien de deconnexion (visuellement distinct) */
.profile_user_links li a.logout {
    color: var(--phm-danger, #ef4444);
    border-top: 1px solid var(--phm-border, #e5e7eb);
    margin-top: var(--phm-space-1, 4px);
    padding-top: var(--phm-space-3, 12px);
    border-radius: 0 0 var(--phm-radius-sm, 6px) var(--phm-radius-sm, 6px);
}

.profile_user_links li a.logout i {
    color: var(--phm-danger, #ef4444);
}

.profile_user_links li a.logout:hover {
    background: var(--phm-danger-soft, #fef2f2);
    color: var(--phm-danger, #ef4444);
}

#topMain a {
    color: var(--phm-text, #111827);
    text-decoration: none;
}

/* ============================================================
   Banner cookie RGPD (#acb-banner)
   ============================================================ */
#acb-banner {
    box-sizing: border-box;
    position: fixed !important;
    left: 0;
    right: 0;
    z-index: 999999;
    width: 100%;
    margin: 0;
    padding: var(--phm-space-5, 20px) var(--phm-space-6, 24px);
    background: var(--phm-surface, #ffffff);
    color: var(--phm-text, #111827);
    border-style: solid;
    border-width: 0;
    box-shadow: var(--phm-shadow-xl, 0 20px 40px -10px rgba(15, 23, 42, 0.15), 0 8px 16px -4px rgba(15, 23, 42, 0.06));
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--phm-space-6, 24px);
}

#acb-banner.acb-position-bottom { bottom: 0; }
#acb-banner.acb-position-top    { top: 0; }

#acb-content {
    flex: 1;
    align-self: center;
    font-size: 0.95rem;
    line-height: 1.55;
}

#acb-content p {
    margin: 0;
}

.acb_link_information_container {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: var(--phm-space-2, 8px);
}

#acb_link_information {
    color: var(--phm-accent, #6366f1);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--phm-transition, 180ms ease);
}

#acb_link_information:hover {
    color: var(--phm-accent-hover, #4f46e5);
}

#acb-action {
    align-self: center;
    display: flex;
    gap: var(--phm-space-3, 12px);
    flex-wrap: wrap;
    justify-content: flex-end;
}

#acb-banner:not(.acb-gdpr) .acb-button {
    width: auto;
    min-width: 140px;
}

/* Boutons banner */
.acb-button {
    height: auto;
    min-height: 40px;
    padding: 10px var(--phm-space-5, 20px);
    background: var(--phm-surface, #ffffff);
    color: var(--phm-text, #111827);
    border: 1px solid var(--phm-border, #e5e7eb);
    border-radius: var(--phm-radius-sm, 6px);
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: all var(--phm-transition, 180ms ease);
    white-space: nowrap;
}

.acb-button:hover {
    background: var(--phm-surface-hover, #f3f4f6);
    border-color: var(--phm-border-hover, #d1d5db);
    box-shadow: var(--phm-shadow-sm, 0 1px 3px rgba(15, 23, 42, 0.08));
}

/* Le bouton "Accept all" est l'action primaire */
#acb-accept-all-button.acb-button {
    background: var(--phm-accent, #6366f1);
    color: var(--phm-text-on-accent, #ffffff);
    border-color: var(--phm-accent, #6366f1);
}

#acb-accept-all-button.acb-button:hover {
    background: var(--phm-accent-hover, #4f46e5);
    border-color: var(--phm-accent-hover, #4f46e5);
    transform: translateY(-1px);
    box-shadow: var(--phm-shadow-md, 0 4px 6px -1px rgba(15, 23, 42, 0.07));
}

/* Le bouton "Close / I agree" en mode non-GDPR */
#acb-close-button.acb-button {
    background: var(--phm-accent, #6366f1);
    color: var(--phm-text-on-accent, #ffffff);
    border-color: var(--phm-accent, #6366f1);
}

#acb-close-button.acb-button:hover {
    background: var(--phm-accent-hover, #4f46e5);
    border-color: var(--phm-accent-hover, #4f46e5);
    transform: translateY(-1px);
}

/* Bouton "Deny all" reste neutre */
#acb-deny-all-button.acb-button {
    background: var(--phm-surface, #ffffff);
    color: var(--phm-text, #111827);
    border-color: var(--phm-border, #e5e7eb);
}

/* Checkboxes GDPR */
.acbCheckboxesContainer {
    display: flex;
    flex-wrap: wrap;
    gap: var(--phm-space-5, 20px);
    margin-top: var(--phm-space-4, 16px);
}

.acbCheckboxContainer16,
.acbCheckboxContainer {
    display: flex;
    align-items: center;
    gap: var(--phm-space-2, 8px);
}

.acbCheckboxContainer label {
    margin-bottom: 0;
    font-size: 0.9rem;
    color: var(--phm-text, #111827);
    cursor: pointer;
    user-select: none;
}

.acbCheckbox {
    width: 18px;
    height: 18px;
    accent-color: var(--phm-accent, #6366f1);
    cursor: pointer;
}

.acbCheckbox[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
}

#acbCriticalCheckbox:hover {
    cursor: not-allowed;
}

#acb-content div.checker.disabled span.checked {
    background-position: -15px -257px;
}

/* ============================================================
   Responsive : banner cookie
   ============================================================ */
@media screen and (min-width: 768px) {
    #acb-banner.acb-gdpr {
        flex-direction: column;
        align-items: stretch;
    }
    #acb-banner.acb-gdpr #acb-action {
        display: flex;
        justify-content: center;
        width: 100%;
        margin-top: var(--phm-space-4, 16px);
    }
    #acb-banner.acb-gdpr .acb-button {
        padding: 10px var(--phm-space-6, 24px);
        margin: 0;
    }
}

@media screen and (max-width: 767px) {
    #acb-banner.acb-position-bottom { top: auto; bottom: 0; }
    #acb-banner.acb-position-top    { top: 0; bottom: auto; }

    #acb-banner {
        max-height: 90vh;
        margin: 0;
        width: 100% !important;
        padding: var(--phm-space-4, 16px);
        flex-direction: column;
        align-items: stretch;
        gap: var(--phm-space-3, 12px);
        overflow: auto;
    }
    #acb-content {
        font-size: 0.9rem;
    }
    .acb_link_information_container {
        margin: var(--phm-space-2, 8px) 0;
        padding: var(--phm-space-2, 8px) 0;
        border-width: 1px 0;
        border-style: solid;
        border-color: var(--phm-border, #e5e7eb);
    }
    .acbCheckboxesContainer {
        flex-direction: column;
        gap: var(--phm-space-2, 8px);
    }
    #acb-banner.acb-gdpr .acb-button {
        width: 100%;
        margin: 0;
    }
    #acb-action {
        flex-direction: column;
        gap: var(--phm-space-2, 8px);
    }

    /* Profile menu en mobile : prend toute la largeur */
    #profile_menu {
        position: fixed;
        top: 60px;
        left: var(--phm-space-2, 8px);
        right: var(--phm-space-2, 8px);
        min-width: 0;
        max-width: none;
    }
}

@media screen and (min-width: 576px) and (max-width: 767px) and (orientation: landscape) {
    #acb-banner.acb-gdpr {
        width: 95vw !important;
    }
    #acb-banner.acb-gdpr .acb-button {
        width: initial;
    }
    #acb-banner.acb-gdpr #acb-action {
        display: flex;
        justify-content: space-between;
        width: 83.33%;
    }
}

@media screen and (min-width: 768px) and (max-width: 991px) {
    #acb-banner.acb-gdpr .acb-button {
        padding: 10px var(--phm-space-3, 12px);
    }
}

@media screen and (min-width: 768px) and (max-width: 991px) and (orientation: landscape) {
    #acb-banner.acb-gdpr .acb-button {
        padding: 10px var(--phm-space-4, 16px);
    }
}

@media screen and (max-width: 575px) and (orientation: landscape) {
    #acb-banner.acb-gdpr { width: 95vw !important; }
    #acb-banner.acb-gdpr .acb-button { width: initial; }
    #acb-banner.acb-gdpr #acb-action {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }
}
