/* ================================================================================
   ESTILOS PRINCIPALES DEL SISTEMA DE ASESORÍA PREVISIONAL
   ================================================================================ */

:root {
    --primary: #1e3a8a;
    --secondary: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray: #6b7280;
    --light: #f8fafc;
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--light);
    color: #1f2937;
}

.header {
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.main-container {
    display: grid;
    grid-template-columns: 280px minmax(320px, 380px) 1fr;
    min-height: calc(100vh - 80px);
    gap: 1rem;
    padding: 1rem;
    max-width: 100vw;
    overflow-x: auto;
}

.main-container.panel-oculto {
    grid-template-columns: 280px 1fr;
}

@media (max-width: 1400px) {
    .main-container {
        grid-template-columns: 260px minmax(300px, 350px) 1fr;
    }
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 240px 1fr;
        gap: 0.5rem;
    }
    
    .main-container .datos-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
        padding: 0.5rem;
    }
    
    .sidebar {
        order: -1;
        grid-column: 1 / -1;
        display: flex;
        overflow-x: auto;
        padding: 0.5rem;
    }
    
    .nav-item {
        min-width: auto;
        padding: 0.5rem 1rem;
    }
}

.sidebar {
    background: white;
    border-right: 1px solid #e5e7eb;
    padding: 1.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: background 0.2s;
}

.nav-item:hover, .nav-item.active {
    background: #eff6ff;
    color: var(--primary);
}

.content {
    padding: 2rem;
    overflow-y: auto;
}

/* ================================================================================
   PANEL LATERAL DE DATOS EXTRAÍDOS
   ================================================================================ */

.datos-sidebar {
    background: #f8fafc;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
}

.datos-header {
    background: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.datos-header h4 {
    font-size: 1rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.btn-toggle {
    background: none;
    border: none;
    color: var(--gray);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: background 0.2s;
}

.btn-toggle:hover {
    background: #f3f4f6;
    color: var(--danger);
}

.datos-content {
    padding: 1rem;
}

.datos-section {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
}

.datos-section h5 {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.datos-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dato-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}

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

.dato-label {
    font-size: 0.8rem;
    color: var(--gray);
    font-weight: 500;
}

.dato-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: #1f2937;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.dato-value.highlight {
    color: var(--primary);
}

.dato-value.money {
    color: var(--success);
}

/* Beneficiarios */
.beneficiarios-count {
    margin-bottom: 0.75rem;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.beneficiarios-lista {
    max-height: 200px;
    overflow-y: auto;
}

.beneficiario-item {
    padding: 0.5rem;
    background: #f8fafc;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--secondary);
}

.beneficiario-item:last-child {
    margin-bottom: 0;
}

.beneficiario-nombre {
    font-weight: 600;
    font-size: 0.8rem;
    color: #1f2937;
    display: block;
}

.beneficiario-info {
    font-size: 0.75rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

/* Estadísticas de ofertas */
.ofertas-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.stat-item {
    text-align: center;
    padding: 0.5rem;
    background: #f8fafc;
    border-radius: 0.25rem;
}

.stat-number {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--gray);
    text-transform: uppercase;
    font-weight: 500;
}

/* Mejor oferta */
.mejor-oferta-info {
    padding: 0.75rem;
    background: linear-gradient(135deg, #fef3cd, #fde68a);
    border-radius: 0.5rem;
    border-left: 4px solid var(--warning);
}

.mejor-oferta-entidad {
    font-weight: 700;
    color: #92400e;
    font-size: 0.85rem;
}

.mejor-oferta-monto {
    font-size: 0.9rem;
    color: #78350f;
    font-weight: 600;
    margin-top: 0.25rem;
}

.no-data {
    color: var(--gray);
    font-size: 0.8rem;
    text-align: center;
    padding: 1rem 0;
    font-style: italic;
}

/* Animaciones */
@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.datos-sidebar {
    animation: slideIn 0.3s ease-out;
}

/* Estados de carga */
.dato-value.loading {
    background: #f3f4f6;
    color: transparent;
    border-radius: 0.25rem;
    position: relative;
}

.dato-value.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 250px 300px 1fr;
    }
}

@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .datos-sidebar {
        position: fixed;
        top: 80px;
        left: 0;
        width: 100%;
        height: calc(100vh - 80px);
        z-index: 1000;
    }
}

/* Botones */
.ml-2 {
    margin-left: 0.5rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: #1e40af;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(30, 58, 138, 0.3);
}

.btn-secondary {
    background: var(--gray);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(75, 85, 99, 0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

.upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 0.75rem;
    padding: 3rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--secondary);
    background: #eff6ff;
}

.upload-zone.dragover {
    border-color: var(--success);
    background: #ecfdf5;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: #1e40af;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mt-3 {
    margin-top: 1rem;
}

.seccion {
    display: none;
}

.seccion.active {
    display: block;
}

.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.ofertas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.oferta-card {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    position: relative;
    background: white;
}

.oferta-afp {
    border-left: 4px solid #ef4444;
}

.oferta-seguro {
    border-left: 4px solid #3b82f6;
}

.rating-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.rating-aaa { background: #10b981; color: white; }
.rating-aa { background: #059669; color: white; }
.rating-a { background: #0891b2; color: white; }
.rating-bbb { background: #f59e0b; color: white; }

.monto {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.progress-bar {
    background: #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    margin: 1rem 0;
}

.progress-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--primary);
}

.no-results {
    text-align: center;
    padding: 2rem;
    color: var(--gray);
    font-style: italic;
}

.resultado-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.ofertas-section {
    margin-bottom: 2rem;
}

.ofertas-section h5 {
    margin-bottom: 1rem;
    color: var(--primary);
    font-size: 1.1rem;
}