/* =============================================================================
   ESTILOS PARA AF APP MENU - SIDEBAR LATERAL
   Inspirado en KeepArmor, utilizando la paleta y tipografías del tema af-app-theme
   ============================================================================= */

:root {
    font-size: 16px;
}

.af-app-layout {
    min-height: 100vh;
    background-color: var(--af-bg-secondary, #f2f5f7);
    font-family: var(--af-font-body, "Open Sans", sans-serif);
}


.af-app-sidebar-container {
    background: #1c2536;
    color: var(--af-gray-50, #ffffff);
    padding: 2.5rem 1.75rem;
    display: flex;
    align-items: stretch;
}

.af-app-sidebar {
    width: 100%;
    font-family: var(--af-font-body, "Open Sans", sans-serif);
    display: flex;
    flex-direction: column;
}

.af-app-sidebar__inner {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: calc(100vh - 5rem);
    gap: 2rem;
}

.af-app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.af-app-sidebar__logo img {
    max-width: 40px;
    height: auto;
    border-radius: 0;
    box-shadow: var(--af-shadow, 0 1px 3px rgba(0,0,0,0.18));
    background-color: rgba(255, 255, 255, 0.08);
    padding: 0.4rem;
}

.af-app-sidebar__placeholder-logo {
    width: 40px;
    height: 40px;
    border-radius: 0;
    background: rgba(255, 255, 255, 0.12);
    display: grid;
    place-items: center;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--af-gray-50, #ffffff);
}

.af-app-sidebar__title {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.af-app-sidebar__name {
    font-family: var(--af-font-heading, "Josefin Sans", sans-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--af-gray-50, #ffffff);
}

.af-app-sidebar__tagline {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.af-app-sidebar__menu {
    flex: 1;
    overflow-y: auto;
}

.af-app-sidebar__menu::-webkit-scrollbar {
    width: 6px;
}

.af-app-sidebar__menu::-webkit-scrollbar-track {
    background: transparent;
}

.af-app-sidebar__menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 0;
}

/* Reset básico */
.af-app-nav,
.af-app-subnav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.af-app-nav__item {
    margin-bottom: 0;
}

.af-app-nav__link {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap;
    gap: 0.65rem;
    padding: 0.55rem 0.85rem;
    color: rgba(255, 255, 255, 0.7) !important;
    text-decoration: none;
    border-radius: 0;
    position: relative;
    font-size: 0.95rem;
    transition: background 0.15s ease, color 0.15s ease;
    background: transparent;
}

/* Indicador de selección: absoluto para no afectar al layout */
.af-app-nav__link::before {
    display: none;
}

/* Flecha (caret) para items del menú (estilo gris del menú) */
.af-app-nav__item > .af-app-nav__link::after {
    content: "";
    margin-left: auto;
    border: solid rgba(255, 255, 255, 0.6);
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 4px;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
}

.af-app-nav__item.has-submenu.is-active > .af-app-nav__link::after,
.af-app-nav__item.has-submenu.open > .af-app-nav__link::after {
    transform: rotate(45deg);
}

.af-app-nav__link:hover,
.af-app-nav__item.is-active > .af-app-nav__link,
.af-app-nav__item.current-menu-item > .af-app-nav__link,
.af-app-nav__item > .af-app-nav__link.current {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff !important;
}

.af-app-nav__item.is-active > .af-app-nav__link::before,
.af-app-nav__item.current-menu-item > .af-app-nav__link::before,
.af-app-nav__item > .af-app-nav__link.current::before {
    background: rgba(9, 174, 184, 0.9);
}

/* ===== Bloqueo por vinculación: links disabled ===== */
.af-app-nav__item.is-disabled > .af-app-nav__link,
.af-app-nav__link.is-disabled,
.af-app-subnav__item.is-disabled > .af-app-subnav__link,
.af-app-subnav__link.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Evitar “highlight” al hover si está disabled */
.af-app-nav__item.is-disabled > .af-app-nav__link:hover,
.af-app-nav__link.is-disabled:hover,
.af-app-subnav__item.is-disabled > .af-app-subnav__link:hover,
.af-app-subnav__link.is-disabled:hover {
    background: transparent;
    color: rgba(255, 255, 255, 0.85) !important;
}

.af-app-nav__icon-wrapper {
    width: 26px;
    height: 26px;
    border-radius: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.af-app-nav__icon {
    font-size: 1.05rem;
    opacity: 0.9;
    display: inline-block;
    line-height: 1;
}

.af-app-nav__label {
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* (Deprecado) .af-app-nav__chevron ya no se renderiza en APP menu */

/* Submenús */
.af-app-subnav {
    margin-top: 0;
    margin-left: 1.6rem;
    border-left: none;
}

.af-app-subnav__item {
    margin-bottom: 0.2rem;
}

.af-app-subnav__link {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap;
    gap: 0.55rem;
    padding: 0.6rem 0.9rem;
    font-size: 0.98rem;
    color: rgba(255, 255, 255, 0.78) !important;
    text-decoration: none;
    border-radius: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.af-app-subnav__link:hover,
.af-app-subnav__item.is-active > .af-app-subnav__link,
.af-app-subnav__link.current {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff !important;
}

.af-app-subnav__icon-wrapper {
    width: 20px;
    height: 20px;
    border-radius: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.af-app-subnav__icon {
    font-size: 0.85rem;
    opacity: 0.8;
}

.af-app-sidebar__footer {
    margin-top: auto;
    padding-top: 1.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.af-app-user-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 0.85rem;
    border-radius: 0;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.92) !important;
    background: rgba(255, 255, 255, 0.06);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: none;
}

.af-app-user-link:hover,
.af-app-user-link:focus-visible {
    background: rgba(9, 174, 184, 0.22);
    color: #ffffff !important;
    transform: none;
    box-shadow: none;
    outline: none;
}

.af-app-user-link__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;  /* Avatar de cuenta: círculo (excepción al rectangular) */
    background: linear-gradient(140deg, rgba(9, 174, 184, 0.95) 0%, rgba(47, 128, 237, 0.95) 90%);
    display: grid;
    place-items: center;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 1.1rem;
}

.af-app-user-link__details {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    line-height: 1.25;
}

.af-app-user-link__name {
    font-weight: 600;
    font-size: 1.05rem;
    color: #ffffff;
}

.af-app-user-link__plan {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.af-app-user-link__chevron {
    margin-left: auto;
    width: 10px;
    height: 10px;
    border: solid rgba(255, 255, 255, 0.7);
    border-width: 0 2px 2px 0;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
}

.af-app-user-link:hover .af-app-user-link__chevron,
.af-app-user-link:focus-visible .af-app-user-link__chevron {
    transform: rotate(-45deg) translateX(2px);
}

/* Zona de contenido */
.af-app-content-area {
    padding: 2.5rem 3rem;
    background-color: var(--af-bg-secondary, #f7f8fa);
    box-shadow: none;
}

/* Submenús: colapsado animable (abre/cierra suave) */
.af-app-nav__item.has-submenu > .af-app-subnav {
    display: block; /* importante: no usar display:none si queremos animación */
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: max-height 240ms ease, opacity 180ms ease;
    will-change: max-height, opacity;
}

.af-app-nav__item.has-submenu.is-active > .af-app-subnav,
.af-app-nav__item.has-submenu.open > .af-app-subnav {
    max-height: 600px;
    opacity: 1;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .af-app-nav__item.has-submenu > .af-app-subnav {
        transition: none;
    }
}

/* Responsivo */
@media (max-width: 1024px) {
    .af-app-sidebar-container {
        padding: 2rem 1.25rem;
    }

    .af-app-content-area {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .af-app-layout {
        flex-direction: column;
    }

    .af-app-sidebar__inner {
        min-height: auto;
        flex: initial;
    }

    .af-app-content-area {
        padding: 1.5rem;
    }
}

/* ===== Mobile hamburger / off-canvas (AF App Menu) ===== */
.af-app-mobile-topbar,
.af-app-mobile-overlay {
    display: none;
}

@media (max-width: 768px) {
    :root { --af-mobile-topbar-h: 56px; }

    /* Topbar: una línea con el mismo fondo del sidebar */
    .af-app-sidebar-container {
        padding: 0;
        height: var(--af-mobile-topbar-h);
        align-items: center;
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .af-app-mobile-topbar {
        display: flex;
        width: 100%;
        height: 100%;
        align-items: center;
        justify-content: flex-start; /* cambia a center si lo quieres centrado */
        padding: 0 1rem;
    }

    .af-app-mobile-toggle {
        appearance: none;
        background: transparent;
        border: 0;
        padding: 0.5rem;
        cursor: pointer;
        color: #fff;
    }

    .af-app-mobile-toggle__icon {
        position: relative;
        display: block;
        width: 24px;
        height: 2px;
        background: rgba(255, 255, 255, 0.9);
    }

    .af-app-mobile-toggle__icon::before,
    .af-app-mobile-toggle__icon::after {
        content: "";
        position: absolute;
        left: 0;
        width: 24px;
        height: 2px;
        background: rgba(255, 255, 255, 0.9);
    }

    .af-app-mobile-toggle__icon::before { top: -7px; }
    .af-app-mobile-toggle__icon::after { top: 7px; }

    /* Sidebar como panel off-canvas */
    .af-app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(85vw, 320px);
        transform: translateX(-110%);
        transition: transform 0.25s ease;
        z-index: 1100;

        background: #1c2536;
        padding: 2.5rem 1.75rem;
        overflow-y: auto;
    }

    /* Overlay */
    .af-app-mobile-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 1050;
    }

    body.af-app-menu--open {
        overflow: hidden;
    }

    body.af-app-menu--open .af-app-sidebar {
        transform: translateX(0);
    }

    body.af-app-menu--open .af-app-mobile-overlay[data-af-menu="app"] {
        opacity: 1;
        pointer-events: auto;
    }
}
