/* ==========================================================================
   UPOBI: capa de diseño compartida
   Encabezado, menús, listado de reportes, ventana de reporte y pie de página.
   La usan los módulos, Rectoría, Inicio y Configuración.
   ========================================================================== */

:root {
    --azul: #061a33;
    --azul2: #08284d;
    --azul3: #0b376d;
    --gris: #f4f6f9;
    --texto: #1f2937;
    --texto-suave: #5b6675;
    --borde: #e5e7eb;
    --blanco: #ffffff;
    --verde: #15803d;
    --rojo: #dc2626;
    --rojo2: #b91c1c;
    --degradado: linear-gradient(135deg, var(--azul), var(--azul2), var(--azul3));

    /* Espacio entre la ventana del reporte y el borde de la pantalla.
       Con 0 la ventana queda de orilla a orilla. */
    --visor-margen: 8px;
}

* { box-sizing: border-box; }

html,
body {
    width: 100%;
    overflow-x: hidden;
}

html:has(.report-modal) {
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    color: var(--texto);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(8, 40, 77, 0.12), transparent 35%),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.page-wrapper {
    flex: 1 0 auto;
}

.dashboard-container {
    padding: 24px;
}

/* Íconos Lucide: el tamaño base se ajusta según dónde se usen. */

i[data-lucide] {
    display: inline-block;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.lucide {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
}

.btn .lucide {
    width: 1.15em;
    height: 1.15em;
    vertical-align: -0.2em;
}

/* --------------------------------------------------------------------------
   Encabezado
   -------------------------------------------------------------------------- */

.app-header {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 24px;
    color: #ffffff;
    background: var(--degradado);
    border-radius: 0 0 20px 20px;
    box-shadow: 0 10px 28px rgba(6, 26, 51, 0.22);
}

.app-brand {
    display: block;
    flex-shrink: 0;
}

.app-brand img {
    display: block;
    width: auto;
    height: 48px;
}

.app-heading {
    min-width: 0;
    padding-left: 20px;
    border-left: 1px solid rgba(255, 255, 255, 0.24);
}

.app-title {
    margin: 0;
    font-size: 21px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.app-subtitle {
    margin: 2px 0 0;
    font-size: 13.5px;
    line-height: 1.3;
    opacity: 0.85;
}

.app-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.app-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 14px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 999px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.app-btn:hover,
.app-btn[aria-expanded="true"] {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.app-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.app-btn svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.app-btn .app-chevron {
    width: 14px;
    height: 14px;
    opacity: 0.8;
    transition: transform 0.15s ease;
}

.app-btn[aria-expanded="true"] .app-chevron {
    transform: rotate(180deg);
}

/* Regresar y Módulos miden lo mismo. */
.app-btn-wide {
    justify-content: center;
    min-width: 136px;
}

.app-btn-user {
    padding-left: 6px;
}

.app-avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    color: var(--azul);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    background: #ffffff;
    border-radius: 50%;
}

/* Menús desplegables del encabezado */

.app-menu {
    min-width: 248px;
    margin-top: 8px !important;
    padding: 6px;
    border: 1px solid rgba(6, 26, 51, 0.1);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(6, 26, 51, 0.2);
}

.app-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    color: var(--azul);
    font-size: 14px;
    font-weight: 600;
    border-radius: 9px;
}

.app-menu .dropdown-item svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--azul3);
}

.app-menu .dropdown-item:hover,
.app-menu .dropdown-item:focus {
    color: var(--azul);
    background: rgba(8, 40, 77, 0.07);
}

.app-menu .dropdown-item.is-current {
    font-weight: 700;
    background: rgba(8, 40, 77, 0.12);
}

.app-menu .dropdown-item.is-danger,
.app-menu .dropdown-item.is-danger svg {
    color: var(--rojo2);
}

