/* ==========================================
   INKA CORP - Estilos del Módulo de Créditos Preferenciales
   Gestión y monitoreo
   ========================================== */

/* Contenedor principal - hereda max-width del content-wrapper */
.creditos-pref-wrapper {
    width: 100%;
    /* NO usar overflow: hidden para que sticky funcione */
    box-sizing: border-box;
}

/* Asegurar que todos los elementos respeten el contenedor */
.creditos-pref-wrapper *,
.creditos-pref-wrapper *::before,
.creditos-pref-wrapper *::after {
    box-sizing: border-box;
}

/* ==========================================
   HERO SECTION - Identical to creditos module
   ========================================== */
.creditos-pref-hero {
    position: relative;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--black) 100%);
    border-radius: 1.5rem;
    padding: 2.5rem;
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

.hero-bg-creditos-pref {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(11, 78, 50, 0.2) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 20%);
    z-index: 1;
}

.hero-content-creditos-pref {
    position: relative;
    z-index: 2;
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero-icon-creditos-pref {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    border-radius: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.2);
    transform: rotate(5deg);
}

.hero-icon-creditos-pref i {
    font-size: 2.5rem;
    color: var(--gold);
}

.hero-title-creditos-pref {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--white);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.hero-subtitle-creditos-pref {
    font-size: 1.1rem;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

/* ==========================================
   STATS CARDS
   ========================================== */
.creditos-pref-hero-stats {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

.creditos-pref-hero-stat {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 1rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 110px;
}

.creditos-pref-hero-stat:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.creditos-pref-hero-stat.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
}

.creditos-pref-hero-stat.highlight {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.creditos-pref-hero-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 0.25rem;
}

.creditos-pref-hero-stat.warning .creditos-pref-hero-value {
    color: var(--warning);
}

.creditos-pref-hero-stat.highlight .creditos-pref-hero-value {
    color: var(--success-light);
}

.creditos-pref-hero-label {
    font-size: 0.8rem;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==========================================
   TOOLBAR DE FILTROS
   ========================================== */
.creditos-pref-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    background: var(--gray-800);
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

/* Estado Counters */
.creditos-pref-wrapper .estado-counters {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0; /* Ajustado para el wrapper */
}

/* ==========================================
   VIEW SWITCHER
   ========================================== */
.view-switcher {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.view-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.view-btn i {
    font-size: 1rem;
}

.view-btn:hover {
    color: var(--white);
}

.view-btn.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(11, 78, 50, 0.3);
}

/* ==========================================
   GALLERY VIEW
   ========================================== */
.creditos-pref-gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.socio-card-pref {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 1.25rem;
    padding: 1.75rem;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    color: white;
}

.socio-card-pref:hover {
    transform: translateY(-10px) rotateX(4deg) rotateY(-2deg);
    border-color: var(--gold);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

/* Patrón sutil de fondo para la tarjeta */
.socio-card-pref::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(circle at 2px 2px, rgba(255,255,255,0.03) 1px, transparent 0);
    background-size: 16px 16px;
    pointer-events: none;
}

/* Destello de luz */
.socio-card-pref::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 0%,
        rgba(255, 255, 255, 0.03) 45%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.03) 55%,
        transparent 100%
    );
    transform: rotate(25deg);
    transition: all 0.8s ease;
    pointer-events: none;
}

.socio-card-pref:hover::after {
    left: 100%;
    top: 100%;
}

.card-pref-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    margin-bottom: 2rem;
}

.card-brand {
    font-weight: 900;
    font-size: 1.25rem;
    letter-spacing: 2px;
    color: var(--gold);
    text-transform: uppercase;
    text-shadow: 0 2px 5px rgba(0,0,0,0.4);
    font-family: 'Segoe UI', sans-serif;
}

.card-chip {
    width: 48px;
    height: 38px;
    background: linear-gradient(135deg, #f2cd70 0%, var(--gold) 50%, #d3900d 100%);
    border-radius: 8px;
    position: relative;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.3), 0 2px 5px rgba(0,0,0,0.2);
}

.card-mid-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 1.5rem;
    background: transparent !important;
}

.card-amount-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.1rem;
    font-weight: 700;
}

.card-amount-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: white;
    font-family: 'OCR A Extended', 'Courier New', monospace;
    text-shadow: 0 3px 10px rgba(0,0,0,0.5);
}

.card-bottom-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
}

.card-holder-info {
    flex: 1;
}

.card-number-display {
    font-family: 'OCR A Extended', 'Courier New', monospace;
    font-size: 1.25rem;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.4rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.card-holder-name {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.card-extra-stats {
    display: flex;
    gap: 1.25rem;
    text-align: right;
}

.card-stat-small {
    display: flex;
    flex-direction: column;
}

.card-stat-small-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 2px;
    font-weight: 700;
}

.card-stat-small-value {
    font-size: 0.9rem;
    font-weight: 800;
}

.card-stat-small-value.percent {
    color: var(--gold-light);
}

.creditos-pref-wrapper .estado-counter {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--gray-800);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.creditos-pref-wrapper .estado-counter:hover {
    border-color: var(--primary);
    background: var(--gray-700);
}

.creditos-pref-wrapper .estado-counter.active {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--gold);
}

