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

/* ====================================================== */
/* RESET GLOBAL DE LAYOUT (Fijar para todo el sistema)   */
/* Asegura que el padding no desborde el ancho elemento  */
/* ====================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}
/* ====================================================== */

:root {
    --primary-color: #0d6efd;
    --mercadopago-color: #009ee3;
    --success-color: #198754;
    --error-color: #dc3545;
    --light-gray: #f8f9fa;
    --dark-gray: #343a40;
    --border-color: #dee2e6;
    --shadow: 0 4px 8px rgba(0,0,0,0.1);
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #f4f7fe;
    color: var(--dark-gray);
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 40px);
}

.login-wrapper {
    width: 100%;
    max-width: 480px;
    background-color: #f8f9fa;
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.login-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Alineado a la izquierda */
    margin-bottom: 30px;
    gap: 15px;
}

.login-title {
    font-size: 1.4em;
    font-weight: 500;
    color: #6c757d; /* Color gris más suave */
    margin: 0;
}

.login-main .card {
    background-color: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: none; /* La sombra ya está en el wrapper */
}

/* Ocultar elementos que no son de login */
/* Ocultar elementos de la estructura principal SOLO en la página de login de CLIENTES */
.login-page .container, .login-page > header, .login-page > footer {
    display: none;
}

.login-page .login-wrapper {
    display: block; /* Asegurarse de que el wrapper es visible */
}

.header-main {
    display: flex;
    flex-direction: column; /* Apilar logo y título */
    align-items: center;
    gap: 10px; /* Espacio entre logo y título */
}

header h1 {
    margin: 0;
    font-size: 1.7em; /* Un punto más pequeño que 1.8em */
    color: var(--dark-gray);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.notification-wrapper {
    position: relative;
}

.notification-bell {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    position: relative;
}

.notification-bell svg {
    width: 28px;
    height: 28px;
    fill: #6c757d;
}

.notification-count {
    position: absolute;
    top: 0;
    right: 0;
    background-color: var(--error-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.notification-panel {
    position: absolute;
    top: 100%;
    right: 0;
    width: 350px;
    max-width: 90vw; /* Asegurar que no se desborde en pantallas pequeñas */
    max-height: 400px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 1001;
}

.notification-panel-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.notification-panel-header h3 {
    margin: 0;
    font-size: 1.1em;
}

.notification-list {
    padding: 0;
    margin: 0;
}

.notification-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background-color: #f8f9fa;
}

.notification-item.unread {
    background-color: #e9f5ff;
    font-weight: bold;
}

.notification-item p {
    margin: 0 0 5px 0;
    font-size: 0.95em;
}

.notification-item .timestamp {
    font-size: 0.8em;
    color: #6c757d;
}


.logo {
    max-width: 220px; /* Tamaño aumentado globalmente */
    margin-bottom: 0;
    flex-shrink: 0;
}

.login-header .logo {
    max-width: 180px; /* Mantiene el tamaño más pequeño solo para el login */
}

h1 {
    /* Estilos del h1 ahora están en .header-center-title */
}

.card {
    background-color: #ffffff;
    border-radius: 16px !important; /* Esquinas más redondeadas */
    box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.04) !important; /* Sombra muy difusa */
    border: none !important; /* Sin bordes */
    padding: 25px;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.input-group input, .input-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-size: 16px;
    box-sizing: border-box;
}

.phone-input-group {
    display: flex;
    gap: 10px;
}
.phone-input-group select {
    flex-basis: 120px;
    flex-shrink: 0;
}
.phone-input-group input {
    flex-grow: 1;
}

#form-upload .input-group input[type="file"] {
    padding: 10px;
    border: 1px dashed var(--border-color);
    background-color: #f8f9fa;
    cursor: pointer;
}

.btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 50px !important; /* Forzar estilo píldora */
    font-size: 16px !important;
    font-weight: 500 !important;
    color: #fff;
    cursor: pointer;
    text-decoration: none; /* Quitar subrayado de los links */
    transition: background-color 0.3s, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.btn .btn-text {
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.btn .loader {
    position: absolute;
}

.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }

.btn:disabled {
    background-color: #adb5bd;
    cursor: not-allowed;
    opacity: 0.65;
}
.btn:disabled:hover {
    opacity: 0.65; /* Evitar cambio de opacidad en hover */
}

.btn-primary { background-color: var(--success-color) !important; }
.btn-success { background-color: var(--success-color); }
.btn-secondary { background-color: #6c757d; }
.btn-secondary:hover { background-color: #5c636a; }
.btn-info { background-color: var(--primary-color); } /* Cambiado a azul */
.btn-danger { background-color: var(--error-color); }

.loader {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mensaje {
    padding: 15px;
    margin-top: 20px;
    border-radius: 8px;
    text-align: center;
}
.error { background-color: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.success { background-color: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.info { background-color: #cff4fc; color: #055160; border: 1px solid #b6effb; }

footer {
    text-align: center;
    margin-top: 30px;
    color: #6c757d;
    font-size: 0.9em;
}

/* --- ESTILOS DEL PORTAL DE CLIENTES --- */
#lista-cuentas {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}
.cuenta-item {
    border: 1px solid var(--border-color);
    border-radius: 32px; /* Reducido para coincidir */
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative; /* Necesario para posicionar el badge y el degradado */
    overflow: hidden; /* Clave para recortar el contenido que se desborda */
}

.cuenta-notification-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 28px;
    height: 28px;
    z-index: 2;
}

.cuenta-notification-icon svg {
    width: 100%;
    height: 100%;
    fill: var(--primary-color);
}

.cuenta-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--error-color);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.cuenta-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.cuenta-item h3 { margin: 0 0 10px 0; color: var(--primary-color); }
.cuenta-item p { margin: 0; color: #6c757d; }

.dashboard-container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-top: 20px;
}
.pago-container {
    margin-top: 30px;
}
.dashboard-column {
    flex: 1 1 320px; /* Permite crecer y encogerse con una base de 320px */
}

/* Ajuste para la flexibilidad de las columnas superiores */
#columna-datos-cuenta {
    flex-grow: 2; /* Le da más prioridad para crecer */
    flex-shrink: 1;
}
#columna-resumen-pago {
    flex-grow: 1;
    flex-shrink: 2; /* Se encogerá más fácilmente si es necesario */
    min-width: 280px; /* Asegura que no se colapse por completo */
}

.dashboard-column-full {
    flex-basis: 100%;
}
.apartado {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.apartado-header {
    background-color: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.apartado-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: var(--primary-color);
}
.apartado-body {
    padding: 20px;
    flex-grow: 1;
}

.apartado-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background-color: #f8f9fa;
}

.apartado-body p:first-child {
    margin-top: 0;
}
#datos-cuenta-content .dato-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}
#datos-cuenta-content .dato-item:last-child {
    border-bottom: none;
}
#datos-cuenta-content .dato-titulo {
    font-weight: 500;
    color: #6c757d;
    margin-right: 15px;
}
#datos-cuenta-content .dato-valor {
    color: var(--dark-gray);
    text-align: right;
    font-weight: 500;
}
.footer-acciones {
    display: flex;
    justify-content: flex-end;
    margin-top: 30px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}
.btn-volver {
    background-color: var(--success-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.3s;
}
.btn-volver:hover {
    background-color: #157347;
}
.btn-volver-rojo {
    background-color: var(--error-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.3s;
}
.btn-volver-rojo:hover {
    background-color: #b02a37;
}

#estado-cuenta-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between; /* Cambiado a space-between */
    align-items: center;
    gap: 15px;
    /* margin-bottom ya no es necesario aquí */
}

#columna-datos-cuenta .apartado-header #estado-cuenta-content {
    margin-bottom: 0; /* Anular el margen que tenía antes */
}

.card-resumen-pago .apartado-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 15px;
}

.resumen-subtitulo {
    font-size: 1em;
    font-weight: 500;
    color: #6c757d;
    margin: 0;
}

.resumen-total {
    font-size: 2.8em;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    line-height: 1.1;
}

.card-resumen-pago .btn {
    width: 100%;
    max-width: 250px; /* Para que no sea excesivamente ancho en desktop */
}

#mapa-container-fullwidth {
    width: 100%;
    height: 250px;
    border-radius: 8px;
    margin-top: 30px;
}


#estado-cuenta-content .estado-item {
    display: inline-flex;
    align-items: center;
    font-size: 1em;
    font-weight: 500;
    margin-bottom: 0; /* Quitado para alinear con flex */
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid transparent;
}

#estado-cuenta-content .estado-icon {
    margin-right: 8px;
    font-size: 1.2em; /* Agrandamos un poco el emoji */
}

