/* =========================================================
   ArabicLearn - Topbar responsive
   Ce fichier doit être chargé après layout.css
   ========================================================= */


/* =========================================================
   Structure générale - ordinateur
   ========================================================= */

.app-topbar {
    /*
    position: sticky;
    top: 0;
    z-index: 4000;

    width: 100%;
    min-height: 0 !important;
    padding: 12px 18px;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap !important;

    overflow: visible;

    background: #f7fbff;
    border: 1px solid #dbe7f0;
    border-radius: 0 0 22px 22px;
    box-shadow: 0 8px 24px rgba(31, 60, 90, 0.12);
    */
    position: sticky;
    top: 0;
    z-index: 4000;

    width: 100%;
    max-width: none;
    min-width: 0;

    margin: 0;
    padding: 12px 18px;
    box-sizing: border-box;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;

    overflow: visible;

    background: #f7fbff;
    border: 1px solid #dbe7f0;
    border-radius: 0 0 22px 22px;
    box-shadow: 0 8px 24px rgba(31, 60, 90, 0.12);
}

.topbar-head {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: center;
}

.app-navigation {
    position: static;

    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}


/* =========================================================
   Logo
   ========================================================= */

.app-topbar .brand-area {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    margin: 0;
    padding: 0;

    color: #102b56;
    text-decoration: none !important;
}

.app-topbar .brand-area:hover,
.app-topbar .brand-area:focus,
.app-topbar .brand-area:active {
    text-decoration: none !important;
}

.app-topbar .brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-topbar .brand-logo img {
    display: block;

    width: 52px;
    height: 52px;

    object-fit: contain;
}

.app-topbar .brand-text {
    display: inline-flex;
    align-items: baseline;

    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
}

.app-topbar .brand-text-main {
    color: #102b56;
}

.app-topbar .brand-text-accent {
    color: #20aaa9;
}


/* =========================================================
   Menu principal
   ========================================================= */

.app-topbar .child-main-nav {
    width: 100%;

    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;

    margin: 0 !important;
    padding: 0 !important;

    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.app-topbar .nav-pill {
    min-height: 54px;
    padding: 12px 18px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;

    border: 1px solid #d8e4ed;
    border-radius: 15px;

    background: #ffffff;
    color: #102b56;

    font-weight: 900;
    text-decoration: none !important;

    box-shadow: 0 5px 14px rgba(31, 60, 90, 0.10);

    transition:
        transform 0.12s ease,
        background 0.12s ease,
        border-color 0.12s ease,
        box-shadow 0.12s ease;
}

.app-topbar .nav-pill:hover {
    transform: translateY(-2px);

    border-color: #afd6df;
    background: #eefafa;
    color: #102b56;

    box-shadow: 0 8px 18px rgba(31, 60, 90, 0.14);
}

.app-topbar .nav-pill.active {
    border-color: #20aaa9;
    background: #20aaa9;
    color: #ffffff;
}

.app-topbar .nav-disabled {
    opacity: 0.52;
    pointer-events: none;
}

.app-topbar .nav-icon {
    font-size: 1rem;
}


/* =========================================================
   Actions inférieures
   ========================================================= */

.app-topbar .topbar-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;

    margin: 0;
}

.app-topbar .help-link,
.app-topbar .profile-chip,
.app-topbar .admin-button {
    min-height: 40px;
    padding: 7px 10px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    border: none;
    border-radius: 12px;

    background: transparent;
    color: #657286;

    font: inherit;
    font-weight: 800;
    text-decoration: none !important;

    cursor: pointer;
}

.app-topbar .help-link:hover,
.app-topbar .profile-chip:hover,
.app-topbar .admin-button:hover {
    background: #eef5fa;
    color: #102b56;
}

.app-topbar .help-icon {
    width: 28px;
    height: 28px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 2px solid #93a6b9;
    border-radius: 50%;

    font-weight: 900;
}

.app-topbar .profile-chip {
    background: #eaf5ff;
}

.app-topbar .profile-avatar {
    font-size: 1.25rem;
}

.app-topbar .profile-arrow {
    font-size: 0.7rem;
}

.app-topbar .topbar-separator {
    width: 1px;
    height: 26px;

    background: #d8e4ed;
}


/* =========================================================
   Menu Admin - ordinateur
   ========================================================= */

.app-topbar .admin-dropdown {
    position: relative;

    margin: -8px 0;
    padding: 8px 0;
}

