:root {
    --ec-sidebar-width: 272px;
    --ec-mobile-header-height: 72px;
}

html,
body {
    min-height: 100%;
}

/* "clip" y no "hidden": así <body> no se convierte en contenedor de scroll y el navegador del móvil puede
   ocultar su barra al desplazarse. */
html,
body.ec-authenticated {
    overflow-x: clip;
}

.ec-layout,
.ec-content-shell {
    min-height: 100vh;
}

.ec-content-shell {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.ec-main {
    position: relative;
    min-width: 0;
    flex: 1;
}

.ec-mobile-header {
    position: sticky;
    z-index: 1030;
    top: 0;
    display: grid;
    height: var(--ec-mobile-header-height);
    grid-template-columns: 44px 1fr 40px;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--dashboard-border, var(--quaternary));
    background: var(--surface);
    box-shadow: 0 5px 20px rgb(0 61 80 / 0.06);
}

.ec-menu-toggle,
.ec-sidebar-close,
.ec-sidebar-overlay {
    border: 0;
}

.ec-menu-toggle,
.ec-sidebar-close {
    display: grid;
    width: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    border-radius: 11px;
    background: transparent;
    color: var(--primary);
    font-size: 1.05rem;
}

.ec-menu-toggle:hover,
.ec-menu-toggle:focus-visible,
.ec-sidebar-close:hover,
.ec-sidebar-close:focus-visible {
    background: var(--tertiary);
}

.ec-mobile-brand {
    display: inline-flex;
    width: fit-content;
    height: 52px;
    align-items: center;
    justify-self: start;
}

.ec-mobile-brand img {
    width: 124px;
    max-width: 100%;
    height: auto;
    max-height: 44px;
    object-fit: contain;
}

.ec-mobile-avatar,
.ec-sidebar-avatar {
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-weight: var(--font-weight-bold);
}

.ec-mobile-avatar {
    width: 38px;
    height: 38px;
    background: var(--primary);
    color: var(--secondary);
    font-size: 0.78rem;
}

.ec-sidebar {
    position: fixed;
    z-index: 1050;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    width: min(86vw, var(--ec-sidebar-width));
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--dashboard-border, var(--quaternary));
    background: var(--surface);
    box-shadow: 16px 0 40px rgb(0 44 58 / 0.18);
    transform: translateX(-105%);
    transition: transform 0.24s ease;
}

.ec-sidebar-open {
    overflow: hidden;
}

.ec-sidebar-open .ec-sidebar {
    transform: translateX(0);
}

.ec-sidebar-header {
    display: flex;
    min-height: 82px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--dashboard-border, var(--quaternary));
}

.ec-sidebar-brand {
    display: inline-flex;
    min-height: 54px;
    align-items: center;
}

.ec-sidebar-brand img {
    width: 140px;
}

.ec-sidebar-nav {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    padding: 16px 12px 24px;
    scrollbar-color: var(--quaternary) transparent;
    scrollbar-width: thin;
}