.app-menu .dropdown-item.is-danger:hover,
.app-menu .dropdown-item.is-danger:focus {
    background: rgba(220, 38, 38, 0.08);
}

.app-menu-user {
    padding: 8px 10px;
    color: var(--texto-suave);
    font-size: 13px;
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   Listado de reportes
   -------------------------------------------------------------------------- */

.reports-header {
    margin-bottom: 16px;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 2px;
    color: var(--azul);
    font-size: 18px;
    font-weight: 800;
}

.section-help {
    margin: 0;
    color: var(--texto-suave);
    font-size: 14px;
}

.report-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.report-list form {
    margin: 0;
}

.report-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    height: 100%;
    padding: 14px 15px;
    color: var(--texto);
    text-align: left;
    cursor: pointer;
    background: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.report-button:hover {
    border-color: rgba(8, 40, 77, 0.35);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.1);
    transform: translateY(-2px);
}

.report-button:active {
    transform: scale(0.99);
}

.report-button:focus-visible {
    outline: 2px solid var(--azul3);
    outline-offset: 2px;
}

.report-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.report-icon {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 38px;
    height: 38px;
    color: var(--azul2);
    background: rgba(8, 40, 77, 0.1);
    border-radius: 12px;
}

.report-name {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.report-meta {
    display: block;
    margin-top: 2px;
    color: var(--texto-suave);
    font-size: 13px;
}

/* Reportes recientes de Inicio: siempre en una fila completa. */
.recent-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.arrow-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #9ca3af;
}

.empty-state {
    display: grid;
    place-items: center;
    padding: 56px 24px;
    text-align: center;
    background: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: 20px;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 82px;
    height: 82px;
    margin-bottom: 18px;
    color: var(--azul2);
    background: rgba(8, 40, 77, 0.1);
    border-radius: 26px;
}

.empty-icon .lucide {
    width: 42px;
    height: 42px;
    stroke-width: 1.5;
}

.empty-state h5 {
    margin-bottom: 8px;
    color: var(--azul);
    font-weight: 800;
}

.empty-state p {
    margin: 0;
    color: var(--texto-suave);
}

.error-box {
    margin-bottom: 20px;
    padding: 16px 18px;
    color: var(--rojo2);
    font-weight: 700;
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: 14px;
}

/* --------------------------------------------------------------------------
   Ventana del reporte
   -------------------------------------------------------------------------- */

.report-modal {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    padding: var(--visor-margen);
    background: rgba(6, 26, 51, 0.78);
    backdrop-filter: blur(6px);
    animation: report-fade 0.18s ease-out;
}

.report-window {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--blanco);
    border-radius: 14px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    animation: report-pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.report-window-bar {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 8px 10px 8px 14px;
    border-bottom: 1px solid var(--borde);
}

.viewer-badge {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    color: var(--verde);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    background: rgba(22, 163, 74, 0.11);
    border-radius: 999px;
}

.viewer-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    background: currentColor;
    border-radius: 50%;
}

.viewer-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: var(--azul);
    font-size: 16px;
    font-weight: 800;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.exit-view-btn {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 6px;
    padding: 8px 16px 8px 13px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    background: var(--rojo);
    border-radius: 999px;
    transition: background-color 0.15s ease;
}

.exit-view-btn:hover {
    color: #ffffff;
    background: var(--rojo2);
}

.exit-view-btn:focus-visible {
    outline: 2px solid var(--rojo);
    outline-offset: 2px;
}

.exit-view-btn .lucide {
    width: 16px;
    height: 16px;
    stroke-width: 2.4;
}

.report-window-body {
    flex: 1;
    min-height: 0;
}

.report-frame {
    display: block;
    width: 100%;
    height: 100%;
    background: #f9fafb;
    border: 0;
}

@keyframes report-fade {
    from { opacity: 0; }
}

@keyframes report-pop {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
}

/* --------------------------------------------------------------------------
   Pie de página
   -------------------------------------------------------------------------- */