.app-topbar .admin-dropdown-content {
    display: none;

    position: absolute;
    top: 100%;
    right: 0;
    z-index: 4100;

    min-width: 230px;
    padding: 8px;

    background: #ffffff;
    border: 1px solid #dbe7f0;
    border-radius: 15px;
    box-shadow: 0 14px 32px rgba(31, 60, 90, 0.20);
}

.app-topbar .admin-dropdown:hover .admin-dropdown-content,
.app-topbar .admin-dropdown:focus-within .admin-dropdown-content,
.app-topbar .admin-dropdown.is-open .admin-dropdown-content {
    display: block;
}

.app-topbar .admin-dropdown-content a {
    display: block;

    padding: 10px 12px;

    border-radius: 10px;

    color: #102b56;
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none !important;
}

.app-topbar .admin-dropdown-content a:hover {
    background: #eefafa;
    color: #102b56;
}


/* =========================================================
   Bouton hamburger
   ========================================================= */

.mobile-nav-toggle {
    display: none;
}


/* =========================================================
   Tablette et téléphone
   ========================================================= */

@media (max-width: 1280px) {

    .app-topbar {
        position: sticky;
        top: 0;

        display: block;

        min-height: 62px !important;
        padding: 7px 12px;

        border-radius: 0 0 17px 17px;
    }

    .topbar-head {
        min-height: 48px;

        justify-content: space-between;
        gap: 12px;
    }

    .app-topbar .brand-area {
        justify-content: flex-start;
        gap: 8px;
    }

    .app-topbar .brand-logo img {
        width: 42px;
        height: 42px;
    }

    .app-topbar .brand-text {
        font-size: 1.55rem;
    }

    .mobile-nav-toggle {
        flex: 0 0 auto;

        width: 44px;
        height: 44px;

        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;

        padding: 0;

        border: 1px solid #d5e3ec;
        border-radius: 13px;

        background: #ffffff;
        cursor: pointer;

        box-shadow: 0 4px 12px rgba(31, 60, 90, 0.10);
    }

    .mobile-nav-toggle span {
        width: 21px;
        height: 2px;

        display: block;

        border-radius: 999px;
        background: #102b56;

        transition:
            transform 0.18s ease,
            opacity 0.18s ease;
    }

    .app-topbar.is-open .mobile-nav-toggle span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .app-topbar.is-open .mobile-nav-toggle span:nth-child(2) {
        opacity: 0;
    }

    .app-topbar.is-open .mobile-nav-toggle span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /*
     * Le menu devient un panneau flottant.
     * Il ne pousse donc plus la page vers le bas.
     */
    .app-navigation {
        display: none;

        position: absolute;
        top: calc(100% + 6px);
        left: 8px;
        right: 8px;
        z-index: 4050;

        width: auto;
        max-height: calc(100vh - 84px);
        max-height: calc(100dvh - 84px);
        padding: 12px;

        overflow-y: auto;

        background: #f7fbff;
        border: 1px solid #dbe7f0;
        border-radius: 17px;
        box-shadow: 0 16px 36px rgba(31, 60, 90, 0.24);
    }

    .app-topbar.is-open .app-navigation {
        display: block;
    }

    .app-topbar .child-main-nav {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;

        width: 100%;
    }

    .app-topbar .nav-pill {
        min-width: 0;
        min-height: 46px;
        padding: 9px 11px;

        justify-content: flex-start;

        border-radius: 12px;

        font-size: 0.92rem;
        box-shadow: none;
    }

    .app-topbar .nav-pill:hover {
        transform: none;
        box-shadow: none;
    }

    .app-topbar .topbar-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;

        width: 100%;
        margin-top: 10px;
        padding-top: 10px;

        border-top: 1px solid #dbe7f0;
    }

    .app-topbar .help-link,
    .app-topbar .profile-chip,
    .app-topbar .admin-button {
        width: 100%;
        min-height: 42px;
        padding: 8px;

        background: #ffffff;
        border: 1px solid #dbe7f0;
    }

    .app-topbar .topbar-separator {
        display: none;
    }

    /*
     * La section Admin prend toute la largeur.
     */
    .app-topbar .admin-dropdown {
        position: static;
        grid-column: 1 / -1;

        width: 100%;
        margin: 0;
        padding: 0;
    }

    .app-topbar .admin-dropdown-content {
        display: none;

        position: static;

        min-width: 0;
        width: 100%;
        margin-top: 8px;
        padding: 8px;

        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;

        box-shadow: none;
    }

    /*
     * Sur écran tactile, l’ouverture est contrôlée
     * par la classe is-open ajoutée en JavaScript.
     */
    .app-topbar .admin-dropdown:hover .admin-dropdown-content {
        display: none;
    }

    .app-topbar .admin-dropdown.is-open .admin-dropdown-content {
        display: grid;
    }

    .app-topbar .admin-dropdown-content a {
        border: 1px solid #e3ebf2;
        background: #f9fcff;
    }
}


