/* =========================================
   ESTILOS GENERALES DEL SISTEMA INTERNO
   (Administrador y Asesores)
   ========================================= */
/* Forzar la tipografía Montserrat en todos los formularios del sistema */
    input, select, textarea, button {
        font-family: 'Montserrat', sans-serif;
    }
body {
    font-family: 'Montserrat', sans-serif; /* Usamos la fuente corporativa */
    margin: 0;
    background-color: #f4f4f9; 
}

/* --- Fondo específico para la pantalla de Login --- */
.body-login {
    background-color: #0f1633; /* Fondo azul oscuro para resaltar la caja blanca */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* --- Contenedor Principal Dividido --- */
.login-contenedor {
    background-color: white;
    border-radius: 20px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
    display: flex;
    max-width: 900px;
    width: 100%;
    overflow: hidden; /* Evita que la mascota se salga de las esquinas redondeadas */
    flex-wrap: wrap; /* Permite que se adapte en celulares */
}

/* --- Lado Izquierdo: Mascota --- */
.login-mascota {
    flex: 1;
    min-width: 350px;
    background-color: #f9f9f9;
    display: flex;
    align-items: flex-end; /* Alinea al perrito en la base de la caja */
    justify-content: center;
    padding-top: 20px;
}

.login-mascota img {
    max-width: 120%;
    height: auto;
    max-height: 550px;
    display: block;
}

/* --- Lado Derecho: Formulario --- */
.login-formulario-caja {
    flex: 1;
    min-width: 300px;
    padding: 50px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-logo {
    max-width: 180px;
    height: auto;
    margin: 0 auto 20px auto;
    display: block;
}

.login-formulario-caja h2 {
    text-align: center;
    color: #1b2853;
    margin-top: 0;
    margin-bottom: 30px;
    font-weight: 800;
    font-size: 24px;
    line-height: 1.2;
}

.login-formulario-caja h2 span {
    color: #e3125d; /* Fucsia corporativo para resaltar "Gestión Mi Portal" */
    font-size: 28px;
    font-weight: 900;
}

/* --- Campos del Formulario --- */
.grupo-formulario {
    margin-bottom: 20px;
}

.grupo-formulario label {
    display: block;
    margin-bottom: 8px;
    color: #1b2853;
    font-size: 14px;
    font-weight: 600;
}

.grupo-formulario input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

.grupo-formulario input:focus {
    border-color: #e3125d; /* El borde se pinta fucsia al escribir */
    outline: none;
}

/* --- Botón Ingresar --- */
.btn-ingresar {
    width: 100%;
    padding: 15px;
    background-color: #e3125d; 
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 800;
    font-family: 'Montserrat', sans-serif;
    margin-top: 10px;
    transition: background-color 0.3s;
}

.btn-ingresar:hover {
    background-color: #1b2853; /* Se vuelve azul oscuro al pasar el mouse */
}

/* =========================================
   ESTRUCTURA DEL PANEL (DASHBOARD)
   ========================================= */

.admin-layout {
    display: flex;
    min-height: 100vh; /* Ocupa toda la altura de la pantalla */
    width: 100%;
}

/* --- BARRA LATERAL (SIDEBAR) --- */
.sidebar {
    width: 260px;
    background-color: #0f1633; /* Azul oscuro corporativo */
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    z-index: 10;
}

.sidebar-logo {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo img {
    max-width: 160px;
    height: auto;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.menu-titulo {
    color: #8892b0;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    padding: 10px 25px;
    margin: 15px 0 5px 0;
}

.sidebar-menu a {
    color: #c2c7d0;
    text-decoration: none;
    padding: 12px 25px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
}

.sidebar-menu a i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-menu a:hover, 
.sidebar-menu a.activo {
    background-color: rgba(227, 18, 93, 0.1); /* Fucsia transparente */
    color: #e3125d; /* Fucsia corporativo */
    border-right: 4px solid #e3125d;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.btn-salir {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: transparent;
    color: #ff4757;
    text-decoration: none;
    padding: 12px;
    border: 1px solid #ff4757;
    border-radius: 8px;
    font-weight: 600;
    transition: 0.3s;
}

.btn-salir:hover {
    background-color: #ff4757;
    color: white;
}

/* --- CONTENIDO PRINCIPAL (DERECHA) --- */
.main-content {
    flex: 1;
    background-color: #f4f4f9;
    display: flex;
    flex-direction: column;
}

.topbar {
    background-color: white;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.titulo-seccion h2 {
    margin: 0;
    color: #1b2853;
    font-size: 24px;
    font-weight: 800;
    text-align: left;
}

.titulo-seccion p {
    margin: 5px 0 0 0;
    color: #666;
    font-size: 13px;
}

.usuario-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.rol-badge {
    background-color: #e3125d;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
}

.perfil-icono {
    font-size: 35px;
    color: #1b2853;
}

.contenido-panel {
    padding: 40px;
    flex: 1;
}

.caja-blanca {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.03);
}

.caja-blanca h3 {
    margin-top: 0;
    color: #1b2853;
    font-weight: 800;
}

/* =========================================
   DASHBOARD / KPI CARDS
   ========================================= */
.subtitulo-dash {
    color: #1b2853;
    font-size: 18px;
    margin-top: 30px;
    margin-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

.subtitulo-dash:first-child {
    margin-top: 0;
}

.dashboard-grid {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.kpi-card {
    flex: 1;
    min-width: 200px;
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.04);
    border-left: 5px solid #ccc;
}

.kpi-icono {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    color: white;
}

.kpi-datos h4 {
    margin: 0;
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.kpi-datos p {
    margin: 5px 0 0 0;
    font-size: 24px;
    font-weight: 900;
    color: #1e293b;
}

/* Colores personalizados por tarjeta */
.lote-vendido { border-left-color: #10b981; }
.lote-vendido .kpi-icono { background-color: #10b981; }

.lote-separado { border-left-color: #f59e0b; }
.lote-separado .kpi-icono { background-color: #f59e0b; }

.lote-bloqueado { border-left-color: #64748b; }
.lote-bloqueado .kpi-icono { background-color: #64748b; }

.dinero-verde { border-left-color: #e3125d; }
.dinero-verde .kpi-icono { background-color: #e3125d; }

.dinero-rojo { border-left-color: #ef4444; }
.dinero-rojo .kpi-icono { background-color: #ef4444; }

.lead-ok { border-left-color: #3b82f6; }
.lead-ok .kpi-icono { background-color: #3b82f6; }

.lead-wait { border-left-color: #f59e0b; }
.lead-wait .kpi-icono { background-color: #f59e0b; }

.lead-bad { border-left-color: #ef4444; }
.lead-bad .kpi-icono { background-color: #ef4444; }

/* =========================================
   MÓDULOS DE FILTROS Y CREACIÓN (LEADS AMIGABLE)
   ========================================= */
.modulo-filtros, .modulo-creacion {
    margin-bottom: 25px;
}

.modulo-creacion h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    color: #1b2853;
}

/* Grillas para Formularios (Mejor distribución que Flexbox) */
.grid-filtros {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end; /* Alinea los botones con los inputs */
}

.grid-creacion {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.input-grupo {
    display: flex;
    flex-direction: column;
}

.input-grupo label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #64748b;
}

/* Diseño moderno de Inputs */
.grid-filtros input, .grid-filtros select,
.grid-creacion input, .grid-creacion select {
    padding: 12px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    outline: none;
    background-color: #f8fafc;
    transition: all 0.3s;
    width: 100%;
    box-sizing: border-box;
}

.grid-filtros input:focus, .grid-filtros select:focus,
.grid-creacion input:focus, .grid-creacion select:focus {
    border-color: #e3125d;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(227, 18, 93, 0.1);
}

/* Botones Principales */
.btn-primario, .btn-secundario {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: 0.3s;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primario {
    background-color: #e3125d;
    color: white;
}
.btn-primario:hover { background-color: #1b2853; }

.btn-secundario {
    background-color: #1b2853;
    color: white;
}
.btn-secundario:hover { background-color: #e3125d; }

/* =========================================
   TABLAS DEL SISTEMA
   ========================================= */
.tabla-responsive {
    width: 100%;
    overflow-x: auto;
}

.tabla-gestion {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: left;
}

.tabla-gestion th {
    background-color: #f8fafc;
    color: #1b2853;
    font-weight: 800;
    padding: 15px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.tabla-gestion td {
    padding: 15px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.tabla-gestion tr:hover {
    background-color: #f8fafc;
}

.texto-pequeno {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

/* Etiquetas de Estado (Badges) */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    display: inline-block;
}

.badge-verde { background-color: #dcfce7; color: #16a34a; }
.badge-amarillo { background-color: #fef3c7; color: #d97706; }
.badge-rojo { background-color: #fee2e2; color: #dc2626; }
.badge-azul { background-color: #e0f2fe; color: #0284c7; }

/* Botones de Acción AMIGABLES (Con texto) */
.acciones-celda {
    display: flex;
    flex-wrap: wrap; /* Si la pantalla es pequeña, bajan de renglón */
    gap: 8px;
}

.btn-accion {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px; /* Separación entre ícono y texto */
    font-size: 12px;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    transition: 0.2s;
}

.btn-ver { background-color: #64748b; }
.btn-ver:hover { background-color: #475569; }

.btn-editar { background-color: #3b82f6; }
.btn-editar:hover { background-color: #2563eb; }

.btn-contrato { background-color: #10b981; }
.btn-contrato:hover { background-color: #059669; }

.btn-separacion { background-color: #f59e0b; }
.btn-separacion:hover { background-color: #d97706; }

.btn-asignar { background-color: #8b5cf6; }
.btn-asignar:hover { background-color: #7c3aed; }

/* =========================================
   INVENTARIO DE LOTES (TARJETAS VISUALES)
   ========================================= */
.grid-inventario {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.lote-card {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-top: 5px solid #cbd5e1; /* Borde por defecto */
    transition: transform 0.2s, box-shadow 0.2s;
}

.lote-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* Colores de estado en la tarjeta */
.borde-disponible { border-top-color: #0284c7; }
.borde-separado { border-top-color: #f59e0b; }
.borde-vendido { border-top-color: #16a34a; }
.borde-bloqueado { border-top-color: #dc2626; }

.lote-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.lote-header h3 {
    margin: 0;
    font-size: 16px;
    color: #1b2853;
    font-weight: 800;
}

.lote-body {
    flex: 1; /* Empuja el footer hacia abajo */
    margin-bottom: 15px;
}

.lote-body p {
    margin: 5px 0;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lote-body p i {
    color: #94a3b8;
    width: 15px;
    text-align: center;
}

.cliente-asignado {
    margin-top: 15px !important;
    font-size: 12px !important;
    color: #1b2853 !important;
    font-weight: 600 !important;
    background-color: #f8fafc;
    padding: 8px;
    border-radius: 6px;
}

.lote-footer {
    margin-top: auto;
}

/* =========================================================
   CORRECCIÓN RESPONSIVA MÓVIL Y BOTÓN HAMBURGUESA
   ========================================================= */

/* Botón flotante siempre visible arriba a la izquierda */
.btn-toggle-sidebar {
    display: none;
    position: fixed !important;
    top: 15px !important;
    left: 15px !important;
    bottom: auto !important;
    right: auto !important;
    z-index: 9999 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 8px !important;
    background: #1b2853 !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    font-size: 20px !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Telón de fondo oscuro */
.sidebar-overlay-mobile {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.7) !important;
    z-index: 9000 !important;
    backdrop-filter: blur(3px) !important;
}

.sidebar-overlay-mobile.activo {
    display: block !important;
}

/* TABLETS Y CELULARES (1024px o menor) */
@media (max-width: 1024px) {
    .btn-toggle-sidebar {
        display: flex !important;
    }

    /* Contenedor principal a una sola columna */
    .admin-layout {
        display: block !important;
        position: relative !important;
        width: 100% !important;
    }

    /* Sidebar oculto por defecto hacia la izquierda */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -320px !important;
        width: 280px !important;
        max-width: 80vw !important;
        height: 100% !important;
        min-height: 100vh !important;
        z-index: 9500 !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.4) !important;
    }

    /* Sidebar visible al hacer clic */
    .sidebar.abierto-movil {
        left: 0 !important;
    }

    /* El contenido central se expande */
    .main-content {
        width: 100% !important;
        margin-left: 0 !important;
        padding: 70px 16px 25px 16px !important;
        box-sizing: border-box !important;
    }

    .topbar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        padding-top: 10px !important;
    }

    .grid-kpis, 
    .grid-dashboard-4, 
    .grid-dashboard-3,
    .resumen-financiero {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .crm-grid,
    .grid-cotizador {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
}

/* CELULARES PEQUEÑOS */
@media (max-width: 640px) {
    .grid-kpis, 
    .grid-dashboard-4, 
    .grid-dashboard-3,
    .resumen-financiero {
        grid-template-columns: 1fr !important;
    }

    .grid-creacion {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .tabla-responsive {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}