/* ============================================================
   styles.css — Sistema de Acreditaciones
   Design System: Variables, Layout, Components
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
    /* Primary Palette */
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --primary-subtle: rgba(79, 70, 229, 0.08);

    /* Accent */
    --accent: #06b6d4;
    --accent-light: #67e8f9;

    /* Neutrals */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1e1b4b;
    --bg-sidebar-hover: #312e81;
    --bg-sidebar-admin: #0f172a;
    --bg-sidebar-admin-hover: #1e293b;
    --bg-sidebar-maestro: #000000;
    --bg-sidebar-maestro-hover: #111827;
    --accent-maestro: #ef4444;
    --bg-navbar: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    /* Status Colors */
    --estado-nuevo: #3b82f6;
    --estado-pendiente: #f59e0b;
    --estado-rechazado: #ef4444;
    --estado-habilitado: #10b981;
    --estado-desafectado: #94a3b8;
    --estado-falta-doc: #f97316;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 64px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

.bg-falta-doc {
    background-color: var(--estado-falta-doc) !important;
    color: white !important;
}

/* ============================================================
   Base Reset & Typography
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Loading state — ocultar contenido hasta que el guard resuelva */
body.loading .app-layout {
    opacity: 0;
    pointer-events: none;
}

body.loading::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 3rem;
    height: 3rem;
    margin-top: -1.5rem;
    margin-left: -1.5rem;
    border: 0.25em solid rgba(79, 70, 229, 0.2);
    border-right-color: var(--primary);
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
    z-index: 9999;
}

body.loading::after {
    content: 'Cargando datos...';
    position: fixed;
    top: calc(50% + 2.5rem);
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary);
    z-index: 9999;
    letter-spacing: 0.2px;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

body:not(.loading) .app-layout {
    opacity: 1;
    transition: opacity var(--transition-normal);
}

/* ============================================================
   Preloader
   ============================================================ */
.landing-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease-out;
}

.landing-preloader .spinner-container {
    text-align: center;
}

/* ============================================================
   Landing Page Layout (Split View)
   ============================================================ */
.landing-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
}

@media (min-width: 992px) {
    .landing-wrapper {
        flex-direction: row;
    }
}

/* ── Hero Section (Left) ── */
.landing-hero {
    flex: 1;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #4f46e5 100%);
    position: relative;
    overflow: hidden;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: white;
}

@media (min-width: 992px) {
    .landing-hero {
        padding: 4rem 10%;
    }
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(6, 182, 212, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(129, 140, 248, 0.1) 0%, transparent 40%);
    animation: pulseBg 15s ease-in-out infinite alternate;
}

@keyframes pulseBg {
    0% {
        opacity: 0.7;
        transform: scale(1);
    }

    100% {
        opacity: 1;
        transform: scale(1.05);
    }
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 600px;
}

.hero-logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
}

.hero-icon {
    width: 64px;
    height: 64px;
    background: white;
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.hero-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.hero-brand {
    font-size: 3.75rem; /* 3x original size */
    font-weight: 800;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #ffffff 0%, #c7d2fe 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

.hero-title {
    font-size: clamp(2rem, 4vw, 3.25rem);
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 1.25rem;
    letter-spacing: -1px;
    color: rgba(255, 255, 255, 0.95);
}

.hero-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.6;
    margin-bottom: 3rem;
    max-width: 90%;
}

.hero-features {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.feature-icon {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.feature-text h4 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
}

.feature-text p {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    line-height: 1.5;
}

/* ── Auth Section (Right) ── */
.landing-auth {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    background: var(--bg-body);
}

@media (min-width: 992px) {
    .landing-auth {
        max-width: 480px;
        background: white;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.03);
    }
}

@media (min-width: 1200px) {
    .landing-auth {
        max-width: 550px;
    }
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl), 0 0 40px rgba(79, 70, 229, 0.05);
    padding: 3rem 2.5rem;
    transition: transform var(--transition-normal);
}

.login-card:hover {
    transform: translateY(-2px);
}

@media (min-width: 992px) {
    .login-card {
        box-shadow: none;
        padding: 0;
        background: transparent;
    }
}

.login-card .form-control {
    border-radius: var(--border-radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.login-card .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.login-card .input-group-text {
    border: 1.5px solid var(--border-color);
    border-right: none;
    color: var(--text-secondary);
}

.login-card .form-control:focus+.btn-outline-secondary,
.login-card .input-group:focus-within .input-group-text {
    border-color: var(--primary-light);
}

.login-card .btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0.85rem;
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.3px;
    margin-top: 0.5rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.login-card .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
}

.login-card .btn-primary:active {
    transform: translateY(0);
}

/* ============================================================
   App Layout (Sidebar + Content)
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal), transform var(--transition-normal);
    overflow: visible;
    /* Permitir que sobresalgan elementos como el toggle */
}

