@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* Reset básico por si acaso */
.legal-panel * {
    box-sizing: border-box;
}

.legal-panel {
    display: flex;
    min-height: 100vh;
    font-family: 'Inter', sans-serif; /* Fuente tipo Dashboard moderno */
    background-color: #f3f4f6; /* Fondo gris clarito para el contenido */
}

/* ================= SIDEBAR FIJO ================= */
.legal-sidebar {
    width: 260px;
    background-color: #0f172a; /* Azul noche oscuro como en tu imagen */
    color: #f8fafc;
    padding: 20px 15px;
    
    /* Magia para dejarlo fijo */
    position: fixed; 
    top: 0;
    left: 0;
    height: 100vh; /* Ocupa todo el alto de la pantalla */
    overflow-y: auto; /* Por si agregas muchos menús y en pantallas chicas no entra */
    
    /* Flexbox para mandar el último item hacia abajo */
    display: flex;
    flex-direction: column;
    border-right: 1px solid #1e293b;
    z-index: 1000;
}

/* Título del Panel (Simulando el logo de PostVentaPRO) */
.legal-sidebar h3 {
    font-size: 22px;
    font-weight: 600;
    color: #ffffff;
    margin: 10px 0 30px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Un iconito de edificio con CSS puro antes del título */
.legal-sidebar h3::before {
    content: "🏢"; 
    font-size: 24px;
}

/* Lista de menús */
.legal-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1; /* Esto hace que el contenedor estire y empuje el botón de salir abajo */
    display: flex;
    flex-direction: column;
    gap: 8px; /* Espacio entre botones */
}

.legal-sidebar li {
    margin: 0;
}

.legal-sidebar a {
    display: block;
    color: #cbd5e1; /* Texto gris claro */
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
}

/* Hover: Cuando pasas el mouse (Gris oscuro) */
.legal-sidebar a:hover {
    background-color: #1e293b;
    color: #ffffff;
}

/* Active: Cuando está seleccionada la pestaña actual */
.legal-sidebar a.active,
.legal-sidebar a:active,
.legal-sidebar a:focus {
    background-color: #1e293b !important; /* Azul pizarra oscuro */
    color: #ffffff !important;
    border-radius: 6px;
    font-weight: 600;
}

/* Efecto hover general de los links (para que combinen) */
.legal-sidebar a:hover {
    background-color: #334155 !important; /* Un gris-azul un poco más claro al pasar el mouse */
    color: #ffffff !important;
}


/* Separador y posición del "Cerrar sesión" al fondo */
.legal-sidebar li:last-child {
    margin-top: auto; /* Lo empuja hasta el final de la barra */
    border-top: 1px solid #1e293b; /* Línea separadora como en tu imagen */
    padding-top: 15px;
}

/* Evitar que el botón de cerrar sesión se vuelva azul oscuro */
.legal-sidebar li:last-child a.active,
.legal-sidebar li:last-child a:hover {
    background-color: #E2CE9F !important; 
    color: #0f172a !important;
}
/* ================= CONTENIDO PRINCIPAL ================= */
.legal-content {
    flex: 1;
    padding: 40px;
    /* Como el sidebar es fixed y flota, le damos un margen izquierdo al contenido 
       del mismo tamaño que el ancho del sidebar para que no se oculte detrás */
    margin-left: 260px; 
    width: calc(100% - 260px);
}

