/* ── App shell: header + sidebar (desktop) + bottom nav (móvil) ────────────── */

/* Header */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--green);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    z-index: 200;
    box-shadow: var(--shadow);
}

.app-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    flex: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-menu {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    width: var(--touch);
    height: var(--touch);
}
.btn-menu span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s;
}

.btn-lang {
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.4);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    min-width: var(--touch);
    height: 32px;
}
.btn-lang:hover { background: rgba(255,255,255,.3); }

.user-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
.user-role-badge {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(255,255,255,.2);
    font-weight: 600;
}
.user-role-badge[data-rol="superadmin"] { background: rgba(244,162,97,.5); }
.user-role-badge[data-rol="admin"]      { background: rgba(82,183,136,.4); }

.btn-icon {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    width: var(--touch);
    height: var(--touch);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.btn-icon:hover { background: rgba(255,255,255,.15); }

/* ── Sidebar (desktop ≥ 768px) ─────────────────────────────────────────────── */
.app-nav {
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    left: 0;
    width: var(--nav-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    z-index: 100;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
    min-height: var(--touch);
}
.nav-item:hover { background: var(--bg); color: var(--green); }
.nav-item.active {
    background: var(--green-xlt);
    color: var(--green);
    font-weight: 600;
    border-right: 3px solid var(--green);
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }

.nav-item-new .nav-icon {
    background: var(--green);
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* Contenido principal */
.app-content {
    margin-top: var(--header-h);
    margin-left: var(--nav-w);
    padding: 24px;
    min-height: calc(100dvh - var(--header-h));
}

/* ── Móvil (< 768px): bottom nav, ocultar sidebar ──────────────────────────── */
@media (max-width: 767px) {
    .app-nav {
        top: auto;
        bottom: 0;
        left: 0; right: 0;
        width: 100%;
        height: var(--nav-h);
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 0;
        overflow: visible;
        transform: translateY(0);
    }

    .app-nav .nav-item {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        padding: 6px 4px;
        gap: 2px;
        font-size: 11px;
        min-height: var(--nav-h);
        border-right: none;
    }
    .app-nav .nav-item.active { border-right: none; border-top: 3px solid var(--green); }
    .nav-icon { width: auto; font-size: 20px; }

    .app-content {
        margin-left: 0;
        padding: 16px;
        padding-bottom: calc(var(--nav-h) + 16px);
    }

    .btn-menu { display: none; }

    /* En móvil el user-chip se esconde para ahorrar espacio */
    .user-chip { display: none; }
}

/* Desktop grande: ocultar hamburguesa (sidebar siempre visible) */
@media (min-width: 901px) {
    .btn-menu { display: none; }
}

/* Tablet (768–900px): hamburguesa colapsa el sidebar */
@media (max-width: 900px) and (min-width: 768px) {
    .btn-menu { display: flex; }
    .app-nav {
        transform: translateX(-100%);
        transition: transform .25s;
    }
    .app-nav.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .app-content { margin-left: 0; }
}