.sidebar-content {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-text {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #ffffff 0%, #c7d2fe 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

.sidebar-brand-icon {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 12px;
    padding: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Estado Colapsado (Desktop) */
.app-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.app-sidebar.collapsed .sidebar-brand-text,
.app-sidebar.collapsed .sidebar-nav .nav-link span,
.app-sidebar.collapsed .sidebar-user-info,
.app-sidebar.collapsed .sidebar-footer span {
    display: none;
}

.app-sidebar.collapsed .sidebar-footer {
    padding: 1rem 0.5rem;
    display: flex;
    justify-content: center;
}

.app-sidebar.collapsed .sidebar-footer .btn {
    display: none;
}

.app-sidebar.collapsed .sidebar-footer .btn i {
    margin: 0 !important;
    font-size: 1.2rem;
}

.app-sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 1.25rem 0;
}

.app-sidebar.collapsed .sidebar-brand-icon {
    margin-right: 0;
}

.app-sidebar.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 0.8rem 0;
}

.app-sidebar.collapsed .sidebar-nav .nav-link i {
    margin-right: 0 !important;
    font-size: 1.35rem;
}

.app-sidebar.collapsed .sidebar-footer {
    padding: 1rem 0.5rem;
    display: flex;
    justify-content: center;
}

.app-sidebar.collapsed .sidebar-user {
    justify-content: center;
}

.app-sidebar.collapsed .sidebar-user-avatar {
    margin-right: 0;
}

.sidebar-brand-text small {
    display: block;
    font-weight: 400;
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 2px;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.sidebar-nav .nav-item {
    padding: 0 0.75rem;
    margin-bottom: 2px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    color: rgba(255, 255, 255, 0.65);
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    color: #fff;
    background: var(--bg-sidebar-hover);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── Role Themes (Admin & Maestro) ── */
.app-sidebar.is-admin {
    background: var(--bg-sidebar-admin);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.app-sidebar.is-admin .sidebar-brand-icon {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    /* Amber/Gold */
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

.app-sidebar.is-admin .sidebar-nav .nav-link:hover {
    background: var(--bg-sidebar-admin-hover);
}

.app-sidebar.is-admin .sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, #d97706, #92400e);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
}

.app-sidebar.is-admin .sidebar-user-avatar {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: #451a03;
}

/* Maestro: Aggressive High-Alert Theme */
.app-sidebar.is-maestro {
    background: var(--bg-sidebar-maestro);
}

.app-sidebar.is-maestro .sidebar-brand-icon {
    background: linear-gradient(135deg, var(--accent-maestro), #991b1b);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
    animation: maestroPulse 2s infinite;
}

@keyframes maestroPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.app-sidebar.is-maestro .sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.7);
}

.app-sidebar.is-maestro .sidebar-nav .nav-link:hover {
    color: #fff;
    background: rgba(239, 68, 68, 0.1);
}

.app-sidebar.is-maestro .sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--accent-maestro), #b91c1c);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.app-sidebar.is-maestro .sidebar-user-avatar {
    background: var(--accent-maestro);
    color: #fff;
}

.app-sidebar.is-maestro .sidebar-brand-text {
    color: var(--accent-maestro);
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.sidebar-user-dropdown-btn {
    width: 100%;
    background: transparent;
    border: none;
    padding: 0;
    color: inherit;
    text-align: left;
    display: block;
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition-fast);
}

.sidebar-user-dropdown-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    overflow: hidden;
}

.app-sidebar.collapsed .sidebar-user-info,
.app-sidebar.collapsed .sidebar-user-more {
    display: none;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-user-more {
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.sidebar-user-dropdown-btn:hover .sidebar-user-more {
    opacity: 1;
}

.sidebar-user-menu {
    width: 100%;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem;
    margin-bottom: 0.5rem !important; /* Desplegar hacia arriba si es necesario */
}

.sidebar-user-menu .dropdown-item {
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.sidebar-user-menu .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-user-menu .dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171 !important;
}

/* ── Main Content ── */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-normal);
}

.app-sidebar.collapsed~.app-main {
    margin-left: var(--sidebar-collapsed-width);
}