.app-footer {
    display: flex;
    flex-shrink: 0;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    color: #ffffff;
    background: var(--degradado);
    border-radius: 20px 20px 0 0;
}

.app-footer-copy {
    margin: 0;
    font-size: 14px;
}

.app-footer-logo {
    display: block;
    width: auto;
    height: 36px;
}

/* --------------------------------------------------------------------------
   Acceso: inicio de sesión y cambio de contraseña
   -------------------------------------------------------------------------- */

.auth-page {
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    background: var(--azul) url("../img/plantilla.jpg") center / cover no-repeat fixed;
}

.auth-shell {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    display: block;
    width: auto;
    max-width: 100%;
    height: 72px;
}

.auth-card {
    width: 100%;
    padding: 28px;
    background: var(--blanco);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.auth-title {
    margin: 0;
    color: var(--azul);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.auth-help {
    margin: 4px 0 20px;
    color: var(--texto-suave);
    font-size: 14px;
}

.auth-field {
    margin-bottom: 14px;
}

.auth-field label {
    display: block;
    margin-bottom: 6px;
    color: var(--azul);
    font-size: 14px;
    font-weight: 700;
}

.auth-input {
    position: relative;
}

.auth-input > .lucide {
    position: absolute;
    top: 50%;
    left: 13px;
    width: 18px;
    height: 18px;
    color: var(--texto-suave);
    pointer-events: none;
    transform: translateY(-50%);
}

.auth-input .form-control {
    height: 46px;
    padding-left: 42px;
    border-color: #d1d5db;
    border-radius: 12px;
}

.auth-input .form-control:focus {
    border-color: var(--azul3);
    box-shadow: 0 0 0 3px rgba(11, 55, 109, 0.16);
}

.auth-input input[type="password"],
.auth-input:has(.auth-eye) .form-control {
    padding-right: 46px;
}

/* Edge dibuja su propio ojo en los campos de contraseña. */
.auth-input input::-ms-reveal {
    display: none;
}

.auth-eye {
    position: absolute;
    top: 50%;
    right: 6px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--texto-suave);
    background: transparent;
    border: 0;
    border-radius: 8px;
    transform: translateY(-50%);
}

.auth-eye:hover {
    color: var(--azul);
    background: rgba(8, 40, 77, 0.07);
}

.auth-eye:focus-visible {
    outline: 2px solid var(--azul3);
    outline-offset: 1px;
}

.auth-eye .lucide {
    width: 18px;
    height: 18px;
}

.auth-eye .lucide-eye-off,
.auth-eye[aria-pressed="true"] .lucide-eye {
    display: none;
}

.auth-eye[aria-pressed="true"] .lucide-eye-off {
    display: block;
}

.auth-submit {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 46px;
    margin-top: 6px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    background: var(--degradado);
    border: 0;
    border-radius: 12px;
    transition: filter 0.15s ease;
}

.auth-submit:hover {
    color: #ffffff;
    filter: brightness(1.3);
}

.auth-submit:focus-visible {
    outline: 2px solid var(--azul3);
    outline-offset: 2px;
}

.auth-submit .lucide {
    width: 18px;
    height: 18px;
}

.auth-message {
    margin: 14px 0 0;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    border-radius: 10px;
}

.auth-message.is-error {
    color: var(--rojo2);
    background: rgba(220, 38, 38, 0.08);
}

.auth-message.is-ok {
    color: var(--verde);
    background: rgba(22, 163, 74, 0.11);
}

/* Resultado de las acciones de Configuración */

.auth-result {
    text-align: center;
}

.auth-result-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    color: var(--azul2);
    background: rgba(8, 40, 77, 0.1);
    border-radius: 50%;
}

.auth-result-icon .lucide {
    width: 32px;
    height: 32px;
}

.auth-result.is-success .auth-result-icon {
    color: var(--verde);
    background: rgba(22, 163, 74, 0.11);
}