/* Estado: Activo (Verde) */
.estado-servicio-activo {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

/* Estado: Pendiente (Celeste) */
.estado-pendiente-de-activación {
    background-color: #cce5ff;
    color: #004085;
    border-color: #b8daff;
}

/* Estado: Advertencia (Naranja) */
.estado-servicio-con-falta-de-pago {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
}

/* Estado: Peligro (Rojo) */
.estado-bloqueo-de-servicio,
.estado-proceso-de-suspensión {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Estado: Inactivo (Gris) */
.estado-servicio-dado-de-baja,
.estado-estado-desconocido {
    background-color: #e2e3e5;
    color: #383d41;
    border-color: #d6d8db;
}

#mapa-container {
    display: none; /* Ocultamos el mapa original dentro de la tarjeta */
}

#lista-facturas {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}
.factura-item {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Distribute space between checkbox, info, and monto */
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease-in-out;
}

.factura-info {
    display: flex;
    flex-direction: column; /* Stack description and date vertically */
    flex-grow: 1; /* Allow info to take available space */
    margin-left: 15px; /* Space between checkbox and info */
}

.factura-vence {
    margin-left: 15px; /* Espacio entre fecha y vencimiento */
    font-style: italic;
    color: #6c757d;
}

.factura-monto {
    margin-left: 15px; /* Space between info and monto */
    /* Existing styles for color and font-weight */
}
.pedido-acciones {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 15px;
}
.pedido-acciones select {
    padding: 5px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
}
.btn-guardar-pedido {
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid var(--primary-color);
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    font-size: 0.9em;
}
.btn-guardar-pedido:hover {
    opacity: 0.9;
}
.btn-ver-detalle {
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid #6c757d;
    background-color: #6c757d;
    color: white;
    cursor: pointer;
    font-size: 0.9em;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-ver-detalle:hover {
    background-color: #5a6268;
    border-color: #545b62;
}

.total-a-pagar {
    text-align: right;
    font-size: 1.5em;
    font-weight: 700;
    margin: 0; /* Quitado el margen superior e inferior */
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
}
.total-a-pagar span {
    font-size: 0.8em;
    color: #6c757d;
    font-weight: 500;
}
.total-a-pagar strong {
    font-size: 1.2em;
    color: var(--dark-gray);
}


.status-container { text-align: center; padding: 20px 0; }
.status-icon { margin: 0 auto 20px auto; width: 80px; height: 80px; }
.status-icon svg { width: 100%; height: 100%; }
.status-success svg { fill: var(--success-color); }
.status-failure svg { fill: var(--error-color); }
.status-pending svg { fill: #ffc107; }

.consola-log {
    background-color: #212529;
    color: #f8f9fa;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    padding: 15px;
    border-radius: 8px;
    height: 300px;
    overflow-y: auto;
    white-space: pre-wrap; /* Clave para respetar saltos de línea */
    word-wrap: break-word;
    margin-top: 20px;
}

/* --- ESTILOS PARA LA PÁGINA DE GESTIÓN --- */
.back-to-dashboard {
    margin-bottom: 20px;
    text-align: left;
}
.back-to-dashboard a {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 500;
}
.back-to-dashboard a:hover {
    text-decoration: underline;
}



.modal {
    display: none;
    position: fixed !important;
    z-index: 9999 !important;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden; /* Evita scroll fantasma en el fondo */
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #ffffff;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important; /* Mata el margen que lo empujaba hacia abajo */
    padding: 25px;
    border-radius: 16px;
    border: none;
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh; /* Si es muy largo, no se sale de la pantalla */
    overflow-y: auto; /* Scrollea por dentro del cuadro */
}

/* --- ESTILOS PARA EL MODAL DE QR --- */
.qr-code-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 25px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
}
#qr-image {
    max-width: 220px;
    width: 100%;
    height: auto;
    border: 1px solid var(--border-color);
}
.qr-monto {
    font-size: 1.2em;
    font-weight: 500;
    margin-top: 15px;
}
.qr-monto strong {
    color: var(--primary-color);
    font-weight: 700;
}
.qr-info {
    text-align: center;
    font-size: 0.9em;
    color: #6c757d;
}


/* --- ESTILOS PARA EL CONTENIDO DEL MODAL DE PEDIDO --- */
.modal-content .container {
    padding: 0; /* Resetear padding para que no haya doble padding */
    max-width: 100%;
}

.modal-content .card {
    box-shadow: none;
    border: none;
    padding: 0;
}

.modal-content .pedido-header {
    padding-bottom: 15px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
}

.modal-content .pedido-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: var(--primary-color);
}

.modal-content .pedido-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.modal-content .info-item {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.modal-content .info-item strong {
    display: block;
    color: #6c757d;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.modal-content .info-item span {
    font-weight: 500;
    font-size: 1.1em;
}

.modal-content .pedido-articulos h3 {
    font-size: 1.3em;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.modal-content .articulos-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.modal-content .articulos-table th,
.modal-content .articulos-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.modal-content .articulos-table th {
    background-color: #f8f9fa;
    font-weight: 700;
}

.modal-content .articulos-table .text-right {
    text-align: right;
}

.modal-content .pedido-total {
    text-align: right;
    font-size: 1.4em;
    font-weight: 700;
    margin-top: 20px;
}

.modal-content .pedido-total span {
    color: var(--success-color);
}

.modal-content .footer-acciones {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

/* --- Media Queries para el modal --- */
@media (max-width: 768px) {
    .modal-content .pedido-info {
        grid-template-columns: 1fr; /* Una columna en móviles */
    }

    .modal-content .articulos-table {
        display: block;
        width: 100%;
    }
    .modal-content .articulos-table thead,
    .modal-content .articulos-table tbody,
    .modal-content .articulos-table tr {
        display: block;
    }

    .modal-content .articulos-table thead {
        display: none; /* Ocultar cabecera */
    }

    .modal-content .articulos-table tr {
        border: 1px solid var(--border-color);
        margin-bottom: 15px;
    }

    .modal-content .articulos-table td {
        display: flex;
        justify-content: space-between;
        padding: 10px;
        border: none;
        border-bottom: 1px solid #f0f0f0;
    }
    .modal-content .articulos-table td:last-child {
        border-bottom: none;
    }

    .modal-content .articulos-table td::before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 10px;
    }

    .modal-content .articulos-table .text-right {
        text-align: left; /* Forzar alineación para que el flexbox funcione */
    }

    .modal-content .pedido-total {
        text-align: center;
        font-size: 1.6em;
    }
}


.modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 15px;
    right: 25px;
}

.modal-close:hover,
.modal-close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

@keyframes fadeIn {
    from {opacity: 0}
    to {opacity: 1}
}

@keyframes slideIn {
    from {top: -50px; opacity: 0}
    to {top: 0; opacity: 1}
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 20% auto;
    }
}

.progress-bar-container { /* ... (estilos existentes) ... */ }
.progress-bar { /* ... */ }
.progress-bar-container span { /* ... */ }

.download-area {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}
.download-area .btn {
    width: auto;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: stretch; /* Mantiene la misma altura */
}

.button-group .download-area a,
.button-group .btn-confirmar {
    padding: 0 25px !important; /* Padding solo horizontal */
    width: auto;
    flex-shrink: 0;
    height: 50px; /* Altura fija para ambos botones */
    display: flex;
    align-items: center;
    justify-content: center;
}

.button-group.payment-buttons {
    display: flex;
    gap: 15px; /* Espacio entre los botones */
}
.button-group.payment-buttons .btn {
    flex: 1 1 0; /* Cada botón ocupa el mismo espacio */
    width: 0; /* Necesario para que flex-basis funcione correctamente */
}


