/*
 * Layout compartido — header limpio + card de contenido (tablas, formularios)
 */

.lib-page-layout.main-content {
    margin-top: 0.5rem !important;
    border-radius: 12px !important;
    overflow: visible !important;
    box-shadow: none;
    background: transparent;
}

.lib-page-layout__container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0 !important;
    margin-top: 0 !important;
}

@media (min-width: 1200px) {
    .lib-page-layout__container {
        padding-left: 1.25rem !important;
        padding-right: 1.5rem !important;
    }

    .lib-page-layout.lib-table-fill {
        height: calc(100vh - 1.5rem);
        max-height: calc(100vh - 1.5rem);
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .lib-page-layout.lib-table-fill .lib-page-layout__container {
        flex: 1 1 auto;
        min-height: 0;
        height: 100%;
    }
}

.lib-page-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(13, 59, 102, 0.06);
    overflow: hidden;
    min-width: 0;
}

.lib-page-card--table {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.lib-page-card--form {
    overflow: visible;
}

.lib-page-card--form .lib-page-card__body {
    overflow: visible;
    padding: 20px 22px 24px;
}

.lib-page-card__body.lib-table-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

@media (max-width: 1199.98px) {
    .lib-page-layout.main-content {
        margin-top: 0 !important;
        border-radius: 0 !important;
    }

    .lib-page-layout__container {
        padding: 12px !important;
        gap: 14px;
    }

    .lib-page-layout.lib-table-fill {
        height: calc(100vh - var(--mobile-nav-height) - env(safe-area-inset-bottom, 0px));
        max-height: calc(100vh - var(--mobile-nav-height) - env(safe-area-inset-bottom, 0px));
        overflow: hidden;
    }

    .lib-page-card--form .lib-page-card__body {
        padding: 16px 14px 20px;
    }
}

/* Cabecera de página (mismo estilo que dashboard) */
.lib-page-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    width: 100%;
    height: 64px;
    min-height: 64px;
    padding: 0 22px 0 20px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(13, 59, 102, 0.06);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 1025;
    overflow: visible;
}

.lib-page-header__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #0d3b66 !important;
    white-space: nowrap;
}

.lib-page-header__user {
    position: relative;
    z-index: 2;
}

.lib-page-header__toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px 7px 7px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.lib-page-header__toggle:hover,
.lib-page-header__toggle:focus-visible {
    background: #f1f5f9;
    outline: none;
}

.lib-page-header__toggle[aria-expanded="true"] {
    background: #dbeafe;
    color: #0d3b66;
}

.lib-page-header__toggle[aria-expanded="true"] .lib-page-header__name,
.lib-page-header__toggle[aria-expanded="true"] .lib-page-header__avatar {
    color: #0d3b66;
}

.lib-page-header__toggle[aria-expanded="true"] .lib-page-header__chevron {
    border-top-color: #0d3b66;
    transform: rotate(180deg);
}

.lib-page-header__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #ffffff;
    color: #475569;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(13, 59, 102, 0.1);
}

.lib-page-header__name {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #475569;
    white-space: nowrap;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-page-header__chevron {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #94a3b8;
    transition: transform 0.2s ease, border-top-color 0.2s ease;
    flex-shrink: 0;
}

.lib-page-header__menu {
    position: fixed;
    top: auto;
    right: auto;
    left: auto;
    min-width: 220px;
    padding: 8px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(13, 59, 102, 0.18);
    z-index: 1100;
}

.lib-page-header__menu[hidden] {
    display: none;
}

.lib-page-header__menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    color: #334155;
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.lib-page-header__menu-item i {
    font-size: 1.125rem;
    color: #0d3b66;
}

.lib-page-header__menu-item:hover,
.lib-page-header__menu-item:focus-visible {
    background: #f1f5f9;
    color: #0d3b66;
    outline: none;
}

.lib-page-header__menu-item--danger {
    color: #b91c1c;
}

.lib-page-header__menu-item--danger i {
    color: #b91c1c;
}

.lib-page-header__menu-item--danger:hover,
.lib-page-header__menu-item--danger:focus-visible {
    background: #fef2f2;
    color: #991b1b;
}

@media (max-width: 1199.98px) {
    .lib-page-header {
        height: 58px;
        min-height: 58px;
        padding: 0 14px;
    }

    .lib-page-header__title {
        font-size: 1rem;
    }

    .lib-page-header__name {
        max-width: 42vw;
    }
}
