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

[x-cloak] { display: none !important; }

:root {
    --crm-header-height: 56px;
    --crm-sidebar-width: 250px;
    --crm-primary: #1F4E79;
    --crm-sidebar-bg: #1a3a5c;
    --demo-banner-h: 0px;
}

/* Modo demo: el banner ocupa 24px y empuja todo hacia abajo */
body.demo-mode {
    --demo-banner-h: 24px;
}
body.demo-mode .crm-header {
    top: var(--demo-banner-h);
}
body.demo-mode .crm-sidebar {
    top: calc(var(--crm-header-height) + var(--demo-banner-h));
    height: calc(100vh - var(--crm-header-height) - var(--demo-banner-h));
}
body.demo-mode .crm-content {
    margin-top: calc(var(--crm-header-height) + var(--demo-banner-h));
}

/* ── BODY — Aurora gradient ── */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #eef2ff;
    /* background-attachment:fixed roto en iOS Safari — se reemplaza con pseudo-elemento */
}

/* Aurora fija via pseudo-elemento: no interfiere con modales ni backdrop-filter */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse at 0% 0%,   rgba(147,197,253,0.55) 0%, transparent 55%),
        radial-gradient(ellipse at 100% 0%,  rgba(196,181,253,0.50) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 100%, rgba(249,168,212,0.35) 0%, transparent 55%),
        #eef2ff;
    pointer-events: none;
}

/* ── HEADER ── */
/* z-index: 1030 = mismo que Bootstrap .fixed-top, por debajo del modal-backdrop (1050)
   y del modal (1055). Sin backdrop-filter para no crear stacking contexts que
   interfieren con Bootstrap modals y offcanvas. */
.crm-header {
    background: rgba(15,23,42,0.97);
    height: var(--crm-header-height);
    z-index: 1030;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 32px rgba(0,0,0,0.25);
}

.crm-logo {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: white !important;
}

.crm-logo-img {
    height: 36px;
    width: auto;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

.crm-usuario {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
}

/* ── SIDEBAR DESKTOP ── */
/* z-index: 1025 = por debajo del offcanvas-backdrop (1040) y modal-backdrop (1050).
   Sin backdrop-filter para evitar conflictos de stacking context. */
.crm-sidebar {
    background: rgba(255,255,255,0.97);
    border-right: 1px solid rgba(255,255,255,0.6);
    box-shadow: 4px 0 24px rgba(139,92,246,0.07);
    width: var(--crm-sidebar-width);
    position: fixed;
    top: var(--crm-header-height);
    left: 0;
    height: calc(100vh - var(--crm-header-height));
    overflow-y: auto;
    z-index: 1025;
    padding: 0.5rem 0.4rem;
}

/* ── SIDEBAR MOBILE (offcanvas) — mantiene oscuro porque logo es blanco ── */
.crm-sidebar-mobile {
    background-color: var(--crm-sidebar-bg);
    width: var(--crm-sidebar-width);
}

/* ── SECCIÓN LABEL (desktop) ── */
.crm-sidebar .nav-section {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.65rem 0.9rem 0.25rem;
    margin-top: 4px;
    list-style: none;
}
.crm-sidebar .nav-section span {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #94a3b8;
    text-transform: uppercase;
    white-space: nowrap;
}
.crm-sidebar .nav-section::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(0,0,0,0.07);
}

/* ── NAV LINKS DESKTOP (sidebar claro) ── */
.crm-sidebar .nav-link {
    color: #475569;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    transition: all 0.15s ease;
    font-size: 0.88rem;
    font-weight: 450;
}

.crm-sidebar .nav-link:hover {
    background: rgba(255,255,255,0.75);
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.crm-sidebar .nav-link.active {
    background: white;
    color: #4f46e5;
    font-weight: 600;
    border-left: none;
    padding-left: 0.9rem;
    box-shadow: 0 2px 12px rgba(79,70,229,0.16), 0 1px 3px rgba(0,0,0,0.06);
}

.crm-sidebar .nav-link.active i { color: #6366f1; }

.crm-sidebar .nav-link i {
    width: 22px;
    margin-right: 8px;
    font-size: 1rem;
}

/* ── NAV LINKS MOBILE (sidebar oscuro, igual que antes) ── */
.crm-sidebar-mobile .nav-link {
    color: rgba(255, 255, 255, 0.70);
    padding: 0.75rem 1.25rem;
    border-radius: 0;
    transition: background-color 0.15s ease;
    font-size: 0.92rem;
}

.crm-sidebar-mobile .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.10);
    color: white;
}

.crm-sidebar-mobile .nav-link.active {
    background-color: rgba(255, 255, 255, 0.18);
    color: white;
    font-weight: 500;
    border-left: 3px solid rgba(255, 255, 255, 0.6);
}

.crm-sidebar-mobile .nav-link i {
    width: 22px;
    margin-right: 8px;
    font-size: 1rem;
}

/* ── CONTENIDO PRINCIPAL ── */
.crm-content {
    margin-top: var(--crm-header-height);
    margin-left: var(--crm-sidebar-width);
    padding: 2rem;
    min-height: calc(100vh - var(--crm-header-height) - 50px);
    background: transparent;
}

@media (max-width: 767.98px) {
    .crm-content {
        margin-left: 0;
        padding: 1.25rem;
    }
}

/* ── FOOTER ── */
.crm-footer {
    margin-left: var(--crm-sidebar-width);
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.75rem;
    text-align: center;
    font-size: 0.82rem;
    color: #6c757d;
    border-top: 1px solid rgba(255,255,255,0.65);
}