.auth-result.is-error .auth-result-icon {
    color: var(--rojo2);
    background: rgba(220, 38, 38, 0.09);
}

.auth-legal {
    color: rgba(255, 255, 255, 0.78);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

.auth-legal p {
    margin: 0;
}

/* Inicio de sesión: dos columnas sobre el fondo azul */

.login-page {
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
}

.login-shell {
    display: flex;
    flex: 1;
    gap: 96px;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}

.login-brand {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    gap: 34px;
    align-items: center;
    width: 320px;
}

.login-logo {
    display: block;
    width: 100%;
    height: auto;
}

.login-partners {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* En blanco para que ambos logos se lean igual sobre el azul. */
.login-partners img {
    display: block;
    filter: brightness(0) invert(1);
    opacity: 0.92;
}

.login-powerbi {
    width: 53%;
    height: auto;
}

/* La imagen de Microsoft trae mucho aire arriba y abajo: se recorta aquí. */
.login-microsoft {
    width: 40%;
    aspect-ratio: 128 / 30;
    object-fit: cover;
    object-position: 50% 62%;
}

.login-divider {
    flex-shrink: 0;
    width: 3px;
    height: 240px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 3px;
}

.login-form {
    width: 100%;
    max-width: 416px;
}

.login-field {
    margin-bottom: 14px;
}

.login-form .form-control {
    height: 46px;
    padding-right: 46px;
    padding-left: 46px;
    text-align: center;
    border: 0;
    border-radius: 12px;
}

.login-form .form-control::placeholder {
    color: var(--texto-suave);
    opacity: 1;
}

.login-form .form-control:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}

.login-form .auth-submit {
    margin-top: 10px;
    background: #6c757d;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.login-form .auth-submit:hover {
    background: #5c636a;
    filter: none;
}

.login-form .auth-submit:focus-visible {
    outline-color: #ffffff;
}

.login-form .auth-message {
    text-align: center;
}

.login-form .auth-message.is-error {
    background: #fde8e8;
}

.login-form .auth-message.is-ok {
    background: #dcfce7;
}

.login-footer {
    padding: 16px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    text-align: center;
}

@media (max-width: 991.98px) {
    .login-shell {
        flex-direction: column;
        gap: 32px;
    }

    .login-brand {
        width: 280px;
        max-width: 100%;
    }

    .login-divider {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .auth-logo {
        height: 56px;
    }

    .auth-card {
        padding: 22px 20px;
    }
}

/* --------------------------------------------------------------------------
   Adaptación a pantallas pequeñas
   -------------------------------------------------------------------------- */

@media (max-width: 1199.98px) {
    .recent-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .app-header {
        flex-wrap: wrap;
        gap: 10px 12px;
        padding: 10px 16px 12px;
        border-radius: 0 0 16px 16px;
    }

    .app-brand img {
        height: 38px;
    }

    .app-heading {
        order: 3;
        flex-basis: 100%;
        padding-left: 0;
        border-left: 0;
    }

    .app-title {
        font-size: 19px;
    }

    .dashboard-container {
        padding: 16px;
    }

    .app-footer {
        padding: 12px 16px;
        border-radius: 16px 16px 0 0;
    }

    .recent-list {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 575.98px) {
    :root {
        --visor-margen: 0px;
    }

    .report-window {
        border-radius: 0;
    }

    .report-window-bar {
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 6px 12px;
    }

    .viewer-title {
        order: 3;
        flex-basis: 100%;
        font-size: 15px;
    }

    .app-btn-label,
    .app-btn .app-chevron {
        display: none;
    }

    .app-btn {
        justify-content: center;
        width: 42px;
        min-width: 0;
        padding: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .report-modal,
    .report-window {
        animation: none;
    }

    .report-button,
    .report-button:hover,
    .auth-submit,
    .app-btn .app-chevron {
        transition: none;
        transform: none;
    }
}