/* =========================================================
   Téléphone
   ========================================================= */

@media (max-width: 650px) {

    .app-topbar {
        padding: 6px 9px;
    }

    .app-topbar .brand-logo img {
        width: 38px;
        height: 38px;
    }

    .app-topbar .brand-text {
        font-size: 1.35rem;
    }

    .app-navigation {
        left: 6px;
        right: 6px;
        padding: 10px;
    }

    .app-topbar .child-main-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .app-topbar .nav-pill {
        font-size: 0.88rem;
    }

    .app-topbar .topbar-actions {
        grid-template-columns: 1fr 1fr;
    }

    .app-topbar .admin-dropdown-content {
        grid-template-columns: 1fr;
    }
}


/* =========================================================
   Très petit téléphone
   ========================================================= */

@media (max-width: 390px) {

    .app-topbar .brand-text {
        font-size: 1.2rem;
    }

    .app-topbar .child-main-nav {
        grid-template-columns: 1fr;
    }

    .app-topbar .topbar-actions {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   Ordinateur : topbar compacte pleine largeur
   ========================================================= */

@media (min-width: 1281px) {

    .app-topbar {
        width: 100%;
        max-width: none;
        min-width: 0;

        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 14px;

        min-height: 68px !important;
        padding: 8px 14px;

        border-radius: 0 0 18px 18px;
        box-sizing: border-box;
    }

    .topbar-head {
        width: auto;
        min-width: max-content;

        display: flex;
        align-items: center;
        justify-content: flex-start;
    }

    .app-topbar .brand-area {
        gap: 7px;
    }

    .app-topbar .brand-logo img {
        width: 42px;
        height: 42px;
    }

    .app-topbar .brand-text {
        font-size: 1.5rem;
    }

    .app-navigation {
        position: static;

        width: 100%;
        min-width: 0;
        max-width: 100%;

        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
    }

    .app-topbar .child-main-nav {
        width: 100%;
        min-width: 0;
        max-width: 100%;

        display: flex !important;
        align-items: center;
        justify-content: center;
        flex-wrap: nowrap;
        gap: 6px;

        overflow: hidden;
    }

    .app-topbar .nav-pill {
        flex: 0 1 auto;
        min-width: 0;
        min-height: 42px;

        padding: 8px 9px;
        gap: 5px;

        border-radius: 12px;

        font-size: 0.88rem;
        white-space: nowrap;

        box-shadow: 0 3px 10px rgba(31, 60, 90, 0.09);
    }

    .app-topbar .nav-icon {
        flex: 0 0 auto;
        font-size: 0.9rem;
    }

    .app-topbar .topbar-actions {
        min-width: max-content;

        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 4px;
    }

    .app-topbar .help-link,
    .app-topbar .profile-chip,
    .app-topbar .admin-button {
        min-height: 36px;
        padding: 5px 6px;

        border-radius: 10px;
        font-size: 0.86rem;
    }

    .app-topbar .help-icon {
        width: 24px;
        height: 24px;
    }

    .app-topbar .profile-avatar {
        font-size: 1.1rem;
    }

    .app-topbar .topbar-separator {
        height: 22px;
        margin: 0 1px;
    }

    .mobile-nav-toggle {
        display: none !important;
    }
}

/* =========================================================
   Accès Admin discret
   Hors navigation publique principale
   ========================================================= */

.global-admin-link {
    position: fixed;
    right: 14px;
    bottom: 12px;
    z-index: 3000;

    display: inline-flex;
    align-items: center;
    gap: 5px;

    padding: 6px 9px;

    border: 1px solid rgba(155, 172, 188, 0.55);
    border-radius: 10px;

    background: rgba(255, 255, 255, 0.88);
    color: #647488 !important;

    font-size: 0.76rem;
    font-weight: 800;

    text-decoration: none !important;

    opacity: 0.48;

    backdrop-filter: blur(6px);

    transition:
        opacity 0.15s ease,
        border-color 0.15s ease,
        background 0.15s ease;
}

.global-admin-link:hover,
.global-admin-link:focus {
    opacity: 1;

    border-color: #afd6df;

    background: #ffffff;
    color: #102b56 !important;
}

@media (max-width: 520px) {
    .global-admin-link {
        right: 8px;
        bottom: 8px;

        padding: 5px 7px;

        font-size: 0.72rem;
    }
}