.whatsapp-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--success-color);
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background-color 0.2s;
}
.whatsapp-link:hover {
    background-color: rgba(25, 135, 84, 0.1);
}
.analisis-resultado h4 {
    margin-top: 0;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.analisis-ok h4 { color: var(--success-color); }
.analisis-warn h4 { color: #fd7e14; }

.cuenta-existente-item {
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    border: 1px solid transparent;
}
.fondo-verde { background-color: rgba(25, 135, 84, 0.1); border-color: rgba(25, 135, 84, 0.2); }
.fondo-celeste { background-color: rgba(13, 202, 240, 0.1); border-color: rgba(13, 202, 240, 0.2); }
.fondo-rojo { background-color: rgba(220, 53, 69, 0.1); border-color: rgba(220, 53, 69, 0.2); }
.cuenta-acciones { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; }
.btn-accion {
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid;
    cursor: pointer;
    background-color: white;
}

/* Ajuste para achicar todo el box de login */
#consulta-section {
    max-width: 450px; /* Ancho máximo para el contenedor del formulario */
    margin-left: auto;
    margin-right: auto;
}

#saldo-cuenta-container .btn {
    width: auto; /* Ancho automático */
    padding: 8px 15px; /* Padding más pequeño */
    font-size: 14px; /* Fuente más pequeña */
}
.btn-aplicar-solicitud {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.input-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.input-row .input-group {
    margin-bottom: 20px; /* Mantener el margen inferior consistente */
}

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

.btn-qr {
    background-color: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.form-row-login {
    display: flex;
    gap: 15px;
    align-items: flex-end; /* Alinea los elementos por su base */
}

.form-row-login .input-group {
    margin-bottom: 20px;
}

.form-row-login .input-group-grow {
    flex-grow: 1; /* Hace que este grupo ocupe el espacio restante */
}

.form-row-login #tipo-doc {
    width: auto; /* Permite que el select se ajuste a su contenido */
    min-width: 90px; /* Un ancho mínimo para que no se vea mal */
}

.form-row {
    display: flex;
    gap: 20px; /* Espacio entre los elementos */
    align-items: flex-start; /* Alinear items al inicio */
}

.form-row .input-group {
    flex: 1; /* Permitir que los elementos crezcan y ocupen el espacio */
}

/* --- ESTILOS RESPONSIVOS --- */
@media (max-width: 992px) {
    body {
        padding: 10px; /* Reducir padding general en móviles */
        align-items: flex-start; /* Alinear contenido al inicio en móviles */
        padding-top: 20px;
    }

    .container {
        padding: 0 10px;
    }

    header {
        flex-direction: column;
        text-align: center;
        gap: 10px; /* Reducir el espacio en el header */
    }

    header h1 {
        font-size: 1.5em; /* Reducir tamaño del título principal */
        text-align: center;
    }

    .card {
        padding: 20px; /* Reducir padding de las tarjetas */
    }

    .form-row-login {
        flex-direction: column;
        gap: 0;
    }

    .form-row-login .input-group {
        margin-bottom: 20px; /* Mantener el espaciado entre grupos */
    }

    .input-row, .form-row {
        flex-direction: column;
        gap: 0; /* Eliminar el gap para que los input-group se peguen */
    }
    .apartado-documentacion .form-row {
        flex-direction: column;
        gap: 20px; /* Re-aplicar gap para la sección de documentos en móvil */
    }

    /* Asegurar que los selectores con ancho fijo ocupen todo el espacio */
    #form-paso2 select[style*="width"] {
        width: 100% !important;
    }

    /* Ajustar la sección del router para móviles */
    #seccion-router-grid {
        flex-direction: column;
    }
    #vista-previa-router {
        margin-left: 0;
        margin-top: 20px; /* Añadir espacio superior */
        align-self: center; /* Centrar la vista previa */
    }
    #imagen-plan {
        height: auto !important;
        max-width: 150px; /* Limitar el ancho en móviles */
        margin-left: auto;
        margin-right: auto;
    }
    .phone-input-group {
        flex-direction: column;
    }
    .phone-input-group select {
        flex-basis: auto;
    }

    /* --- NUEVOS AJUSTES PARA LA PÁGINA DE SALDO --- */
    .dashboard-container {
        flex-direction: column;
        gap: 20px;
    }

    .dashboard-column {
        min-width: 100%;
    }

    .apartado-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .resumen-total {
        font-size: 2.2em;
    }

    #mapa-container-fullwidth {
        height: 200px;
    }

    .factura-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 15px;
    }

    .factura-item > * {
        flex-basis: auto !important;
        width: 100%;
        text-align: left !important;
        margin-left: 0 !important;
    }

    .factura-info {
        order: 1;
    }

    .factura-monto {
        order: 2;
        font-size: 1.2em;
        text-align: right !important;
    }
    
    /* Específico para el historial unificado */
    .factura-header {
        display: flex;
        font-weight: bold;
        padding-bottom: 10px;
        border-bottom: 2px solid #333;
    }
    
    .factura-header span {
        flex: 1;
        text-align: left;
    }

    .factura-header .accion-cell {
        text-align: center;
    }

    @media (max-width: 768px) {
        .factura-header {
            display: none; /* Ocultar cabecera en móviles */
        }

        #lista-facturas-unificada .factura-item {
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
        }

        #lista-facturas-unificada .factura-item span[data-label] {
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: center;
            text-align: right !important;
            font-size: 0.9em; /* Reducir tamaño de fuente */
        }
    
        .accion-impaga {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 15px; /* Espacio entre checkbox y PDF */
        }

        #lista-facturas-unificada .factura-item span[data-label]::before {
            content: attr(data-label);
            font-weight: bold;
            text-align: left;
            margin-right: 10px;
        }
        
        #lista-facturas-unificada .factura-item span[data-label="Acción"] {
            justify-content: flex-end;
        }
    }


    .button-group.payment-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .button-group.payment-buttons .btn {
        width: 100%;
    }

    .total-a-pagar {
        justify-content: center;
        font-size: 1.2em;
        padding: 10px 0;
    }
}



.btn-pdf {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}
.btn-pdf svg {
    width: 22px;
    height: 22px;
    fill: #dc3545; /* Rojo */
    transition: fill 0.2s;
}
.btn-pdf:hover {
    background-color: rgba(220, 53, 69, 0.1); /* Fondo rojo claro al pasar el mouse */
}

.estado-factura {
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.estado-pagada {
    background-color: #28a745; /* Verde éxito */
}
.estado-impaga {
    background-color: #dc3545; /* Rojo peligro */
}

/* --- ESTILOS PARA LOS NUEVOS DASHBOARDS --- */
.stat-number {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--primary-color);
    margin: 10px 0 0 0;
}

.dashboard-card .card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.dashboard-card h3 {
    margin: 0;
    font-size: 1.1em;
    color: #6c757d;
    font-weight: 500;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 400px; /* Altura por defecto para el gráfico */
}

.four-columns {
    grid-template-columns: repeat(4, 1fr);
}

.five-columns {
    grid-template-columns: repeat(5, 1fr);
}

/* Colores para las tarjetas del dashboard operativo */
.card-activos { background-color: rgba(25, 135, 84, 0.1); }
.card-aviso-suspension { background-color: rgba(255, 159, 64, 0.1); }
.card-falta-pago { background-color: rgba(255, 193, 7, 0.1); }
.card-bloqueados { background-color: rgba(108, 117, 125, 0.1); }
.card-baja { background-color: rgba(220, 53, 69, 0.1); }

.card-activos .stat-number { color: #198754; }
.card-aviso-suspension .stat-number { color: #ff9f40; }
.card-falta-pago .stat-number { color: #ffc107; }
.card-bloqueados .stat-number { color: #6c757d; }
.card-baja .stat-number { color: #dc3545; }

/* --- NUEVOS ESTILOS PARA TARJETAS FINANCIERAS --- */
.card-facturado { background-color: rgba(54, 162, 235, 0.1); }
.card-cobrado { background-color: rgba(25, 135, 84, 0.1); }
.card-deuda-activos { background-color: rgba(255, 159, 64, 0.1); }
.card-deuda-inactivos { background-color: rgba(220, 53, 69, 0.1); }

.card-facturado .stat-number { color: #36a2eb; }
.card-cobrado .stat-number { color: #198754; }
.card-deuda-activos .stat-number { color: #ff9f40; }
.card-deuda-inactivos .stat-number { color: #dc3545; }

.card-footer-indices {
    border-top: 1px solid rgba(0,0,0,0.1);
    padding: 10px 15px;
    margin-top: 15px;
    display: flex;
    justify-content: space-around;
    gap: 10px;
}
.indice-item {
    text-align: center;
}
.indice-item span {
    font-size: 0.8em;
    color: #6c757d;
    display: block;
}
.indice-item strong {
    font-size: 1.1em;
    font-weight: 700;
}

@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columnas en tablets */
    }
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 576px) {
    .dashboard-grid {
        grid-template-columns: 1fr; /* 1 columna en móviles */
    }
    .stat-number {
        font-size: 2em;
    }
    .chart-container {
        height: 300px; /* Menos altura en móviles */
    }
}

/* --- ESTILOS PARA FILTROS DE DASHBOARD --- */
.form-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.form-filters .input-group {
    flex: 1 1 150px; /* Crece y se encoge, con una base de 150px */
    margin-bottom: 0;
}

.form-filters .btn {
    flex: 0 1 auto; /* No crece, se encoge si es necesario */
    width: auto;
    padding: 12px 25px;
}

/* --- ESTILOS PARA GESTIÓN DE USUARIOS --- */
.permisos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.permiso-item {
    display: flex;
    align-items: center;
    gap: 10px;
}
.permiso-item input[type="checkbox"] {
    width: auto;
}
.user-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}
.user-table th, .user-table td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: left;
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px; /* Evita que una columna se haga excesivamente ancha */
}

.user-table td:last-child {
    max-width: none; /* Permite que la columna de acciones tenga el ancho que necesite */
    width: 1%; /* Truco para que ocupe el mínimo espacio posible */
}
.user-table th {
    background-color: #f8f9fa;
}
.user-table .celda-cliente {
    white-space: nowrap;
}
.btn-edit, .btn-delete {
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    font-weight: 500;
}
.btn-edit {
    background-color: var(--primary-color);
    margin-right: 5px;
}
.btn-delete {
    background-color: var(--error-color);
}
.btn-resend {
    background-color: #ffc107; /* Amarillo */
    margin-right: 5px;
}
.btn-resend {
    background-color: #ffc107; /* Amarillo */
    margin-right: 5px;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: #212529; /* Texto oscuro para mejor contraste */
    font-weight: 500;
}

/* --- NUEVOS ESTILOS PARA FORMULARIO DE USUARIOS --- */
.user-form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
}
.form-column {
    flex: 1;
    min-width: 300px;
}
.form-full-width {
    flex-basis: 100%;
    display: flex;
    gap: 15px;
}
.table-responsive {
    overflow-x: auto;
}
@media (max-width: 768px) {
    .user-form-grid {
        flex-direction: column;
    }
}

/* --- NUEVOS ESTILOS PARA HEADER --- */
.header-user-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}
.welcome-user {
    margin: 0;
    font-weight: 500;
    color: #6c757d;
}
.header-buttons {
    display: flex;
    gap: 10px;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 0.9em;
    font-weight: 500;
    width: auto;
}

/* --- ESTILOS PARA MESA DE AYUDA --- */
#info-cliente-div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

/* --- ESTILOS PARA MÓDULO DE COMUNICACIONES --- */
#form-nueva-comunicacion #destinatarios,
#form-nueva-comunicacion #asunto {
    max-width: 30ch; /* Limita el ancho a aprox. 30 caracteres */
    width: 100%; /* Asegura que sea responsivo */
}

#form-nueva-comunicacion #mensaje {
    min-height: 150px; /* Aumenta la altura mínima */
    resize: vertical; /* Permite al usuario redimensionar verticalmente */
}

#modal-ayuda .modal-content {
    max-width: 500px;
}