@media (max-width: 767.98px) {
    .crm-footer {
        margin-left: 0;
    }
}

/* ── CARDS — Glass effect ── */
.card {
    background: rgba(255,255,255,0.78) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1px solid rgba(255,255,255,0.65) !important;
    border-radius: 16px !important;
    box-shadow:
        0 1px 1px rgba(0,0,0,0.03),
        0 4px 8px rgba(0,0,0,0.05),
        0 16px 40px rgba(0,0,0,0.07),
        inset 0 1px 0 rgba(255,255,255,0.85) !important;
}

.card-header {
    background: rgba(255,255,255,0.50) !important;
    border-bottom: 1px solid rgba(0,0,0,0.05) !important;
    border-radius: 0 !important;
}

.card-footer {
    background: rgba(255,255,255,0.40) !important;
    border-top: 1px solid rgba(0,0,0,0.05) !important;
}

/* ── TABLAS dentro de cards ── */
.table-light {
    --bs-table-bg: rgba(255,255,255,0.45) !important;
}

.hover-row:hover {
    background-color: rgba(255,255,255,0.65) !important;
}

/* ── CARD HOVER ── */
.card-hover {
    transition: transform .15s, box-shadow .15s;
    cursor: pointer;
}
.card-hover:hover {
    transform: translateY(-3px);
    box-shadow:
        0 1px 1px rgba(0,0,0,0.03),
        0 8px 16px rgba(0,0,0,0.08),
        0 24px 48px rgba(0,0,0,0.10),
        inset 0 1px 0 rgba(255,255,255,0.9) !important;
}

/* ── BOTONES ── */
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    border-color: transparent !important;
    box-shadow: 0 4px 14px rgba(99,102,241,0.38) !important;
}
.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #4f46e5, #4338ca) !important;
    box-shadow: 0 6px 20px rgba(99,102,241,0.50) !important;
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    border-color: transparent !important;
    box-shadow: 0 4px 14px rgba(16,185,129,0.32) !important;
}
.btn-success:hover,
.btn-success:focus {
    background: linear-gradient(135deg, #059669, #047857) !important;
    box-shadow: 0 6px 20px rgba(16,185,129,0.45) !important;
}

/* ── DROPDOWNS ── */
.dropdown-menu {
    border: 1px solid rgba(255,255,255,0.6) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06) !important;
    background: rgba(255,255,255,0.92) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* ── ALERTS ── */
.alert {
    border-radius: 12px !important;
}

/* ── MODALES — fondo siempre sólido (evita transparencia en iOS/Safari) ── */
.modal-content {
    background: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.20), 0 4px 16px rgba(0,0,0,0.10) !important;
}
.modal-header {
    background: #f8f9fa !important;
    border-bottom: 1px solid rgba(0,0,0,0.08) !important;
    border-radius: 16px 16px 0 0 !important;
}
.modal-footer {
    background: #f8f9fa !important;
    border-top: 1px solid rgba(0,0,0,0.08) !important;
    border-radius: 0 0 16px 16px !important;
}
.modal-body {
    background: #ffffff !important;
}

/* ── Evitar scroll horizontal global ──
   IMPORTANTE: overflow-x en <html> rompe position:fixed (sidebar/header).
   Se aplica solo al contenedor de contenido, no al html/body. ── */
.crm-content {
    overflow-x: hidden;
}

/* ══ RESPONSIVE MOBILE (< 768px) ══════════════════════════════════ */
@media (max-width: 767.98px) {
    /* Tablas con scroll horizontal en lugar de desborde */
    .table-responsive-mobile {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Chips de acción en la cabecera: permitir que envuelvan */
    .page-header-actions {
        flex-wrap: wrap !important;
    }
}

/* ══ RESPONSIVE MOBILE (< 576px) ══════════════════════════════════ */
@media (max-width: 575.98px) {

    /* Contenido: padding reducido */
    .crm-content {
        padding: 0.75rem 0.625rem;
    }

    /* Títulos de página */
    .crm-content h4 {
        font-size: 1.05rem;
    }

    /* Cards: menos padding */
    .card-body {
        padding: 0.75rem !important;
    }
    .card-header,
    .card-footer {
        padding: 0.5rem 0.75rem !important;
    }

    /* ── KPI cards (col-6): números más chicos ── */
    .kpi-number {
        font-size: 1.35rem !important;
        line-height: 1.1 !important;
    }
    .kpi-label {
        font-size: 0.7rem !important;
        line-height: 1.3 !important;
    }
    .kpi-icon {
        display: none !important;   /* el ícono ocupa espacio valioso en 50% */
    }

    /* ── Tablas más compactas ── */
    .table th,
    .table td {
        font-size: 0.78rem;
        padding: 0.3rem 0.45rem;
    }
    .table .btn-sm {
        padding: 0.18rem 0.3rem;
        font-size: 0.72rem;
    }
    .table .badge {
        font-size: 0.68rem;
    }

    /* ── Paginación centrada ── */
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
        gap: 2px;
    }

    /* ── Botones de cabecera de página: apilables ── */
    .page-header-actions {
        flex-wrap: wrap !important;
    }
    .page-header-actions .btn {
        font-size: 0.78rem;
        padding: 0.25rem 0.5rem;
    }

    /* ── Formularios ── */
    .form-control,
    .form-select {
        font-size: 0.875rem;
    }

    /* ── Ocultar columnas secundarias en tablas listado ── */
    .d-mobile-none {
        display: none !important;
    }

    /* ── Texto largo: permitir corte ── */
    .text-break-mobile {
        word-break: break-word;
        overflow-wrap: break-word;
    }
}