/* ================= RESPONSIVE (Móviles) ================= */
/* ================= MENÚ HAMBURGUESA (MÓVILES) - MODO FORZADO ================= */
@media(max-width: 768px) {
    /* 1. Escondemos el panel a la mala para que no se vea por defecto */
    .legal-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important; /* Aquí lo ocultamos */
        width: 260px !important;
        height: 100vh !important;
        z-index: 10000 !important;
        transition: left 0.3s ease-in-out !important;
        box-shadow: 4px 0 15px rgba(0,0,0,0.5) !important;
        display: flex !important; /* Mantiene la estructura interna */
    }

    /* 2. Cuando el JS le pone la clase al hacer clic, lo traemos a la pantalla */
    .legal-sidebar.mostrar-menu {
        left: 0 !important;
    }

    /* 3. Ajustamos el contenido para que el botón no lo tape */
    .legal-content {
        padding-top: 70px !important; 
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* 4. Estilo del botón hamburguesa */
    .btn-hamburguesa {
        display: block !important;
        position: fixed !important;
        top: 15px !important;
        left: 15px !important;
        z-index: 10001 !important; /* Tiene que estar por encima de todo */
        background-color: #0f172a !important;
        color: #ffffff !important;
        border: none !important;
        border-radius: 8px !important;
        padding: 8px 14px !important;
        font-size: 22px !important;
        cursor: pointer !important;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
    }

    .btn-hamburguesa:active {
        background-color: #0f172a !important;
    }

    /* 5. Fondo oscuro translúcido */
    .menu-overlay {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        background: rgba(15, 23, 42, 0.6) !important;
        z-index: 9998 !important; 
        backdrop-filter: blur(2px) !important;
    }

    .menu-overlay.activo {
        display: block !important;
    }
}

/* Ocultamos el botón en PC para que no moleste */
@media(min-width: 769px) {
    .btn-hamburguesa, .menu-overlay {
        display: none !important;
    }
}


/* ================= ESTILOS DE TABLAS (LISTAS) ================= */

/* Títulos de las listas */
.legal-content h2 {
    color: #0f172a;
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 25px;
}

/* Contenedor de la tabla (Efecto Tarjeta Premium) */
.legal-content table.widefat {
    width: 100%;
    background-color: #ffffff;
    border-collapse: separate; /* Necesario para redondear las esquinas de una tabla */
    border-spacing: 0;
    border-radius: 12px;
    overflow: hidden; /* Corta lo que sobra en las esquinas */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    margin-bottom: 30px;
    border: none;
    font-family: 'Inter', sans-serif;
}

/* Cabecera de la tabla (Gris clarito y letras sutiles) */
.legal-content table.widefat th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 18px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

/* Celdas de la tabla */
.legal-content table.widefat td {
    padding: 16px;
    color: #334155;
    font-size: 14.5px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-weight: 500;
}

/* Quitamos el borde de la última fila para que encaje perfecto con el border-radius */
.legal-content table.widefat tr:last-child td {
    border-bottom: none;
}

/* Efecto Hover: Resalta la fila sutilmente al pasar el mouse */
.legal-content table.widefat tr:hover td {
    background-color: #f8fafc;
    transition: background-color 0.2s ease;
}