/* ── Topbar ── */
.app-topbar {
    height: var(--navbar-height);
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-title i {
    color: var(--primary);
    margin-right: 0.5rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-topbar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--bg-body);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-topbar:hover {
    background: var(--primary-subtle);
    color: var(--primary);
}

/* Mobile toggle */
.sidebar-toggle {
    display: block;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.25rem;
    transition: transform var(--transition-fast);
}

@media (min-width: 993px) {
    .sidebar-toggle {
        display: none;
    }
}

.sidebar-toggle:hover {
    color: var(--primary);
}

/* ── Desktop Edge Toggle ── */
.sidebar-desktop-toggle {
    position: absolute;
    right: -12px;
    top: 45%;
    transform: translateY(-50%);
    width: 24px;
    height: 50px;
    background: var(--bg-sidebar);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1060;
    transition: all var(--transition-normal);
    box-shadow: 4px 0 8px rgba(0, 0, 0, 0.2);
}

.app-sidebar.is-admin .sidebar-desktop-toggle {
    background: var(--bg-sidebar-admin);
}

.app-sidebar.is-maestro .sidebar-desktop-toggle {
    background: var(--bg-sidebar-maestro);
}

.sidebar-desktop-toggle:hover {
    right: -14px;
    width: 28px;
    color: #fff;
    background: var(--primary);
    border-color: var(--primary-light);
}

.sidebar-desktop-toggle i {
    transition: transform var(--transition-normal);
    font-size: 0.9rem;
}

.app-sidebar.collapsed .sidebar-desktop-toggle i {
    transform: rotate(180deg);
}

/* ── Content Area ── */
.app-content {
    flex: 1;
    padding: 1.5rem;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* ── KPI Cards ── */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.kpi-card.kpi-primary::before {
    background: var(--primary);
}

.kpi-card.kpi-success::before {
    background: var(--estado-habilitado);
}

.kpi-card.kpi-warning::before {
    background: var(--estado-pendiente);
}

.kpi-card.kpi-danger::before {
    background: var(--estado-rechazado);
}

.kpi-card.kpi-info::before {
    background: var(--accent);
}

.kpi-card.kpi-secondary::before {
    background: var(--estado-desafectado);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.kpi-primary .kpi-icon {
    background: var(--primary-subtle);
    color: var(--primary);
}

.kpi-success .kpi-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--estado-habilitado);
}

.kpi-warning .kpi-icon {
    background: rgba(245, 158, 11, 0.1);
    color: var(--estado-pendiente);
}

.kpi-danger .kpi-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--estado-rechazado);
}

.kpi-info .kpi-icon {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent);
}

/* ── Mini KPI Cards ── */
.mini-kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.mini-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.mini-kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.kpi-secondary .kpi-icon {
    background: rgba(148, 163, 184, 0.1);
    color: var(--estado-desafectado);
}

.kpi-content {
    flex: 1;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================================
   Tables
   ============================================================ */
.table {
    font-size: 0.9rem;
}

.table thead th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom-width: 1px;
    padding: 0.85rem 1rem;
}

.table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
}

.table-hover tbody tr {
    transition: background-color var(--transition-fast);
}

/* ============================================================
   Status Badges
   ============================================================ */
.badge {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.4em 0.75em;
    border-radius: 6px;
    letter-spacing: 0.3px;
}

.estado-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* ============================================================
   Forms
   ============================================================ */
.form-control,
.form-select {
    border-radius: var(--border-radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

/* ============================================================
   Modals
   ============================================================ */
.modal-content {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.modal-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* ============================================================
   Progress Bars (cupos)
   ============================================================ */
.cupo-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-body);
    overflow: hidden;
}

.cupo-bar .progress-bar {
    border-radius: 4px;
    transition: width var(--transition-normal);
}

.cupo-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ============================================================
   Toast Container
   ============================================================ */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

.toast {
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    border: none;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================================
   Empty States
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.empty-state-sub {
    font-size: 0.85rem;
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.spinner-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--primary);
}

/* ============================================================
   File Upload Area
   ============================================================ */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-body);
}

.file-upload-area:hover,
.file-upload-area.dragover {
    border-color: var(--primary-light);
    background: var(--primary-subtle);
}

.file-upload-area i {
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.file-upload-area p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
}

.file-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--bg-body);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

/* ============================================================
   Tree View (Proveedores)
   ============================================================ */
.tree-node {
    padding-left: 1.5rem;
    position: relative;
}

.tree-node::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
}

.tree-node-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    position: relative;
}