#form-mesa-ayuda textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
    resize: vertical;
    min-height: 100px;
}

/* --- ESTILOS PARA MODAL DE CONVERSACIÓN --- */
#modal-conversacion .modal-content {
    max-width: 600px;
}

.chat-body {
    height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    background-color: #E5DDD5; /* Fondo similar a WhatsApp */
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-bubble {
    max-width: 75%;
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 1em;
    line-height: 1.4;
    position: relative;
}

.chat-bubble .autor-nombre {
    font-weight: 700;
    font-size: 0.9em;
    margin: 0 0 5px 0;
    color: #0056b3;
}

.bubble-enviado .autor-nombre {
    color: #155724;
}

.chat-bubble .texto {
    margin: 0;
    white-space: pre-wrap; /* Para respetar saltos de línea en el mensaje */
    word-wrap: break-word; /* Para forzar el ajuste de palabras largas */
    word-break: break-word; /* Asegura el corte de palabras para evitar desbordamiento */
}

.chat-bubble .fecha {
    display: block;
    font-size: 0.75em;
    color: #888;
    margin-top: 5px;
    text-align: right;
}

.bubble-recibido {
    background-color: #FFFFFF; /* Burbuja blanca para mensajes recibidos */
    align-self: flex-start;
    border-top-left-radius: 0;
}

.bubble-enviado {
    background-color: #DCF8C6; /* Burbuja verde claro para mensajes enviados */
    align-self: flex-end;
    border-top-right-radius: 0;
}

#form-respuesta-suceso textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
    resize: vertical;
}

/* --- ESTILOS PARA HEADER DE HISTORIAL --- */
.historial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px; /* Espacio antes de la tabla */
    flex-wrap: wrap;
    gap: 15px;
}

.historial-header h2 {
    margin: 0;
}

.filtro-historial {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filtro-historial label {
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
}


/* Reducir tamaño de fuente del título del chat */
#conversacion-titulo {
    font-size: 1.2em; /* Ajusta este valor según sea necesario */
}


/* Estilo para el badge de notificación en la tabla de comunicaciones */
.notification-badge {
    background-color: var(--error-color);
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.8em;
    font-weight: bold;
    margin-left: 5px;
    display: inline-block;
    line-height: 1;
    vertical-align: middle;
}


/* Estilo para el estado finalizado en la tabla de comunicaciones */
.estado-finalizado {
    background-color: #6c757d; /* Gris secundario */
}


/* Estilo para notificaciones finalizadas en el panel del cliente */
.notification-item.finalizado {
    background-color: #f8f9fa; /* Un gris muy claro */
    opacity: 0.7;
}

/* --- ESTILOS RESPONSIVOS ADICIONALES PARA NOTIFICACIONES Y CHAT --- */
@media (max-width: 768px) {
    /* Ajustes para el panel de notificaciones */
    .notification-panel {
        /* Convertir de dropdown a modal centrado en móviles */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 500px;
        height: auto; /* Altura basada en contenido */
        max-height: 80vh; /* Con un máximo de altura */
        right: auto; /* Anular posicionamiento de dropdown */
        box-shadow: 0 8px 24px rgba(0,0,0,0.2);
        border-radius: 12px;
        display: flex;
        flex-direction: column;
    }

    /* Ajustes para el modal de conversación/chat */
    #modal-conversacion .modal-content {
        width: 95%;
        margin: 15% auto; /* Margen superior mayor para mejor centrado vertical */
        padding: 15px;
    }

    .chat-body {
        height: 60vh; /* Más altura para el cuerpo del chat */
    }

    #conversacion-titulo {
        font-size: 1.1em; /* Título un poco más pequeño */
    }
}

/* --- ESTILOS PARA EL NUEVO DASHBOARD DE GESTIÓN --- */

.gestion-header {
    width: 100%;
    height: 70px;
    flex-shrink: 0; /* Nuevo */
    display: flex;
    align-items: center;
    background: #ffffff;
    padding: 0 20px;
    box-sizing: border-box;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    position: relative;
}

.gestion-logo {
    max-width: 150px;
}

.gestion-user-controls {
    text-align: right;
}

.gestion-welcome-user {
    margin: 0 0 5px 0;
    font-weight: 500;
}

.gestion-btn-logout {
    background-color: #dc3545;
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9em;
}

.gestion-nav-menu {
    background-color: #1A1A1A;
    width: 80px;
    min-width: 80px;
    border-radius: 16px;
    margin: 15px 10px 15px 20px;
    height: calc(100% - 30px);
    display: flex;
    flex-direction: column;
    padding-top: 15px;
    overflow: visible; /* CRÍTICO: Permite que el dropdown salga de la barra negra */
    z-index: 1000; /* Asegura que se dibuje por encima del wrapper principal */
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.menu-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--dark-gray);
    margin-right: 15px;
}

@media (max-width: 1024px) {
    .menu-toggle-btn {
        display: block;
    }
}

.gestion-nav-tabs {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    border-bottom: 2px solid var(--primary-color);
}

.gestion-nav-tab {
    margin-bottom: -2px;
}

/* Asegurar que los items inactivos también mantengan el ancho y centrado */
.gestion-nav-link {
    color: #a3aed1 !important;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
    width: calc(100% - 20px) !important;
    margin: 0 auto 10px auto !important;
    border-radius: 10px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 12px 0 !important;
}

.gestion-nav-link:hover {
    background-color: var(--light-gray);
    color: var(--primary-color);
}



.gestion-tab-content {
    background-color: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow);
    padding: 30px;
}

.gestion-tab-pane {
    display: none;
}

.gestion-tab-pane.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gestion-iframe-container {
    width: 100%;
    height: 70vh;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    /* Remove min-width to allow responsive resizing */
}

@media (max-width: 768px) {
    .gestion-nav-tabs {
        flex-direction: column;
        border-bottom: none;
    }
    .gestion-nav-tab {
        margin-bottom: 5px;
    }
    /* Asegurar que los items inactivos también mantengan el ancho y centrado */
.gestion-nav-link {
    color: #a3aed1 !important;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
    width: calc(100% - 20px) !important;
    margin: 0 auto 10px auto !important;
    border-radius: 10px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 12px 0 !important;
}
    
    .gestion-header {
    width: 100%;
    height: 70px;
    flex-shrink: 0; /* Nuevo */
    display: flex;
    align-items: center;
    background: #ffffff;
    padding: 0 20px;
    box-sizing: border-box;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    position: relative;
}
    .gestion-user-controls {
        text-align: center;
        margin-top: 10px;
    }
}

