/* =========================================
   1. ESTILOS CORE & TIPOGRAFÍA
   ========================================= */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --dark-bg: #0f172a;
    --sidebar-bg: #1e293b;
    --light-bg: #f1f5f9;
    --border-color: #e2e8f0;
    --text-main: #334155;
    --text-muted: #64748b;
    --card-radius: 16px;
    --transition-speed: 0.25s;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-main);
    overflow-x: hidden;
    margin: 0;
    display: flex;
    font-size: 0.925rem; /* Un poco más pequeño para verse más profesional */
    -webkit-font-smoothing: antialiased;
}

h3, h4, h5, h6 { color: #1e293b; letter-spacing: -0.5px; }

/* =========================================
   2. SIDEBAR & LAYOUT (Responsive)
   ========================================= */
#sidebar-wrapper {
    min-height: 100vh;
    width: 16rem;
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 0;
    background-color: var(--sidebar-bg);
    transition: margin var(--transition-speed) ease-out;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15); /* Sombra suave hacia la derecha */
}

/* Cabecera del Sidebar */
#sidebar-wrapper .sidebar-heading {
    padding: 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    background-color: rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    letter-spacing: 0.5px;
}

/* Items del Menú */
#sidebar-wrapper .list-group-item {
    background-color: transparent;
    color: #94a3b8;
    border: none;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    margin: 4px 12px; /* Espacio alrededor para efecto flotante */
    border-radius: 8px;
}

#sidebar-wrapper .list-group-item:hover {
    background-color: rgba(255,255,255,0.05);
    color: #fff;
    transform: translateX(4px);
}

#sidebar-wrapper .list-group-item.active {
    background-color: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4); /* Glow azul */
}

/* Contenedor Principal */
#page-content-wrapper {
    width: 100%;
    transition: margin-left var(--transition-speed) ease-out;
    background-color: var(--light-bg);
    min-height: 100vh;
    padding-bottom: 40px;
}

/* Navbar Superior */
.navbar {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(10px); /* Efecto cristal moderno */
    border-bottom: 1px solid rgba(226, 232, 240, 0.8) !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02) !important;
}

/* --- LÓGICA RESPONSIVE --- */
/* Mobile First: El sidebar está oculto por defecto (margin negativo) */
#sidebar-wrapper { margin-left: -16rem; }

/* Estado "Abierto" en Móvil */
body.sb-sidenav-toggled #sidebar-wrapper { margin-left: 0; }
body.sb-sidenav-toggled #page-content-wrapper { margin-left: 0; } 

/* Desktop (min-width: 768px) */
@media (min-width: 768px) {
    #sidebar-wrapper { margin-left: 0; } /* Visible por defecto */
    #page-content-wrapper { margin-left: 16rem; width: calc(100% - 16rem); }
    
    /* Estado "Cerrado" en Desktop */
    body.sb-sidenav-toggled #sidebar-wrapper { margin-left: -16rem; }
    body.sb-sidenav-toggled #page-content-wrapper { margin-left: 0; width: 100%; }
}

/* =========================================
   3. TARJETAS DASHBOARD (Efecto Glass/Gradient)
   ========================================= */
.card-dash {
    border: none;
    border-radius: var(--card-radius);
    color: white;
    position: relative;
    overflow: hidden;
    min-height: 150px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.card-dash:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-dash .card-body {
    padding: 1.5rem;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-dash h3 { font-size: 2.2rem; font-weight: 800; margin-bottom: 0.5rem; }
.card-dash span { font-size: 0.8rem; font-weight: 600; letter-spacing: 1px; opacity: 0.9; }
.card-dash .bg-icon {
    position: absolute;
    right: -10px;
    bottom: -10px; /* Cambiado a bottom para que no tape el texto */
    top: auto;
    font-size: 90px !important;
    opacity: 0.15;
    transform: rotate(-10deg);
    z-index: 1;
}

/* Gradientes Modernos */
.bg-gradient-blue { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.bg-gradient-green { background: linear-gradient(135deg, #10b981 0%, #047857 100%); }
.bg-gradient-orange { background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%); }

/* =========================================
   4. COMPONENTES UI (Cards, Tablas, Forms)
   ========================================= */

/* Tarjetas Generales (Blanco) */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    background: white;
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.card-header {
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

/* Tablas Modernas */
.table-responsive {
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}
.table { margin-bottom: 0; }
.table thead th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap; /* Evita que se rompa en celular */
}
.table tbody td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    color: var(--text-main);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
}
.table-hover tbody tr:hover { background-color: #f8fafc; }

/* Formularios & Inputs (Estilo Stripe) */
.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}
.form-control, .form-select {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    color: #1e293b;
    transition: all 0.2s;
    background-color: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1); /* Ring focus suave */
    outline: none;
}
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Botones */
.btn {
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(37, 99, 235, 0.3);
}

/* =========================================
   5. PÁGINA DE LOGIN
   ========================================= */
.auth-wrapper {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-color: #f8fafc; /* Fallback */
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 24px 24px; /* Efecto de puntos sutil */
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    background: white;
    padding: 3rem 2.5rem;
    border-radius: 24px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid #fff;
}

/* =========================================
   6. UTILIDADES Y ANIMACIONES
   ========================================= */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
}
.badge-success { background-color: #dcfce7; color: #15803d; }
.badge-warning { background-color: #fef9c3; color: #a16207; }
.badge-danger { background-color: #fee2e2; color: #b91c1c; }

/* ✅ PEGA ESTO AQUÍ (Lo movimos desde abajo hacia arriba) */
.bg-purple {
    background-color: #6f42c1 !important;
    color: #ffffff !important;
    border: 1px solid #5a32a3; /* Opcional: un borde sutil */
}

.portal-section {
    display: none;
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Loader Global */
.loader-overlay {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display:none;
    align-items:center; justify-content:center;
    flex-direction: column;
}

/* Ajustes Específicos Móvil */
@media (max-width: 767px) {
    .card-dash { min-height: 120px; margin-bottom: 15px; }
    .card-dash h3 { font-size: 1.8rem; }
    .container-fluid { padding-left: 1rem; padding-right: 1rem; }
    
    /* Que las tablas scrolleen horizontalmente en vez de romper el diseño */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
/* Estilos CRM */
#leadDetailModal .modal-header {
    background-color: #f8fafc;
}
#leadDetailModal textarea {
    resize: none;
    font-size: 0.9rem;
}
.bg-purple {
    background-color: #6f42c1 !important;
    color: white;
}
/* Forzar texto blanco en tarjetas */
.card-dash h3, 
.card-dash span {
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}