@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* =============================================
   RESET / BASE
   ============================================= */
html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    height: 100%;
    margin: 0;
    background: #f5f6f8;
}

* { box-sizing: border-box; }

/* =============================================
   LAYOUT — Page wrapper
   ============================================= */
.page {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

main {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

.content {
    padding: 1.25rem 1rem 2rem;
}

/* =============================================
   SIDEBAR — Estructura
   ============================================= */
.sidebar {
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 55%, #0f3460 100%);
    color: #d7d7d7;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0,0,0,0.25);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.sidebar-brand:hover { color: #fff; text-decoration: none; }

.sidebar-logo {
    height: 28px;
    max-width: 100px;
    background: #fff;
    border-radius: 3px;
    padding: 2px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-logo-fallback {
    font-size: 1.5rem;
    line-height: 1;
}

.sidebar-empresa {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-toggler {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.sidebar-toggler:hover { background: rgba(255,255,255,0.25); }

/* =============================================
   SIDEBAR — Nav body
   ============================================= */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.2);
    border-radius: 4px;
}

/* =============================================
   NAV LINKS
   ============================================= */
.sidebar-nav .nav-link {
    color: #c8c8c8;
    text-decoration: none;
    border-radius: 5px;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: background-color 0.12s ease;
    margin: 0.1rem 0;
}

.sidebar-nav .nav-link:hover {
    background-color: rgba(255,255,255,0.12);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background-color: rgba(255,255,255,0.22);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav .nav-link-flat {
    margin: 0.15rem 0;
}

.sidebar-nav .oi {
    width: 1.5rem;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Plataforma — destacado con borde dorado */
.sidebar-nav .nav-link-platform {
    background: rgba(255, 209, 102, 0.08);
    border-left: 3px solid #ffd166;
    border-radius: 3px;
}

/* =============================================
   MENU SECTION (acordeón)
   ============================================= */
.menu-section {
    margin: 0.25rem 0;
}

.menu-section-header {
    width: 100%;
    background: transparent;
    border: none;
    color: #aaa;
    text-align: left;
    padding: 0.45rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.12s ease;
}

.menu-section-header:hover {
    background: rgba(255,255,255,0.06);
    color: #ddd;
}

.menu-section-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.menu-section-title {
    flex: 1;
}

.menu-section-chevron {
    font-size: 0.65rem;
    opacity: 0.7;
    transition: transform 0.15s ease;
}

.menu-section.open > .menu-section-header .menu-section-chevron {
    transform: rotate(0deg);
}

.menu-section-body {
    padding: 0.15rem 0 0.25rem 0.6rem;
    border-left: 1px solid rgba(255,255,255,0.08);
    margin-left: 1rem;
}

.menu-section-body .nav-link {
    font-size: 0.84rem;
    padding: 0.4rem 0.6rem;
}

/* Divider para sección Plataforma */
.menu-divider {
    color: #ffd166;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 0.75rem 0.75rem 0.25rem;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* =============================================
   SIDEBAR FOOTER (sticky bottom)
   ============================================= */
.sidebar-footer {
    margin-top: auto;
    padding: 0.75rem;
    background: rgba(0,0,0,0.25);
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #aaa;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.sidebar-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.sidebar-footer .btn {
    font-size: 0.78rem;
    padding: 0.3rem 0.5rem;
}

/* =============================================
   <details> colapsables (form sections opcionales)
   ============================================= */
.sat-details {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    background: #f8f9fa;
}
.sat-details > summary {
    list-style: none;
}
.sat-details > summary::-webkit-details-marker { display: none; }
.sat-details > summary::before {
    content: "▸ ";
    display: inline-block;
    transition: transform 0.15s ease;
    margin-right: 0.25rem;
}
.sat-details[open] > summary::before {
    transform: rotate(90deg);
}
.sat-details > summary:hover {
    color: #0d6efd !important;
}

/* =============================================
   FORMS / VALIDATION
   ============================================= */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
    font-size: 0.85rem;
}

/* =============================================
   BLAZOR ERROR UI
   ============================================= */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Ocurrió un error inesperado.";
}

/* =============================================
   OVERLAY (móvil — atrás del drawer)
   ============================================= */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1030;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =============================================
   RESPONSIVE — MÓVIL (< 768px)
   Sidebar como off-canvas drawer
   ============================================= */
@media (max-width: 767.98px) {
    .page { flex-direction: column; }

    /* Header del sidebar fijo arriba siempre visible */
    .sidebar-header {
        position: fixed;
        top: 0; left: 0; right: 0;
        z-index: 1020;
        background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
        height: 56px;
        padding: 0 1rem;
    }

    /* El nav del sidebar es un drawer que se desliza */
    .sidebar-nav {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        width: 280px;
        max-width: 85vw;
        background: linear-gradient(180deg, #1a1a2e 0%, #16213e 55%, #0f3460 100%);
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        padding-top: 56px;
        box-shadow: 2px 0 8px rgba(0,0,0,0.3);
    }

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

    /* Wrapper sidebar no necesita ancho fijo en móvil */
    .sidebar { width: 100%; }

    /* Empujar el contenido principal abajo del header fixed */
    main {
        padding-top: 56px;
    }

    .content {
        padding: 1rem 0.75rem 2rem;
    }

    /* Tablas: scroll horizontal por defecto en móvil */
    .table-responsive,
    main table {
        font-size: 0.82rem;
    }
}

/* =============================================
   RESPONSIVE — DESKTOP (≥ 768px)
   ============================================= */
@media (min-width: 768px) {
    .page { flex-direction: row; }

    .sidebar {
        width: 240px;
        height: 100vh;
        position: sticky;
        top: 0;
        flex-shrink: 0;
    }

    .sidebar-toggler { display: none; }

    /* Drawer en desktop siempre visible (sin transform) */
    .sidebar-nav {
        transform: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .content {
        padding: 1.25rem 1.5rem 2rem;
    }
}