.creditos-pref-wrapper .estado-counter.active .counter-label {
    color: var(--gold);
}

/* Capsulas de Tipo de Crédito */
.type-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.type-preferencial {
    background-color: rgba(139, 92, 246, 0.1);
    color: #8B5CF6; /* Morado */
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.type-estudiantil {
    background-color: rgba(180, 83, 9, 0.1);
    color: #B45309; /* Amarillo Oscuro */
    border: 1px solid rgba(180, 83, 9, 0.2);
}

.type-salud {
    background-color: rgba(239, 68, 68, 0.1);
    color: #EF4444; /* Rojo */
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.type-default {
    background-color: rgba(107, 114, 128, 0.1);
    color: #6B7280;
    border: 1px solid rgba(107, 114, 128, 0.2);
}

/* Estado Rechazado (Rojisimo) */
.row-rechazado {
    background-color: rgba(220, 38, 38, 0.05) !important;
}

.row-rechazado:hover {
    background-color: rgba(220, 38, 38, 0.1) !important;
}

.status-rechazado-text {
    color: #DC2626 !important; /* Rojo Muy Intenso */
    font-weight: 700;
}

/* ==========================================
   SECCIONES POR ESTADO CON STICKY HEADERS
   ========================================== */

.creditos-pref-sections-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.creditos-pref-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
}

.creditos-pref-section .section-sticky-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    border-radius: 1rem 1rem 0 0;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.creditos-pref-section .section-sticky-header.is-stuck {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.creditos-pref-section .section-sticky-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--section-color, var(--gold));
    border-radius: 1rem 0 0 0;
}

.creditos-pref-section .section-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0 0 1rem 1rem;
    background: var(--card-bg);
}

.creditos-pref-section-table {
    width: 100%;
    border-collapse: collapse;
}

.creditos-pref-section-table thead th {
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.creditos-pref-section-table tbody tr {
    transition: background 0.15s ease;
    cursor: pointer;
}

.creditos-pref-section-table tbody tr:hover {
    background: rgba(212, 175, 55, 0.05);
}

.creditos-pref-section-table tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    white-space: nowrap;
}

.creditos-pref-section-table tbody tr:last-child td {
    border-bottom: none;
}

/* Progress badge */
.creditos-pref-wrapper .progress-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-300);
}

/* Loading placeholder */
.creditos-pref-wrapper .loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--gray-400);
    gap: 1rem;
}

.creditos-pref-wrapper .loading-placeholder i {
    font-size: 2.5rem;
    color: var(--gold);
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 1024px) {
    .creditos-pref-toolbar {
        gap: 0.5rem;
    }
    
    .creditos-pref-toolbar .toolbar-btn span {
        display: none;
    }
    
    .creditos-pref-toolbar .toolbar-btn {
        padding: 0.5rem;
        width: 38px;
    }
    
    .creditos-pref-toolbar .toolbar-search {
        order: 10;
        flex: 1 1 100%;
        max-width: none;
        margin-top: 0.5rem;
    }
    
    .creditos-pref-toolbar .toolbar-separator {
        display: none;
    }
}

@media (max-width: 768px) {
    .creditos-pref-hero {
        padding: 1.5rem;
        border-radius: 1rem;
    }

    .hero-title-creditos-pref {
        font-size: 1.75rem;
    }

    .creditos-pref-hero-stats {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    
    .creditos-pref-toolbar {
        padding: 0.75rem;
        gap: 0.4rem;
    }
    
    .creditos-pref-wrapper .estado-counters {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .creditos-pref-wrapper .estado-counter {
        flex-shrink: 0;
    }
    
    .creditos-pref-section-table {
        min-width: 700px;
    }

    .creditos-pref-section .section-sticky-header {
        padding: 0.75rem 1rem;
    }
}

/* ==========================================
   FIXED HEADER CLONE (JavaScript controlled)
   ========================================== */
.fixed-header-clone-pref {
    background: var(--card-bg) !important;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
}

.fixed-header-clone-pref .section-sticky-header {
    border-radius: 0;
    margin: 0;
    padding: 0.75rem 1rem;
}

.fixed-header-clone-pref .sticky-table-header {
    background: transparent;
}

.fixed-header-clone-pref .sticky-table-header thead {
    background: var(--bg-secondary);
}

.fixed-header-clone-pref .sticky-table-header thead th {
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.fixed-header-clone-pref .sticky-table-header .text-right {
    text-align: right;
}

.fixed-header-clone-pref .sticky-table-header .text-center {
    text-align: center;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
