/* =====================================================================
   Alena LMS — shell: cabecera, navegación, drawer móvil, barra inferior
   ===================================================================== */
.app-header, header.site-header {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; justify-content: flex-start; flex-wrap: nowrap; gap: 0.9rem;
    height: 56px; padding: 0 1.25rem;
}
.app-header {
    background: linear-gradient(135deg, var(--ink), var(--ink-2));
    color: var(--ink-text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 14px rgba(11, 31, 36, 0.28);
}
header.site-header { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-xs); position: sticky; }
.app-header .brand, header.site-header .brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; letter-spacing: -0.01em; min-width: 0; flex-shrink: 0; }
.app-header .brand { color: #fff; }
header.site-header .brand { color: var(--text); }
.brand-mark {
    width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
    background: var(--brand-gradient); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 0.95rem;
    box-shadow: 0 4px 10px -4px rgba(15, 175, 154, 0.7);
}
.brand-logo { height: 30px; width: auto; max-width: 110px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px; }
.brand-name { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.brand-accent { background: linear-gradient(135deg, var(--brand-500), var(--brand-300)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.app-nav { display: flex; align-items: center; gap: 0.15rem; margin-left: auto; }
.app-nav > * { flex-shrink: 0; }

.nav-link, .nav-trigger {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.7rem; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 0.88rem; font-weight: 500; color: var(--ink-text);
    background: none; border: none; cursor: pointer; transition: var(--ease); line-height: 1.2; position: relative;
}
.nav-link svg, .nav-trigger > svg { width: 16px; height: 16px; opacity: 0.9; flex-shrink: 0; }
.nav-link:hover, .nav-trigger:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, 0.14); color: #fff; }
.nav-link.active::after { content: ""; position: absolute; left: 0.7rem; right: 0.7rem; bottom: 2px; height: 2px; border-radius: 2px; background: var(--brand-300); }
.nav-caret { width: 14px !important; height: 14px !important; transition: transform 0.2s ease; opacity: 0.7; }
.nav-dropdown { position: relative; }
.nav-dropdown.open .nav-caret { transform: rotate(180deg); }
.nav-menu {
    display: none; position: absolute; top: calc(100% + 10px); left: 0; z-index: 60; min-width: 230px;
    flex-direction: column; gap: 0.1rem; padding: 0.35rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
}
.nav-menu::before { content: ""; position: absolute; top: -6px; left: 22px; width: 10px; height: 10px; background: var(--surface); border-left: 1px solid var(--border); border-top: 1px solid var(--border); transform: rotate(45deg); }
.nav-dropdown.open .nav-menu { display: flex; animation: menuIn 0.16s ease; }
.nav-dropdown.align-right .nav-menu { left: auto; right: 0; }
.nav-dropdown.align-right .nav-menu::before { left: auto; right: 22px; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.nav-menu-item {
    display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-family: inherit; font-size: 0.88rem; font-weight: 500; text-align: left;
    background: none; border: none; cursor: pointer; transition: var(--ease);
}
.nav-menu-item svg { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }
.nav-menu-item:hover { background: var(--brand-50); color: var(--brand-800); }
.nav-menu-item:hover svg { color: var(--brand-600); }
.nav-menu-item.active { background: var(--brand-100); color: var(--brand-800); font-weight: 600; }
.nav-menu-item.active svg { color: var(--brand-700); }
.nav-logout { margin: 0.25rem 0 0; padding-top: 0.25rem; border-top: 1px solid var(--border); }

/* Cabecera clara (tienda / estudiante) */
header.site-header .nav-link { color: var(--text-secondary); }
header.site-header .nav-link:hover { background: var(--brand-50); color: var(--brand-800); }
header.site-header .nav-link.active { background: var(--brand-100); color: var(--brand-800); }
header.site-header .nav-link.active::after { background: var(--brand-500); }
header.site-header .nav-logout { border: none; margin: 0; padding: 0; }
header.site-header .nav-logout .nav-link { color: var(--danger-ink); }
header.site-header .nav-logout .nav-link:hover { background: var(--danger-soft); }

.header-burger, .drawer-close {
    display: none; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0;
    border-radius: var(--radius-sm); cursor: pointer; transition: var(--ease); font-family: inherit;
    background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16); color: #fff;
}
header.site-header .header-burger { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.header-burger svg, .drawer-close svg { width: 20px; height: 20px; }
.header-burger:hover { background: rgba(255, 255, 255, 0.18); }

/* Drawer offcanvas + barra inferior: solo móvil */
.drawer-backdrop, .app-drawer, .bottom-nav { display: none; }

@media (max-width: 860px) {
    .app-header, header.site-header { padding: 0 0.85rem; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
    .header-burger { display: inline-flex; }
    .header-burger ~ .app-nav { display: none; }
    .brand-name { max-width: 60vw; }

    .drawer-backdrop {
        display: block; position: fixed; inset: 0; z-index: 80; background: rgba(11, 31, 36, 0.55); backdrop-filter: blur(2px);
        opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0.25s;
    }
    .drawer-backdrop.open { opacity: 1; visibility: visible; }
    .app-drawer {
        display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 90;
        width: min(86vw, 330px); background: var(--surface); box-shadow: var(--shadow-lg);
        transform: translateX(-104%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    }
    .app-drawer.open { transform: none; }
    .drawer-head {
        display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 0.5rem;
        padding: env(safe-area-inset-top) 0.9rem 0; height: calc(56px + env(safe-area-inset-top));
        background: linear-gradient(135deg, var(--ink), var(--ink-2)); color: #fff;
    }
    .drawer-title { font-weight: 700; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .drawer-close { display: inline-flex; }
    .drawer-nav { flex: 1; overflow-y: auto; padding: 0.6rem; display: flex; flex-direction: column; gap: 0.15rem; }
    .drawer-link {
        display: flex; align-items: center; gap: 0.75rem; width: 100%; min-height: 46px; padding: 0.55rem 0.8rem;
        border-radius: 10px; color: var(--text); font-family: inherit; font-size: 0.95rem; font-weight: 500; text-align: left;
        background: none; border: none; cursor: pointer; transition: var(--ease);
    }
    .drawer-link svg { width: 19px; height: 19px; color: var(--text-tertiary); flex-shrink: 0; }
    .drawer-link .nav-caret { margin-left: auto; }
    .drawer-link:hover { background: var(--brand-50); }
    .drawer-link.active { background: var(--brand-100); color: var(--brand-800); font-weight: 600; }
    .drawer-link.active svg { color: var(--brand-700); }
    .drawer-group.open > .drawer-trigger .nav-caret { transform: rotate(180deg); }
    .drawer-sub { display: none; flex-direction: column; margin: 0.1rem 0 0.35rem 1.35rem; padding-left: 0.6rem; border-left: 2px solid var(--border); }
    .drawer-group.open .drawer-sub { display: flex; }
    .drawer-sublink {
        display: flex; align-items: center; gap: 0.6rem; width: 100%; min-height: 44px; padding: 0.5rem 0.7rem; border-radius: var(--radius-sm);
        color: var(--text-secondary); font-family: inherit; font-size: 0.9rem; font-weight: 500; background: none; border: none; text-align: left; cursor: pointer;
    }
    .drawer-sublink svg { width: 17px; height: 17px; color: var(--text-tertiary); }
    .drawer-sublink:hover { background: var(--brand-50); }
    .drawer-sublink.active { background: var(--brand-100); color: var(--brand-800); font-weight: 600; }
    .drawer-nav .nav-logout { border: none; padding: 0; margin: 0; }
    .drawer-nav .nav-logout .drawer-link, .drawer-nav .nav-logout .drawer-sublink { color: var(--danger-ink); }
    body.no-scroll { overflow: hidden; }

    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
        background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(15, 27, 45, 0.08);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .bottom-link {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        min-height: 58px; padding: 0.35rem 0.2rem; position: relative;
        font-family: inherit; font-size: 0.68rem; font-weight: 600; color: var(--text-tertiary);
        background: none; border: none; cursor: pointer; transition: var(--ease);
    }
    .bottom-link svg { width: 22px; height: 22px; }
    .bottom-link:active { background: var(--bg-secondary); }
    .bottom-link.active { color: var(--brand-700); }
    .bottom-link.active::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 4px 4px; background: var(--brand-gradient); }
    body.has-bottom-nav { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
    body.has-bottom-nav .cookie-banner { bottom: calc(68px + env(safe-area-inset-bottom)); }
}