/* --- ESTILOS PARA MENÚ DESPLEGABLE --- */
.gestion-nav-tab.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none !important;
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 10px; /* Separación sutil del sidebar negro */
    background-color: #f8fafc;
    padding: 10px 0;
    list-style: none;
    width: 220px;
    border-radius: 10px; /* Bordes totalmente redondeados */
    box-shadow: 4px 4px 15px rgba(0,0,0,0.1);
    border: 1px solid #cbd5e1;
    z-index: 2000; /* Siempre por encima de todo */
}

.dropdown.open > .dropdown-menu {
    display: none !important;
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 10px; /* Separación sutil del sidebar negro */
    background-color: #f8fafc;
    padding: 10px 0;
    list-style: none;
    width: 220px;
    border-radius: 10px; /* Bordes totalmente redondeados */
    box-shadow: 4px 4px 15px rgba(0,0,0,0.1);
    border: 1px solid #cbd5e1;
    z-index: 2000; /* Siempre por encima de todo */
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--dark-gray);
    font-weight: 500;
    transition: background-color 0.2s;
}

.dropdown-menu a:hover {
    background-color: var(--light-gray);
}

/* --- ESTILOS PARA SUBMENÚ LATERAL --- */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu .dropdown-menu {
    display: none !important;
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 10px; /* Separación sutil del sidebar negro */
    background-color: #f8fafc;
    padding: 10px 0;
    list-style: none;
    width: 220px;
    border-radius: 10px; /* Bordes totalmente redondeados */
    box-shadow: 4px 4px 15px rgba(0,0,0,0.1);
    border: 1px solid #cbd5e1;
    z-index: 2000; /* Siempre por encima de todo */
}

.dropdown-submenu.open > .dropdown-menu {
    display: none !important;
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 10px; /* Separación sutil del sidebar negro */
    background-color: #f8fafc;
    padding: 10px 0;
    list-style: none;
    width: 220px;
    border-radius: 10px; /* Bordes totalmente redondeados */
    box-shadow: 4px 4px 15px rgba(0,0,0,0.1);
    border: 1px solid #cbd5e1;
    z-index: 2000; /* Siempre por encima de todo */
}

/* Estilo para botones de advertencia (naranja) */
.btn-warning, .btn-warning:hover, .btn-warning:active, .btn-warning:focus {
    background-color: #ffc107 !important;
    color: #212529 !important;
    border-color: #ffc107 !important;
}

/* --- NUEVOS ESTILOS PARA SOLICITUD DE SERVICIO (PASO 2) --- */
.router-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    background-color: #fdfdff;
}

.router-preview {
    margin-top: 20px;
    padding: 20px;
    border: 1px dashed var(--primary-color);
    border-radius: 8px;
    text-align: center;
    background-color: #f8f9fa;
}

.router-preview img {
    max-width: 100%;
    max-height: 180px;
    height: 180px; /* Altura fija para el contenedor */
    object-fit: contain; /* Asegura que la imagen quepa sin deformarse */
    margin-bottom: 15px;
    border-radius: 8px;
}

.router-preview span {
    display: block;
    font-weight: 700;
    font-size: 1.4em;
    color: var(--primary-color);
}

.apartado-documentacion {
    border: 1px solid var(--success-color);
    border-radius: 8px;
    margin-top: 30px;
    background-color: #f6fff9;
}

.apartado-documentacion .apartado-header {
    background-color: rgba(25, 135, 84, 0.1);
    border-bottom: 1px solid rgba(25, 135, 84, 0.2);
}

.apartado-documentacion .apartado-header h3 {
    color: var(--success-color);
    font-size: 1.3em;
}

.apartado-documentacion .apartado-body {
    padding: 25px;
}

.required-star {
    color: var(--error-color);
    font-weight: bold;
}

/* Estilos para la sección de historial de facturas */
.historial-toggle {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.historial-toggle a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.historial-toggle a:hover {
    color: var(--dark-primary-color);
    text-decoration: underline;
}

#historial-facturas-container {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px dashed #ddd;
}

#historial-facturas-container .apartado-header h3 {
    color: #555; /* Un color más suave para el título del historial */
}

/* Ajustes menores para asegurar consistencia */
#lista-facturas-impagas .factura-item:last-child,
#lista-facturas-pagadas .factura-item:last-child {
    border-bottom: none;
}


/* --- ESTILOS PARA OPCIONES DE ENVÍO EN MAILING_INICIO.PHP --- */
.opciones-envio-grid {
    display: flex;
    gap: 25px;
    margin-top: 25px;
}

.opcion-envio-card {
    flex: 1;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border: 1px solid transparent;
}

.opcion-envio-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}

.opcion-envio-card h3 {
    margin: 0 0 10px 0;
    font-size: 1.4em;
}

.opcion-envio-card p {
    margin: 0;
    font-size: 0.95em;
    line-height: 1.5;
}

/* Colores específicos para cada tarjeta */
#btn-iniciar-proceso {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

#btn-iniciar-individual {
    background-color: #ffc107; /* Amarillo (Warning) */
    color: #212529; /* Texto oscuro para contraste */
    border-color: #ffc107;
}

#btn-iniciar-individual h3 {
    color: #5d4a00;
}


/* --- AJUSTE PARA ANCHO DE SELECTS EN MODALES --- */
.modal-content .input-group select {
    width: auto;
    min-width: 200px; /* Asegura un ancho mínimo legible */
}

/* --- NUEVOS ESTILOS PARA PEDIDOS PENDIENTES --- */
#lista-pedidos-pendientes .factura-item {
    display: grid;
    grid-template-columns: 1fr auto auto; /* Descripción | Monto | Acciones */
    gap: 15px;
    align-items: center;
}

#lista-pedidos-pendientes .factura-info {
    margin-left: 0;
}

#lista-pedidos-pendientes .pedido-monto {
    text-align: right;
}

#lista-pedidos-pendientes .factura-monto {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--dark-gray);
    margin-left: 0;
}

.pedido-acciones-nuevo {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.pedido-acciones-nuevo .btn {
    width: auto; /* Ancho automático para los botones */
    flex-grow: 0;
}

.btn-rechazar-pedido {
    background-color: #6c757d; /* Gris secundario */
    border-color: #6c757d;
}
.btn-rechazar-pedido:hover {
    background-color: #5a6268;
}

.loader-sm {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* --- Media Queries para Pedidos Pendientes --- */
@media (max-width: 768px) {
    #lista-pedidos-pendientes .factura-item {
        grid-template-columns: 1fr; /* Apilar todo en una columna */
        gap: 15px;
        text-align: center;
    }

    #lista-pedidos-pendientes .factura-info,
    #lista-pedidos-pendientes .pedido-monto,
    #lista-pedidos-pendientes .pedido-acciones-nuevo {
        text-align: center;
        justify-content: center;
        width: 100%;
    }

    #lista-pedidos-pendientes .pedido-monto {
        order: -1; /* Mover el monto arriba de todo */
    }
}

/* --- NUEVOS ESTILOS PARA TARJETA DE SELECCIÓN DE CUENTA --- */
.cuenta-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cuenta-info-principal {
    flex-grow: 1;
}

.cuenta-detalle {
    font-size: 0.9em; /* Letra un punto más chica */
    color: #6c757d;
}

.cuenta-detalle span {
    font-weight: 500;
}

.cuenta-categoria {
    margin-left: 20px;
}

