/* ===== Variables de marca ===== */
:root {
    --color-primary: #0A0B2E; /*#082D52;*/
    --color-accent: #e30613;
    --color-accent-dk: #c00511;
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-text: #111827;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --radius-card: 12px;
}

html, body {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0; padding: 0;
    height: 100%;
}

/* ===== Estructura principal del dashboard ===== */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-primary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0;
}

.logo-icon {
    width: 42px; height: 42px;
    background: var(--color-accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-main {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.logo-sub {
    font-size: 0.75rem;
    color: var(--color-accent);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ===== Navegación del sidebar ===== */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: rgba(255,255,255,0.35);
    letter-spacing: 1px;
    padding: 0.85rem 0.5rem 0.3rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.10);
    color: #fff;
}

.nav-item.active {
    background: var(--color-accent);
    color: #fff;
    box-shadow: 0 3px 10px rgba(227,6,19,0.35);
}

.nav-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

/* ===== Footer del sidebar ===== */
.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    background: none;
    border: none;
    color: rgba(255,255,255,0.45);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.3rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.btn-logout:hover {
    color: var(--color-accent);
    background: rgba(227,6,19,0.12);
}

/* ===== Área principal ===== */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--color-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 6px;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-greeting {
    font-size: 0.88rem;
    color: var(--color-muted);
}

.topbar-greeting strong {
    color: var(--color-primary);
}

.btn-logout-top {
    background: transparent;
    border: 1.5px solid var(--color-accent);
    color: var(--color-accent);
    border-radius: 7px;
    padding: 0.3rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-logout-top:hover {
    background: var(--color-accent);
    color: #fff;
}

/* ===== Contenido de páginas ===== */
.page-content {
    flex: 1;
    padding: 1.75rem;
}

/* ===== Tarjetas del dashboard ===== */
.card-dashboard {
    background: var(--color-surface);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(8,45,82,0.07);
    border: 1px solid var(--color-border);
}

.card-kpi {
    background: var(--color-surface);
    border-radius: var(--radius-card);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 8px rgba(8,45,82,0.07);
    border-top: 4px solid var(--color-accent);
    transition: box-shadow 0.2s;
}

.card-kpi:hover {
    box-shadow: 0 4px 16px rgba(8,45,82,0.12);
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
}

.kpi-sub {
    font-size: 0.78rem;
    color: var(--color-muted);
    margin-top: 0.3rem;
}

/* ===== Página de auth-redirect ===== */
.auth-redirect {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-size: 1rem;
    color: var(--color-muted);
}

/* ===== Utilidades ===== */
a, .btn-link {
    color: var(--color-accent);
}

.btn-primary {
    color: #fff;
    background-color: var(--color-accent);
    border-color: var(--color-accent-dk);
}

.btn-primary:hover {
    background-color: var(--color-accent-dk);
    border-color: var(--color-accent-dk);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.15rem rgba(227,6,19,0.25);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid var(--color-accent);
}

.validation-message {
    color: var(--color-accent);
    font-size: 0.8rem;
}

/* ===== Blazor error ===== */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "Ha ocurrido un error inesperado."
}

#blazor-error-ui {
    background: #ffe4e4;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: #c62828;
    font-size: 0.88rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ===== Sidebar toggle button ===== */
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--color-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    margin-right: 0.5rem;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.sidebar-toggle:hover {
    background: #f0f4f8;
    color: var(--color-accent);
}

/* Botón cerrar dentro del sidebar (mobile) */
.btn-sidebar-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1.1rem;
    padding: 4px 6px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.btn-sidebar-close:hover { color: #fff; background: rgba(255,255,255,0.15); }

/* Backdrop (overlay mobile) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* ===== Transiciones ===== */
.sidebar {
    transition: width 0.25s ease, transform 0.25s ease;
}

.main-area {
    transition: margin-left 0.25s ease;
}

/* ===== Desktop: sidebar colapsado (sin clase sidebar-open) ===== */
@media (min-width: 769px) {
    .dashboard-wrapper:not(.sidebar-open) .sidebar {
        width: 64px;
    }

    .dashboard-wrapper:not(.sidebar-open) .main-area {
        margin-left: 64px;
    }

    .dashboard-wrapper:not(.sidebar-open) .nav-label,
    .dashboard-wrapper:not(.sidebar-open) .nav-section-label,
    .dashboard-wrapper:not(.sidebar-open) .user-details {
        display: none;
    }

    .dashboard-wrapper:not(.sidebar-open) .nav-item {
        justify-content: center;
        padding: 0.6rem;
    }

    .dashboard-wrapper:not(.sidebar-open) .sidebar-nav {
        padding: 1rem 0.4rem;
    }

    .dashboard-wrapper:not(.sidebar-open) .sidebar-logo {
        justify-content: center;
    }

    .dashboard-wrapper:not(.sidebar-open) .sidebar-footer {
        justify-content: center;
        padding: 0.85rem 0.5rem;
    }

    .dashboard-wrapper:not(.sidebar-open) .user-info {
        justify-content: center;
    }

    .dashboard-wrapper:not(.sidebar-open) .user-avatar {
        margin: 0;
    }

    .dashboard-wrapper:not(.sidebar-open) .btn-logout {
        display: none;
    }
}

/* ===== Mobile: sidebar como overlay ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .dashboard-wrapper.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .dashboard-wrapper.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .main-area {
        margin-left: 0 !important;
    }

    .page-content {
        padding: 1rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .topbar-greeting {
        display: none;
    }
}

@media (max-width: 480px) {
    .page-content {
        padding: 0.75rem;
    }

    .kpi-value {
        font-size: 1.6rem;
    }
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}