.tree-node-item::before {
    content: '';
    width: 0.75rem;
    height: 1px;
    background: var(--border-color);
    position: absolute;
    left: -0.75rem;
}

.tree-toggle {
    cursor: pointer;
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
}

.tree-toggle.collapsed {
    transform: rotate(-90deg);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1035;
        display: none;
    }

    .sidebar-backdrop.show {
        display: block;
    }
}

@media (max-width: 767.98px) {
    .app-content {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.4rem;
    }
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.3s ease;
}

/* ============================================================
   Cupo Warning
   ============================================================ */
.cupo-danger {
    color: var(--estado-rechazado) !important;
    font-weight: 700;
}

.cupo-warning {
    color: var(--estado-pendiente) !important;
    font-weight: 600;
}

.cupo-ok {
    color: var(--estado-habilitado);
}

/* ============================================================
   Historial / Logs Panel
   ============================================================ */
.log-entry {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry-date {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ============================================================
   Tree Table (Vista de Árbol)
   ============================================================ */
.tree-table th {
    font-size: 0.7rem !important;
    text-align: center;
    vertical-align: middle;
}

.tree-table td {
    font-size: 0.85rem;
    padding: 0.6rem 0.5rem !important;
}

.tree-table .font-monospace {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9rem;
}

.tree-table tr:hover td {
    background-color: var(--primary-subtle) !important;
}

.tree-table td div span {
    white-space: nowrap;
}

/* ── Phone Mask Calculator Style ── */
.input-phone-calculator {
    text-align: right !important;
}

/* ============================================================
   Tree View & Hierarchy
   ============================================================ */
.tree-connector {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1rem;
    color: var(--text-muted);
    opacity: 0.6;
    user-select: none;
    line-height: 1;
}

.tree-row-n1 {
    background-color: rgba(0, 0, 0, 0.015);
}

.tree-row-n2 {
    background-color: rgba(0, 0, 0, 0.03);
}

.tree-row-n3 {
    background-color: rgba(0, 0, 0, 0.045);
}

.tree-indent-spacer {
    display: inline-block;
}

@media (max-width: 768px) {
    .tree-indent-spacer {
        width: 12px !important;
        /* Reducir en mobile */
    }
}

.view-acreditados-link {
    text-decoration: none;
    cursor: pointer;
    color: var(--bs-primary);
    transition: all 0.2s;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
}

.view-acreditados-link:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    text-decoration: underline;
}

/* Micro-animación para elementos interactivos */
.hvr-grow {
    display: inline-block;
    vertical-align: middle;
    transform: translateZ(0);
    box-shadow: 0 0 1px rgba(0, 0, 0, 0);
    backface-visibility: hidden;
    transition-duration: 0.3s;
    transition-property: transform;
}

.hvr-grow:hover,
.hvr-grow:focus,
.hvr-grow:active {
    transform: scale(1.03);
}

/* ── Automatic Upload Visual Feedback ── */
#inputProtocoloFile.is-loading {
    border-color: var(--primary);
    background-color: var(--primary-subtle);
    pointer-events: none;
    opacity: 0.7;
}

/* ============================================================
   Sidebar Brand Icon (Restored)
   ============================================================ */
.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    padding: 6px;
}

.sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.2;
    white-space: nowrap;
}

/* ============================================================
   Workspace Switcher
   ============================================================ */
.event-switcher-container {
    padding: 0 1rem 0.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar.collapsed .event-switcher-container {
    padding: 0 0.5rem 1rem 0.5rem;
}

.event-switcher-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    text-align: left;
    transition: all var(--transition-fast);
}

.event-switcher-btn.dropdown-toggle::after {
    display: none;
}

.event-switcher-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.event-switcher-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.event-switcher-info {
    flex: 1;
    overflow: hidden;
}

.app-sidebar.collapsed .event-switcher-info,
.app-sidebar.collapsed .event-switcher-chevron {
    display: none;
}

.event-switcher-productora {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-switcher-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-switcher-dropdown {
    width: 100%;
    min-width: 240px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    margin-top: 0.5rem !important;
}

.event-item {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    text-align: left;
    transition: all var(--transition-fast);
}

.event-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.event-item.active {
    background: rgba(255, 255, 255, 0.05);
}

.event-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.event-item.active .event-item-icon {
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.event-item-info {
    flex: 1;
    overflow: hidden;
}

.event-item-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-item-check {
    opacity: 0;
    color: var(--accent-light);
    font-size: 1.1rem;
    transition: opacity var(--transition-fast);
}

.event-item.active .event-item-check {
    opacity: 1;
}