.ec-nav-label {
    margin: 20px 10px 6px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.ec-nav-label:first-child {
    margin-top: 0;
}

.ec-nav-link {
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: 12px;
    padding: 10px 13px;
    border-radius: 11px;
    color: var(--primary);
    font-size: 0.84rem;
    font-weight: var(--font-weight-medium);
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.ec-nav-link :is(.fas, .fab, .far) {
    width: 19px;
    color: var(--accent);
    font-size: 0.95rem;
}

.ec-nav-link:hover,
.ec-nav-link:focus-visible {
    background: var(--surface-soft);
    color: var(--primary);
    transform: translateX(2px);
}

.ec-nav-link.active {
    background: var(--primary);
    color: var(--secondary);
    box-shadow: 0 7px 18px rgb(0 61 80 / 0.16);
}

.ec-nav-link.active :is(.fas, .fab, .far) {
    color: var(--secondary);
}

.ec-sidebar-account {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 38px;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--dashboard-border, var(--quaternary));
    background: var(--surface-soft);
}

.ec-sidebar-preferences {
    padding: 8px 12px;
    border-top: 1px solid var(--dashboard-border, var(--quaternary));
    background: var(--surface);
}

.ec-sidebar-avatar {
    width: 42px;
    height: 42px;
    background: var(--primary);
    color: var(--secondary);
    font-size: 0.78rem;
}

.ec-sidebar-user {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.ec-sidebar-user small {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.ec-sidebar-user strong {
    overflow: hidden;
    color: var(--primary);
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ec-sidebar-logout {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 10px;
    color: var(--primary);
}

.ec-sidebar-logout:hover,
.ec-sidebar-logout:focus-visible {
    background: var(--tertiary);
    color: var(--primary);
}

.ec-sidebar-overlay {
    position: fixed;
    z-index: 1040;
    inset: 0;
    display: block;
    visibility: hidden;
    padding: 0;
    background: rgb(0 32 42 / 0.46);
    opacity: 0;
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.ec-sidebar-open .ec-sidebar-overlay {
    visibility: visible;
    opacity: 1;
}

.ec-content-shell > .footer {
    min-height: 44px;
    margin-top: auto;
}

.ec-guest-header {
    display: flex;
    min-height: 72px;
    align-items: center;
    padding: 8px 3%;
    background: var(--primary);
}

.ec-guest-header img {
    width: 75px;
}

.ec-guest-header .ec-theme-setting {
    width: min(260px, calc(100% - 96px));
    margin-left: auto;
    padding: 2px 6px;
    border-radius: 12px;
    background: var(--surface);
}

@media (min-width: 992px) {
    body.ec-authenticated {
        padding-left: var(--ec-sidebar-width);
    }

    .ec-mobile-header {
        display: none;
    }

    .ec-sidebar {
        width: var(--ec-sidebar-width);
        box-shadow: none;
        transform: none;
        transition: none;
    }

    .ec-sidebar-close,
    .ec-sidebar-overlay {
        display: none;
    }

    .ec-sidebar-header {
        min-height: 92px;
        justify-content: center;
        padding: 16px 22px;
    }

    .ec-sidebar-brand img {
        width: 140px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ec-sidebar,
    .ec-sidebar-overlay,
    .ec-nav-link {
        transition: none;
    }
}

/* EbeneCenter mobile app shell */
:root {
    --ec-bottom-nav-height: 66px;
    --ec-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ec-ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

html {
    overscroll-behavior-y: none;
}

.ec-layout,
.ec-content-shell {
    min-height: 100dvh;
}

.ec-mobile-header {
    height: calc(var(--ec-mobile-header-height) + env(safe-area-inset-top, 0px));
    padding: calc(8px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
}

.ec-menu-toggle,
.ec-sidebar-close,
.ec-nav-link,
.ec-sidebar-logout,
.ec-bottom-nav__item {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.ec-sidebar {
    overscroll-behavior: contain;
    transition: transform 260ms var(--ec-ease-drawer);
}

.ec-sidebar-nav {
    overscroll-behavior: contain;
}

.ec-nav-link:active {
    transform: scale(0.98);
}

.ec-sidebar-logout {
    width: 44px;
    height: 44px;
}

.ec-bottom-nav {
    position: fixed;
    z-index: 1025;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    min-height: calc(var(--ec-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 2px;
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    background: var(--surface);
    box-shadow: 0 -10px 30px rgb(0 44 58 / 0.11);
}

/*
 * La barra se ancla al borde inferior con `bottom: 0`, sin `top` ni `transform` con `100dvh`: iOS no recalcula
 * `dvh` hasta que termina el scroll y, con ese anclaje (v1.19.0), la barra se quedaba a media pantalla al hacer scroll
 * rápido. Las transiciones entre páginas siguen solo en escritorio (app-shell.css), que era lo que la desplazaba.
 */

.ec-bottom-nav__item {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border-radius: 11px;
    color: var(--text-muted);
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.78rem;
    font-weight: var(--font-weight-medium);
    line-height: 1.1;
    text-decoration: none;
    transition: transform 140ms var(--ec-ease-out), background-color 160ms ease, color 160ms ease;
}

.ec-bottom-nav__item :is(.fas, .fab, .far) {
    width: 20px;
    height: 20px;
    font-size: 1.08rem;
}

.ec-bottom-nav__item.active {
    background: var(--surface-soft);
    color: var(--primary);
    font-weight: var(--font-weight-bold);
}

.ec-bottom-nav__item.active::before {
    position: absolute;
    top: 0;
    width: 24px;
    height: 2px;
    border-radius: 999px;
    background: var(--accent);
    content: "";
}

.ec-bottom-nav__item:active {
    transform: scale(0.96);
}

.ec-bottom-nav__item:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 36%, transparent);
    outline-offset: -2px;
}

/* El hueco de la barra inferior va en el body para que también el pie quede por encima de ella. */
body.ec-authenticated {
    padding-bottom: calc(var(--ec-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
}

@media (hover: none), (pointer: coarse) {
    .ec-menu-toggle:hover,
    .ec-sidebar-close:hover,
    .ec-sidebar-logout:hover {
        background: transparent;
    }

    .ec-nav-link:hover {
        background: transparent;
        color: var(--primary);
        transform: none;
    }

    .ec-nav-link.active:hover {
        background: var(--primary);
        color: var(--secondary);
    }
}

@media (min-width: 992px) {
    body.ec-authenticated {
        padding-bottom: 0;
    }

    .ec-bottom-nav {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ec-sidebar,
    .ec-sidebar-overlay,
    .ec-nav-link,
    .ec-bottom-nav__item {
        transition: background-color 100ms linear, color 100ms linear;
    }

    .ec-nav-link:active,
    .ec-bottom-nav__item:active {
        transform: none;
    }
}

/* Pie de la zona privada: discreto y sin barra de color; en móvil queda por encima de la barra inferior. */
body.ec-authenticated > .footer {
    min-height: 0;
    padding: 18px 16px 22px;
    border-top: 1px solid var(--ec-line-soft);
    background: transparent;
}

body.ec-authenticated > .footer .ec-footer__copy,
body.ec-authenticated > .footer .ec-footer__copy > span {
    display: inline;
    color: var(--ec-text-secondary);
    font-size: 0.78rem;
    font-weight: var(--font-weight-medium);
    line-height: 1.5;
}

/* Avatar de la cabecera móvil: lleva al perfil. */
.ec-mobile-avatar {
    justify-self: end;
    text-decoration: none;
}

.ec-mobile-avatar:hover,
.ec-mobile-avatar:focus-visible {
    color: var(--secondary);
    outline-offset: 3px;
}