/* ================= BOTÓN "VER FICHA" (COLOR CORPORATIVO) ================= */
.legal-content table.widefat a.button {
    display: inline-block;
    background-color: #0f172a; /* Nuevo azul pizarra oscuro */
    color: #ffffff; /* Texto blanco puro */
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

/* Hover del botón */
.legal-content table.widefat a.button:hover {
    background-color: #1e293b; /* Un gris-azul un pelín más claro al pasar el mouse */
    color: #ffffff;
}

/* ================= RESPONSIVE PARA TABLAS (MÓVILES) ================= */
/* Si la pantalla es chica, permite hacer scroll horizontal a la tabla en vez de romper la página */
@media(max-width: 768px) {
    .legal-content table.widefat {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Estilo para cuando no hay registros aún */
.legal-content > p {
    color: #64748b;
    font-size: 15px;
    font-weight: 500;
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: inline-block;
}


/* ================= FICHA DEL CLIENTE Y TABS (PESTAÑAS) ================= */

/* Cabecera superior */
.ficha-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ficha-header h2 {
    margin: 0 !important;
}

/* Botón de volver */
.button-back {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    padding: 10px 16px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    border: 1px solid #cbd5e1 !important;
    text-decoration: none;
    transition: all 0.2s ease !important;
}

.button-back:hover {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
}

/* Tarjeta principal con los datos del cliente */
.ficha-card {
    background: #ffffff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

.ficha-card table {
    margin-bottom: 0;
    box-shadow: none !important;
}

.ficha-card table th {
    width: 150px;
    background: transparent !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

.section-title {
    font-size: 20px;
    color: #0f172a;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

/* ================= DISEÑO DE LAS PESTAÑAS (TABS) ================= */
.tabs-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    overflow: hidden;
    margin-bottom: 40px;
}

.tabs-header {
    display: flex;
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto; /* Si hay muchas pestañas, se podrá hacer scroll horizontal */
}

/* Botón de cada pestaña */
.tab-btn {
    background: none;
    border: none;
    padding: 16px 24px;
    font-size: 14.5px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}

.tab-btn:hover {
    color: #0f172a !important;
    background-color: #f1f5f9;
}

/* Pestaña seleccionada */
.tab-btn.active {
    color: #0f172a !important;
    border-bottom-color: #0f172a !important;
    background-color: #ffffff;
}

/* Contenido de la pestaña */
.tabs-content {
    padding: 30px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-in-out; /* Efecto suavecito al aparecer */
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Detalles del caso dentro de la pestaña */
.caso-details p {
    margin: 0 0 14px 0;
    color: #334155;
    font-size: 15px;
}

.caso-details strong {
    color: #0f172a;
    display: inline-block;
    width: 160px; /* Alinea los textos a la derecha de los títulos */
}

/* Etiqueta elegante para el 'Estado' */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    background-color: #e0e7ff; 
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.no-data {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    color: #64748b;
    font-style: italic;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ================= ESTRUCTURA Y GRILLAS ================= */
.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.grid-3-col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
}
.mt-4 { margin-top: 30px; }

/* Formulario Nueva Carpeta */
.form-desplegable {
    background-color: #f8fafc;
    border: 2px dashed #cbd5e1;
    animation: fadeIn 0.3s;
}
.cuotas-caja {
    background: #eff6ff;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

/* ================= PAGOS Y ALERTAS ================= */
.pagos-box ul {
    list-style: none;
    padding: 0;
}
.pagos-box li {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.etiqueta-alerta {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
}
.etiqueta-alerta.verde { background: #dcfce7; color: #166534; }
.etiqueta-alerta.rojo { background: #fee2e2; color: #991b1b; }
.etiqueta-alerta.amarillo { background: #fef9c3; color: #854d0e; }
.etiqueta-alerta.gris { background: #f1f5f9; color: #475569; }

.btn-check {
    background: #10b981;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.btn-check:hover { background: #059669; }

/* ================= HISTORIAL DE COMENTARIOS ================= */
.comentarios-box {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}
.form-comentario textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-bottom: 10px;
    font-family: 'Inter', sans-serif;
}

/* Estilo Chat */
.timeline-comentarios {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}
.burbuja-comentario {
    background: #ffffff;
    border-left: 4px solid #0f172a;
    padding: 15px;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 15px;
}
.fecha-com {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 5px;
    font-weight: bold;
}
.burbuja-comentario p {
    margin: 0;
    font-size: 14px;
    color: #334155;
}

@media(max-width: 768px) {
    .grid-2-col, .grid-3-col { grid-template-columns: 1fr; }
}

/* ================= POPUP ANIMADO (TOAST NOTIFICATION) ================= */
.legal-popup {
    position: fixed;
    top: 30px;
    right: -400px; /* Escondido a la derecha */
    background: #ffffff;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.15);
    border-left: 5px solid #10b981; /* Verde éxito */
    border-radius: 8px;
    padding: 16px 24px;
    z-index: 100000;
    transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); /* Efecto rebote */
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 350px;
}

.legal-popup.error { border-left-color: #ef4444; } /* Rojo si hay error */
.legal-popup.show { right: 30px; } /* Clase que mete el popup a la pantalla */

.legal-popup p { 
    margin: 0; 
    font-family: 'Inter', sans-serif; 
    font-size: 14.5px; 
    color: #1e293b; 
    font-weight: 600; 
}
.legal-popup-icon { font-size: 22px; }


/* ================= BOTONES DE FORMULARIO (COLOR CORPORATIVO) ================= */
.btn-nuevo-caso {
    background-color: #0f172a !important; /* Nuevo azul pizarra oscuro */
    color: #ffffff !important; /* Texto blanco puro */
    border: none !important;
    padding: 10px 16px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, transform 0.1s ease !important;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 4px rgba(15,23,42,0.2) !important;
}

.btn-nuevo-caso:hover {
    background-color: #1e293b !important; /* Un gris-azul un pelín más claro al pasar el mouse */
    transform: translateY(-1px);
}

.btn-nuevo-caso:active {
    transform: translateY(0);
}


/* ================= DOMADOR DE BOTONES (BOMBA NUCLEAR CORPORATIVA) ================= */

/* Agarramos todos los tipos de botones posibles dentro del panel legal */
.legal-panel input[type="submit"],
.legal-panel button[type="submit"],
.legal-panel .button,
.legal-panel .button-primary,
.btn-nuevo-caso,
#btn-nueva-carpeta {
    background-color: #0f172a !important; /* Azul pizarra oscuro obligatorio */
    color: #ffffff !important; /* Texto blanco obligatorio */
    border: none !important;
    padding: 10px 18px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-family: 'Inter', sans-serif !important;
    box-shadow: 0 2px 4px rgba(15,23,42,0.2) !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Efecto Hover para todos */
.legal-panel input[type="submit"]:hover,
.legal-panel button[type="submit"]:hover,
.legal-panel .button:hover,
.legal-panel .button-primary:hover,
.btn-nuevo-caso:hover,
#btn-nueva-carpeta:hover {
    background-color: #1e293b !important; /* Un poco más claro al pasar el mouse */
    transform: translateY(-1px) !important;
}

/* Botoncito "Volver" (Fondo gris) - Lo protegemos para que no se pinte de oscuro */
.legal-panel a.button-back {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
}
.legal-panel a.button-back:hover {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
}


/* ================= ERRADICAR EL AZUL ELÉCTRICO (TEXTOS, TABS Y BADGES) ================= */

/* 1. PESTAÑAS (TABS) - Color y Hover */
.tab-btn {
    color: #64748b !important; /* Gris por defecto para las que no están activas */
}
.tab-btn:hover {
    color: #0f172a !important; /* Azul corporativo al pasar el mouse */
    background-color: #f8fafc !important;
}
.tab-btn.active {
    color: #0f172a !important; /* Azul corporativo para la pestaña seleccionada */
    border-bottom-color: #0f172a !important; /* Línea de abajo corporativa */
}

/* 2. ETIQUETAS DE ESTADO (Apelación, Ejecución, etc.) */
.badge {
    color: #0f172a !important; /* Texto corporativo */
    background-color: #e2e8f0 !important; /* Fondo gris platinado/neutral */
    border: 1px solid #cbd5e1 !important; /* Borde sutil */
    font-weight: 800 !important;
}

/* 3. LÍNEA LATERAL DE LOS COMENTARIOS (En la vista del cliente) */
.burbuja-comentario {
    border-left-color: #0f172a !important;
}

/* 4. CAZADOR DE TEXTOS AZULES INYECTADOS EN PHP (Usuario, Drive, etc.) */
.legal-content [style*="color: #0f172a"],
.legal-content [style*="color:#0f172a"],
.legal-content [style*="color:#3b82f6"] {
    color: #0f172a !important;
}

/* 5. CAZADOR DE BORDES AZULES INYECTADOS EN PHP (Línea de comentarios en vista Admin) */
.legal-content [style*="border-left: 3px solid #3b82f6"] {
    border-left: 3px solid #0f172a !important;
}

.element-style{
    color: #0f172a !important;
}

/* ================= SALVAVIDAS: TEXTO BLANCO PARA "VER FICHA" ================= */
.legal-content table.widefat a.button,
.legal-content table.widefat a.button:hover {
    color: #ffffff !important; /* Fuerza el texto a blanco puro sí o sí */
}


/* ================= SALVAVIDAS: BLINDAR EL BOTÓN CERRAR SESIÓN ================= */
.legal-sidebar a.logout-btn,
.legal-sidebar li:last-child a,
.legal-sidebar li:last-child a:hover,
.legal-sidebar li:last-child a:focus,
.legal-sidebar li:last-child a.active {
    background-color: #E2CE9F !important; 
    color: #141C3A !important; 
    transform: none !important; 
    box-shadow: none !important; 
}



/* ================= SUBIR BOTÓN CERRAR SESIÓN EN MÓVIL ================= */
@media screen and (max-width: 768px) {
    .legal-sidebar li:last-child {
        margin-top: 40px !important; /* Quita el salto al fondo y lo pega más arriba */
    }
    .legal-sidebar {
        padding-bottom: 80px !important; /* Le da aire abajo para que la barra de Android/iOS no tape nada */
    }
}