.cuenta-categoria-esquina {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%; /* Ocupa todo el ancho para el degradado */
    --solid-width: 50px; /* Valor por defecto */
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.categoria-texto-vertical {
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-transform: uppercase;
    line-height: 1.2;
    text-align: center;
    padding-right: 10px; /* Espacio desde el borde derecho */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
    z-index: 1; /* Asegura que el texto esté sobre el fondo */
}

/* Colores de las categorías usando degradado */
.categoria-bronce { background: linear-gradient(to left, #CD7F32 var(--solid-width), transparent calc(var(--solid-width) + 300px)); }
.categoria-plata { background: linear-gradient(to left, #A9A9A9 var(--solid-width), transparent calc(var(--solid-width) + 300px)); }
.categoria-gold { background: linear-gradient(to left, #FFD700 var(--solid-width), transparent calc(var(--solid-width) + 300px)); }
.categoria-black { background: linear-gradient(to left, #000000 var(--solid-width), transparent calc(var(--solid-width) + 300px)); }

/* Estilos para la Modal de Detalles de Cobro */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.6); 
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; 
    padding: 25px;
    border: 1px solid #888;
    width: 80%;
    max-width: 700px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-content h2 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    font-size: 1.5rem;
}

.modal-content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #333;
}

.modal-content .btn {
    /* Se elimina el width: 100% forzado */
    padding: 10px 20px; /* Tamaño normal */
    font-size: 1rem; /* Letra normal (16px) */
    border-radius: 8px; /* Bordes suaves */
    transition: all 0.2s ease;
}


/* --- ESTILOS PARA ALINEAR FILTROS EN MODAL --- */
.form-row-flex {
    display: flex;
    gap: 20px;
    align-items: flex-end; /* Alinea los elementos por su base */
    flex-wrap: wrap; /* Permite que los elementos pasen a la siguiente línea si no hay espacio */
}

.form-row-flex .input-group {
    margin-bottom: 20px; /* Mantiene el espaciado inferior */
}


/* --- ESTILOS PARA MÓDULO DE DÉBITOS AUTOMÁTICOS --- */
.debitos-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.debitos-cards-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
}

.debitos-card-link {
    text-decoration: none;
    color: inherit;
    flex-basis: 300px;
    display: flex;
}

.debitos-card-link .card {
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    border-radius: 12px;
}

.debitos-card-link:hover .card {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

#debitos-card-generar {
    background-color: #28a745;
    color: white;
}

#debitos-card-procesar {
    background-color: #dc3545;
    color: white;
}

.debitos-form-inline-group {
    display: flex;
    align-items: flex-end;
    gap: 15px;
    flex-wrap: wrap;
}

.debitos-form-inline-group .input-group {
    margin-bottom: 0;
}

.debitos-form-inline-group select,
.debitos-form-inline-group input[type="file"] {
    width: auto;
}

.debitos-form-inline-group button {
    width: auto;
    white-space: nowrap;
}

.modulo-debitos-container {
    font-size: 0.875rem; /* 14px si la base es 16px, equivalente a reducir ~2pt */
}

/* --- ESTILOS PARA LA PÁGINA DE LOGIN --- */
/* NUEVOS ESTILOS PARA OPCIONES DE FORMULARIO */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 0.9em;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

.checkbox-group label {
    margin: 0;
    color: #6c757d;
}

/* --- ESTILOS RESPONSIVOS PARA EL NUEVO LOGIN --- */
@media (max-width: 576px) {
    .login-wrapper {
        padding: 20px;
    }
    .login-main .card {
        padding: 20px;
    }
    .login-title {
        font-size: 1.8em;
    }
}

/* --- FIX RESPONSIVE: Ajuste para el ancho del contenedor principal --- */
/* Cuando el body NO tiene la clase .login-page, el wrapper puede expandirse */
/* --- FIX RESPONSIVE DEFINITIVO --- */
.login-wrapper.portal-activo {
    max-width: 1200px;
    margin-top: 20px;
    margin-bottom: 20px;
}



/* --- ESTILOS PARA MÓDULO DE CONFIGURACIÓN DEL SISTEMA --- */
.modulo-sistema-container {
    font-size: 14px; /* Reducir 2pt desde 16px base */
}

.form-inline-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    align-items: flex-start;
}

.form-inline-grid .input-group {
    flex: 1 1 auto; /* Permite que los elementos crezcan */
    min-width: 250px; /* Ancho mínimo para cada elemento antes de apilarse */
    margin-bottom: 0;
}

.form-inline-grid .input-group select,
.form-inline-grid .input-group input {
    width: 100%; /* El input/select ocupa todo el ancho del .input-group */
}

.form-inline-grid .form-full-width {
    flex-basis: 100%;
    margin-top: 15px;
}

.breadcrumb {
    margin-bottom: 20px;
    font-size: 0.9em;
    color: #6c757d;
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    color: #343a40;
    font-weight: 500;
}
.login-page .btn {
    border-radius: 50px; /* Estilo píldora */
    font-weight: 500;
    font-size: 16px;
}

/* =========================================
   1. LAYOUT MAESTRO Y SIDEBAR COLAPSABLE (TEMA MODERNO)
   ========================================= */
body.gestion-body {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Alto exacto de la pantalla */
    margin: 0;
    overflow: hidden !important; /* Evita el scroll global, delega el scroll a los hijos */
    background-color: #f4f7fe; /* Fondo gris-azulado moderno */
    font-family: 'Roboto', sans-serif;
}
/* Original gestion-container */
.gestion-container {
    flex-grow: 1; /* Ocupa el espacio entre header y footer */
    display: flex;
    height: 0; /* Necesario para que flex-grow funcione internamente */
    width: 100%;
    overflow: hidden;
}
/* Nuevo layout index */
.gestion-layout-container {
    flex-grow: 1; /* Ocupa el espacio entre header y footer */
    display: flex;
    height: 0; /* Necesario para que flex-grow funcione internamente */
    width: 100%;
    overflow: hidden;
}

/* --- SIDEBAR OSCURO MATE --- */
.gestion-nav-menu {
    background-color: #1A1A1A;
    width: 80px;
    min-width: 80px;
    border-radius: 16px;
    margin: 15px 10px 15px 20px;
    height: calc(100% - 30px);
    display: flex;
    flex-direction: column;
    padding-top: 15px;
    overflow: visible; /* CRÍTICO: Permite que el dropdown salga de la barra negra */
    z-index: 1000; /* Asegura que se dibuje por encima del wrapper principal */
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.sidebar-logo-container {
    display: flex;
    align-items: center;
    margin-right: 30px;
    padding: 0 !important;
    background: transparent !important;
    width: auto !important;
}
.sidebar-logo {
    height: 45px;
    width: auto;
    object-fit: contain;
}
.gestion-nav-tabs {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    list-style: none;
    width: 100%; 
}
/* Asegurar que los items inactivos también mantengan el ancho y centrado */
.gestion-nav-link {
    color: #a3aed1 !important;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
    width: calc(100% - 20px) !important;
    margin: 0 auto 10px auto !important;
    border-radius: 10px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 12px 0 !important;
}
.gestion-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: #ffffff !important;
}

.nav-icon {
    min-width: 30px;
    font-size: 28px; /* Iconos más grandes */
    text-align: center;
    margin: 0;
    color: #64748b;
    transition: color 0.2s;
}
.gestion-nav-link:hover .nav-icon, .gestion-nav-link.active .nav-icon {
    min-width: 30px;
    font-size: 28px; /* Iconos más grandes */
    text-align: center;
    margin: 0;
    color: #64748b;
    transition: color 0.2s;
}
.nav-text {
    display: none !important; /* El usuario ya no quiere los textos visibles, usa tooltips */
}


/* RESET EXTREMO ESTADO ACTIVO SIDEBAR */
/* ESTADO ACTIVO SIDEBAR - LÍNEA INFERIOR */
.gestion-nav-link.active {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border: none !important;
    border-bottom: 3px solid #4318ff !important; /* Línea celeste abajo */
    border-radius: 10px !important; /* Bordes suaves en todo el botón */
    box-shadow: none !important;
    width: calc(100% - 20px) !important; /* Botón ligeramente más angosto que el menú */
    margin: 0 auto 10px auto !important; /* Centrado horizontalmente */
    box-sizing: border-box !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 12px 0 !important; /* Ajuste de espacio vertical */
}
.gestion-nav-tab {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* --- SUBMENÚS FLOTANTES (POP-OUT) --- */
.gestion-nav-tab.dropdown {
    position: relative; /* Para anclar el submenú flotante */
}
.dropdown-menu {
    display: none !important;
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 10px; /* Separación sutil del sidebar negro */
    background-color: #f8fafc;
    padding: 10px 0;
    list-style: none;
    width: 220px;
    border-radius: 10px; /* Bordes totalmente redondeados */
    box-shadow: 4px 4px 15px rgba(0,0,0,0.1);
    border: 1px solid #cbd5e1;
    z-index: 2000; /* Siempre por encima de todo */
}
.gestion-nav-menu .dropdown.open > .dropdown-menu {
    display: none !important;
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 10px; /* Separación sutil del sidebar negro */
    background-color: #f8fafc;
    padding: 10px 0;
    list-style: none;
    width: 220px;
    border-radius: 10px; /* Bordes totalmente redondeados */
    box-shadow: 4px 4px 15px rgba(0,0,0,0.1);
    border: 1px solid #cbd5e1;
    z-index: 2000; /* Siempre por encima de todo */
}
.dropdown-menu /* Asegurar que los items inactivos también mantengan el ancho y centrado */
.gestion-nav-link {
    color: #a3aed1 !important;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
    width: calc(100% - 20px) !important;
    margin: 0 auto 10px auto !important;
    border-radius: 10px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 12px 0 !important;
}
.dropdown-menu .gestion-nav-link .nav-text {
    display: inline-block !important; /* Dentro del submenú SÍ queremos el texto */
    opacity: 1;
}

/* --- AREA PRINCIPAL (DERECHA) --- */
.gestion-main-wrapper {
    flex-grow: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.gestion-header {
    width: 100%;
    height: 70px;
    flex-shrink: 0; /* Nuevo */
    display: flex;
    align-items: center;
    background: #ffffff;
    padding: 0 20px;
    box-sizing: border-box;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    position: relative;
}
.header-search {
    display: flex;
    align-items: center;
    background-color: #f4f7fe;
    border-radius: 30px;
    padding: 8px 20px;
    max-width: 400px;
    width: 100%;
    margin-right: auto;
}
.header-search .search-icon { color: #8f9bba; margin-right: 10px; }
.header-search .search-input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: #2b3674;
}
.header-actions-modern {
    display: flex;
    align-items: center;
    gap: 15px;
}
.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.6em; /* Iconos agrandados a petición del usuario */
    color: #a3aed1;
    cursor: pointer;
    position: relative;
    padding: 5px;
    transition: transform 0.2s;
}
.icon-btn:hover { transform: scale(1.1); }
.badge-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background-color: #ff5b5b;
    border-radius: 50%;
    border: 2px solid #fff;
}
.badge-number {
    position: absolute;
    top: -2px;
    right: -5px;
    min-width: 14px;
    height: 14px;
    padding: 0 4px;
    background-color: #ff5b5b;
    color: white;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.header-actions-modern .divider {
    width: 1px;
    height: 30px;
    background-color: #e2e8f0;
    margin: 0 10px;
}
.profile-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    position: relative;
    user-select: none;
}
.profile-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.profile-name { font-weight: 700; font-size: 14px; color: #2b3674; }
.profile-role { font-size: 12px; color: #a3aed1; }
.profile-role i {
    font-size: 14px;
    vertical-align: middle;
}
.profile-avatar {
    width: 40px;
    height: 40px;
    background-color: #4318ff;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
}

/* --- ESTILOS DEL DROPDOWN DE PERFIL --- */
.profile-dropdown {
    display: none;
    position: absolute;
    top: 120%; 
    right: 0;
    background-color: #ffffff;
    min-width: 220px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border-radius: 12px;
    padding: 10px 0;
    list-style: none;
    margin: 0;
    z-index: 1050;
    border: 1px solid #f1f3f5;
}
.profile-dropdown.show {
    display: block;
    animation: fadeInDown 0.2s ease-out;
}
.profile-dropdown li {
    padding: 0;
    margin: 0;
}
.profile-dropdown a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #495057;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}
.profile-dropdown a i {
    font-size: 18px;
    margin-right: 12px;
    color: #a3aed1;
    transition: color 0.2s;
}
.profile-dropdown a:hover {
    background-color: #f8f9fa;
    color: #0dcaf0;
}
.profile-dropdown a:hover i {
    color: #0dcaf0;
}
.profile-dropdown .dropdown-divider {
    height: 1px;
    background-color: #f1f3f5;
    margin: 8px 0;
}
.profile-dropdown a.text-danger {
    color: #dc3545;
}
.profile-dropdown a.text-danger i {
    color: #dc3545;
}
.profile-dropdown a.text-danger:hover {
    background-color: rgba(220, 53, 69, 0.05);
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.header-page-title {
    margin: 0;
    font-size: 1.3em;
    color: #1e293b;
    font-weight: 700;
}
.gestion-tab-content {
    flex-grow: 1;
    height: 100%;
    overflow: hidden;
    padding: 20px;
    box-sizing: border-box;
}
.gestion-tab-pane {
    height: 100% !important;
    width: 100%;
    overflow: hidden; 
}
.gestion-iframe-container {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background-color: transparent;
}

/* =========================================
   2. TABLERO KANBAN (gestion_solicitudes.php)
   ========================================= */
body.layout-tablero {
    height: 100vh;
    margin: 0;
    overflow: hidden !important; /* PC: Bloquea scroll global */
    background-color: #f4f6f9;
}
body.layout-tablero .container {
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    padding: 15px;
}
body.layout-tablero main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* TRUCO FLEXBOX: Vital para no empujar el scroll fuera de la pantalla */
}
body.layout-tablero .card {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 0 !important;
    background: transparent;
    box-shadow: none;
    padding: 0;
    min-height: 0;
}
.gestion-grid-container {
    flex-grow: 1;
    min-height: 0; /* Permite que el scroll interno nazca */
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    height: 100%;
}
.gestion-column {
    display: flex;
    flex-direction: column;
    min-height: 0; /* Permite compresión vertical */
}
.gestion-column .apartado {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    min-height: 0; 
}
.gestion-column .apartado-body {
    flex-grow: 1;
    overflow-y: auto; /* El scroll ocurre EXCLUSIVAMENTE acá adentro */
    padding: 15px;
}

/* --- RESPONSIVE: TABLETS Y CELULARES --- */
@media (max-width: 992px) {
    body.layout-tablero {
        height: auto; /* Liberamos la altura fija */
        overflow-y: auto !important; /* Habilitamos scroll general de página en móvil */
    }
    body.layout-tablero .container {
        height: auto;
    }
    .gestion-grid-container {
        display: flex;
        flex-direction: column; /* Apilamos las columnas a 1 sola */
        height: auto;
    }
    .gestion-column {
        height: 500px; /* Le damos una altura fija de medio monitor a cada columna para scrollear internamente */
        margin-bottom: 20px;
    }
}

/* =========================================
   3. VISTAS CON SCROLL LIBRE (detalle_presupuesto.php)
   ========================================= */
.layout-scrollable {
    height: auto !important; 
    min-height: fit-content; 
    max-height: none !important; 
    overflow-y: visible !important;
}

/* ========================================= */
/* ESTILOS DE GESTIÓN DE USUARIOS Y MODERN UI */
/* ========================================= */

/* Contenedor principal del modal moderno */
.modal-modern {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(18, 18, 30, 0.4); /* Fondo más suave */
    backdrop-filter: blur(2px); /* Ligero desenfoque */
    transition: opacity 0.3s ease;
}

/* El contenido del modal (la tarjeta flotante) */
.modal-content-compact {
    background-color: #ffffff;
    margin: 5vh auto; /* 5% desde arriba, centrado horiz. */
    padding: 24px;
    border-radius: 15px;
    max-width: 450px; /* Ancho máximo compacto */
    width: 90%;
    box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.1); /* Sombra suave corporativa */
    position: relative;
    border: none;
    animation: modalFadeIn 0.3s;
}

/* Botón de cierre X moderno */
.close-modal-modern {
    position: absolute;
    right: 20px;
    top: 18px;
    font-size: 24px;
    color: #a3aed1;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.close-modal-modern:hover { color: #ee5d50; }

/* Título del formulario modal */
.modal-form-title {
    margin: 0 0 20px 0;
    color: #2b3674;
    font-size: 18px;
    font-weight: 700;
    padding-bottom: 15px;
    border-bottom: 1px solid #f1f3f5;
}

/* Contenedor de grupos de campos compactos */
.form-group-compact {
    margin-bottom: 14px; /* Menos margen inferior */
}

/* Labels modernos y compactos */
.label-compact {
    display: block;
    font-size: 13px; /* Más pequeño */
    color: #a3aed1;
    font-weight: 600;
    margin-bottom: 5px;
}

/* Inputs y Selects modernos y compactos */
.input-compact, .select-compact {
    width: 100%;
    padding: 8px 12px; /* Mucho menos padding */
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #2b3674;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    background-color: #fcfcfc;
}
.input-compact:focus, .select-compact:focus {
    border-color: #4318FF;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(67, 24, 255, 0.1);
}

/* Fila de 2 columnas compacta */
.form-row-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 14px;
}

/* Animación de entrada */
@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modern-card {
    background: #ffffff;
    border-radius: 15px;
    padding: 24px;
    box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
    border: none;
}
.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.card-title-row h3 {
    margin: 0;
    color: #2b3674;
    font-size: 18px;
    font-weight: 700;
}
.modern-input, .modern-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #2b3674;
    outline: none;
    transition: all 0.3s ease;
    background: #fcfcfc;
}
.modern-input:focus, .modern-select:focus {
    border-color: #4318FF;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(67, 24, 255, 0.1);
}
label {
    display: block;
    font-size: 13px;
    color: #a3aed1;
    font-weight: 600;
    margin-bottom: 6px;
}
.modern-btn {
    padding: 9px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}
.btn-primary { background: #4318FF; color: white; }
.btn-primary:hover { background: #3311cc; box-shadow: 0 4px 10px rgba(67, 24, 255, 0.3); }
.btn-danger { background: #ee5d50; color: white; }
.btn-danger:hover { background: #d04e43; }
.btn-secondary { background: #f4f7fe; color: #2b3674; }
.btn-secondary:hover { background: #e2e8f0; }

.action-icon {
    font-size: 18px;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-edit { background: #e4e7fe; color: #4318FF; margin-right: 5px; }
.icon-edit:hover { background: #4318FF; color: white; }
.icon-delete { background: #feeceb; color: #ee5d50; }
.icon-delete:hover { background: #ee5d50; color: white; }

.modern-table {
    width: 100%;
    border-collapse: collapse;
}
.modern-table th {
    color: #a3aed1;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 12px 10px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}
.modern-table td {
    padding: 14px 10px;
    color: #2b3674;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid #f4f7fe;
}
.grid-2-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}
.layout-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    align-items: start;
}
.permisos-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 15px;
}
.permiso-grupo {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
}
.permiso-grupo h4 {
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #4318FF;
    font-size: 14px;
    color: #2b3674;
}
.permiso-item { display: flex; align-items: center; margin-bottom: 8px; }
.permiso-item input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #a3aed1;
    border-radius: 4px;
    margin-right: 8px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}
.permiso-item input[type="checkbox"]:checked {
    background-color: #4318FF;
    border-color: #4318FF;
}
.permiso-item input[type="checkbox"]:checked::after {
    content: '✔';
    position: absolute;
    color: white;
    font-size: 10px;
    top: -1px;
    left: 2px;
}
.permiso-item label { color: #4a5568; font-weight: 500; cursor: pointer; margin: 0; font-size: 13px; }

/* ========================================= */
/* ESTILOS DEL MÓDULO DE COBROS              */
/* ========================================= */

/* Adaptación de la tabla generada por JS al formato Modern */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tabla-gestion {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    white-space: nowrap;
}
.tabla-gestion th {
    color: #a3aed1;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 14px 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    background-color: #ffffff;
}
.tabla-gestion td {
    padding: 16px 12px;
    color: #2b3674;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid #f4f7fe;
}
.tabla-gestion tbody tr:hover {
    background-color: #f8f9fa;
}

/* Loader Modal Modernizado */
.modal-loader {
    display: none; 
    position: fixed;
    z-index: 9999;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(18, 18, 30, 0.4);
    backdrop-filter: blur(2px);
    justify-content: center;
    align-items: center;
}
.modal-loader-content {
    background-color: #ffffff;
    padding: 25px 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.1);
    color: #2b3674;
    font-weight: 600;
    font-size: 16px;
}

/* Tarjetas de Resumen KPI Internas */
.resumen-kpi-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid #e2e8f0;
    gap: 15px;
    flex-wrap: wrap;
}
.resumen-kpi-item {
    text-align: center;
    flex: 1;
    min-width: 150px;
}
.resumen-kpi-label {
    font-size: 13px;
    color: #a3aed1;
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
}
.resumen-kpi-value {
    font-size: 24px;
    font-weight: 700;
}

/* --- ESTILOS COMPARTIDOS RESTAURADOS --- */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}
.dashboard-card {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 18px;
    text-decoration: none;
    color: var(--dark-gray);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}
.dashboard-card h3 {
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: var(--primary-color);
}
.dashboard-card p {
    margin: 0;
    font-size: 0.85em;
    color: #6c757d;
    line-height: 1.5;
}
.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}
.card-icon svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}
.icon-portal { background-color: var(--primary-color); }
.icon-masivo { background-color: var(--success-color); }
.icon-debito { background-color: #ffc107; }
.icon-simulador { background-color: #fd7e14; }


.gestion-footer {
    flex-shrink: 0;
    background: #ffffff;
    padding: 8px 20px;
    display: flex;
    justify-content: center; /* Esto fuerza el centrado perfecto */
    align-items: center;
    border-top: 1px solid #e2e8f0;
    z-index: 900;
    width: 100%;
    box-sizing: border-box;
    color: #64748b; /* Gris suave y moderno para el texto */
    font-size: 12px;
}
.gestion-footer p {
    margin: 0;
}

/* ========================================================
   FIX DEFINITIVO: SUBMENÚS LATERALES FLOTANTES (OVERRIDE)
   ======================================================== */

/* 1. Liberar el contenedor principal de cualquier recorte */
.gestion-nav-menu {
    overflow: visible !important; 
    overflow-y: visible !important;
    overflow-x: visible !important;
    z-index: 2000 !important;
}

/* 2. Posicionar el contenedor del submenú volando a la derecha */
.gestion-nav-menu .dropdown {
    position: relative !important;
}

.gestion-nav-menu .dropdown-menu {
    display: none !important;
    position: absolute !important;
    left: 100% !important; 
    top: 0 !important; 
    margin-left: 15px !important; 
    background-color: #ffffff !important;
    padding: 10px 0 !important;
    list-style: none !important;
    width: 240px !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
    border: 1px solid #e2e8f0 !important;
    z-index: 3000 !important;
}

/* 3. Mostrar el submenú con animación al hacer clic */
.gestion-nav-menu .dropdown.open > .dropdown-menu {
    display: block !important;
    animation: submenuFadeIn 0.2s ease-out forwards !important;
}

@keyframes submenuFadeIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* 4. Estilizar los enlaces DENTRO del submenú blanco */
.gestion-nav-menu .dropdown-menu a.gestion-nav-link {
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 12px 20px !important;
    color: #2b3674 !important;
    justify-content: flex-start !important; 
    background: transparent !important;
    border: none !important;
    border-bottom: none !important;
}

.gestion-nav-menu .dropdown-menu a.gestion-nav-link:hover {
    background-color: #f4f7fe !important;
    color: #4318ff !important;
}

/* 5. Forzar que los textos se vean dentro del submenú */
.gestion-nav-menu .dropdown-menu .nav-text {
    display: inline-block !important;
    margin-left: 10px !important;
    font-size: 14px !important;
}

.gestion-nav-menu .dropdown-menu .nav-icon {
    font-size: 20px !important;
    color: inherit !important;
}
  
/* --- MOBILE RESPONSIVE REFACTORING --- */  
@media (max-width: 1024px) {  
    .header-search { display: none; }  
    .header-actions-modern { gap: 5px; }  
    .icon-btn { padding: 2px; font-size: 1.4em; }  
    .profile-name { display: none; }  
    .gestion-nav-menu { position: fixed; left: -100%; top: 0; height: 100vh; z-index: 9999; transition: left 0.3s; margin: 0; border-radius: 0; padding-top: 60px; }  
    .gestion-nav-menu.menu-open { left: 0; }  
    .gestion-nav-menu .dropdown-menu { position: static; box-shadow: none; border-radius: 0; display: none; background-color: #2a2a2a; padding-left: 10px; }  
    .gestion-nav-menu .dropdown.open .dropdown-menu { display: block; }  
    .modal-content, .modal-content-compact, #cliente-modal  { width: 95% !important; margin: 5% auto !important; padding: 15px !important; }  
} 

/* Estilo para botón de WhatsApp en la cabecera */
.gestion-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    text-decoration: none;
    margin-left: 10px;
    padding: 0;
    transition: transform 0.2s, background-color 0.2s;
    cursor: pointer;
    border: none;
    outline: none;
}
.gestion-action-btn:hover {
    transform: scale(1.1);
}

/* Modern Header Buttons */
.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    box-sizing: border-box;
}

.btn-modern-primary {
    background: #4318FF;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(67, 24, 255, 0.2);
}

.btn-modern-primary:hover {
    background: #3311CC;
    transform: translateY(-1.5px);
    box-shadow: 0 6px 16px rgba(67, 24, 255, 0.3);
}

.btn-modern-secondary {
    background: #F4F7FE;
    color: #4318FF;
    border: 1px solid transparent;
}

.btn-modern-secondary:hover {
    background: #EAEFFC;
    color: #3311CC;
    transform: translateY(-1px);
}


/* --- RESULTADOS DE BÚSQUEDA FLOTANTES --- */
.search-results-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #ffffff;
    border: 1px solid #e0e5f2;
    border-radius: 12px;
    box-shadow: 0px 10px 30px rgba(112, 144, 176, 0.15);
    z-index: 999;
    list-style: none;
    padding: 0;
    margin: 4px 0 0 0;
    max-height: 240px;
    overflow-y: auto;
}

.search-results-list li {
    padding: 4px 8px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
}

.search-results-list li:last-child {
    border-bottom: none;
}

.search-results-list li:hover {
    background: #f4f7fe;
}

.search-results-list li strong {
    color: #2b3674;
}

.search-results-list li span {
    color: #a3aed1;
    font-size: 11px;
}

.search-results-list li div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
    margin-right: 8px;
}

.status-indicator.activo {
    background-color: #22c55e;
}

.status-indicator.inactivo {
    background-color: #ef4444;
}