/* ============================================
   KrediaPRO - Sistema de Diseño Profesional
   ============================================ */

:root {
    /* Paleta de Colores - Mantenida */
    --primary: #2563eb;
    --primary-light: #60a5fa;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    
    /* Fondo y Superficies Premium */
    --bg-primary: #0f172a;
    --bg-secondary: #020617;
    --bg-card: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --bg-glass-heavy: rgba(15, 23, 42, 0.85);
    
    /* Texto */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Bordes y Sombras - Refinados */
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-light: rgba(255, 255, 255, 0.04);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    /* Radios Modernos */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 32px;

    /* Tipografía Profesional */
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    overflow-wrap: break-word; /* Blindaje global para palabras largas */
}

html, body {
    width: 100%;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.6;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Habilitado scroll global */
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

p {
    text-align: justify;
    hyphens: auto;
}

/* ============================================
   HEADER PROFESIONAL
   ============================================ */

.header-pro {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    font-family: var(--font-main);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(37, 99, 235, 0.39);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.23);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-link {
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease;
    cursor: pointer;
}

.logo-link:hover {
    transform: scale(1.02);
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Language Selector */
.lang-selector {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    color: var(--text-primary);
}

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

.logo-text h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    box-sizing: border-box;
    animation: fadeIn 0.8s ease-out;
}

/* ============================================
   CARD FORMULARIO
   ============================================ */

.card-form {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-glass);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-form:hover {
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

.form-header {
    margin-bottom: 20px;
}

.form-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.limite-section {
    margin-bottom: 16px;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field.full-width {
    grid-column: 1 / -1;
}

.label-pro {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    white-space: nowrap;
}

.w-digits {
    flex: 0 0 105px;
}

.w-digits .input-group {
    padding: 0 10px;
}

.w-digits .input-prefix {
    margin-right: 2px;
    font-size: 20px;
    margin-top: 6px; /* Offset for typical asterisk vertical position */
}

.w-digits input {
    font-size: 15px;
}

.input-group {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 0 16px;
    height: 52px;
    width: 100%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-group:focus-within {
    border-color: var(--primary-light);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.input-prefix {
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 500;
    margin-right: 8px;
    flex-shrink: 0; /* No permitir que el prefijo se encoja o empuje */
}

input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

input::placeholder {
    color: var(--text-muted);
}

/* ============================================
   BOTONES
   ============================================ */

.form-actions {
    margin-top: 24px;
}

.btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--primary-light);
    border: 1px solid var(--primary);
}

.btn-secondary:hover {
    background: rgba(37, 99, 235, 0.1);
}

/* ============================================
   RESUMEN DE CRÉDITO
   ============================================ */

.credit-summary {
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 32px;
}

.summary-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.3s ease, background 0.3s ease;
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-4px);
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.stat-value.positive {
    color: var(--success);
}

.stat-value.negative {
    color: var(--danger);
}

.progress-section {
    margin-top: 16px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 100px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--primary));
    border-radius: 100px;
    transition: width 0.5s ease, background 0.3s ease;
    width: 0%;
}

.progress-fill.warning {
    background: linear-gradient(90deg, var(--warning), #d97706);
}

.progress-fill.danger {
    background: linear-gradient(90deg, var(--danger), #dc2626);
}

/* ============================================
   ALERTA DE ESTADO
   ============================================ */

.status-alert {
    display: none;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

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

.status-alert.success {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--success-bg);
    border: 1px solid var(--success);
    color: var(--success);
}

.status-alert.warning {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    color: var(--warning);
}

.status-alert.danger {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.status-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.status-content {
    flex: 1;
    text-align: left;
}

.status-text {
    font-size: 15px;
    margin-bottom: 6px;
}

.status-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.status-detail span {
    color: var(--text-secondary);
}

.status-detail strong {
    color: var(--text-primary);
}

.status-suggestion {
    font-size: 12px;
    opacity: 0.85;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ============================================
   SECCIÓN DE COMPRAS
   ============================================ */

.purchases-section {
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 32px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.badge {
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
}

.purchases-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ============================================
   CARD DE COMPRA
   ============================================ */

.card-compra {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card-compra:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-glass);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.compra-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.compra-nombre {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word; /* Ajustar nombres de compra largos */
}

.compra-monto {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-light);
}

.compra-detalles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.detalle-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detalle-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detalle-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.detalle-value.highlight {
    color: var(--success);
    font-weight: 600;
}

.compra-restante {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.restante-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.restante-valor {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
}

.compra-actions {
    display: flex;
    gap: 10px;
}

.btn-edit {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-edit:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--primary-light);
}

/* ============================================
   GRÁFICO
   ============================================ */

.chart-section {
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 32px;
}

.chart-container {
    width: 100%;
    height: 350px;
    position: relative;
}

/* ============================================
   FOOTER
   ============================================ */

.footer-pro {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-glass-light);
    margin-top: 40px;
}

/* ============================================
   ESTADOS VACÍOS
   ============================================ */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-text {
    font-size: 15px;
}

/* ============================================
   SIMULADOR DE COMPRA
   ============================================ */

.simulator-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    overflow: hidden;
}

.simulator-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.simulator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.btn-simulate {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-simulate:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.simulator-result {
    margin-top: 16px;
    padding: 20px;
    border-radius: var(--radius-lg);
    display: none;
    animation: slideIn 0.3s ease;
}

.simulator-result.visible {
    display: block;
}

.simulator-result.can-buy {
    background: var(--success-bg);
    border: 1px solid var(--success);
}

.simulator-result.cannot-buy {
    background: var(--danger-bg);
    border: 1px solid var(--danger);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.result-icon {
    font-size: 32px;
}

.result-title {
    font-size: 18px;
    font-weight: 600;
}

.result-title.success {
    color: var(--success);
}

.result-title.danger {
    color: var(--danger);
}

.result-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary);
}

.result-row span:last-child {
    font-weight: 600;
    color: var(--text-primary);
}

.result-impact {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.impact-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.impact-value {
    font-size: 15px;
    color: var(--warning);
    font-weight: 500;
}

/* ============================================
   PROYECCIÓN DE LIBERACIÓN
   ============================================ */

.projection-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    overflow: hidden;
}

.projection-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.projection-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.projection-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.projection-item:hover {
    border-color: var(--success);
}

.projection-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.projection-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.projection-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.projection-amount {
    text-align: right;
}

.projection-libera {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.projection-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--success);
}

.projection-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================
   SELECTOR DE TARJETAS
   ============================================ */

.cards-selector {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
}

.btn-add-card {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-add-card:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.tarjetas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.tarjeta-card {
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.tarjeta-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.tarjeta-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.tarjeta-imagen {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tarjeta-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.tarjeta-nombre {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tarjeta-limite {
    font-size: 12px;
    color: var(--text-muted);
}

.tarjeta-uso {
    margin-top: 10px;
}

.tarjeta-uso-bar {
    height: 4px;
    background: var(--border);
    border-radius: 100px;
    overflow: hidden;
}

.tarjeta-uso-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.3s ease;
}

.tarjeta-uso-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start; /* Cambio de center a flex-start para permitir scroll desde arriba */
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto; /* Habilitar scroll si el contenido es muy alto */
    -webkit-overflow-scrolling: touch; /* Suavidad en iOS */
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
    margin: auto; /* Centrar verticalmente si cabe, si no, respeta el padding del padre */
    animation: modalIn 0.2s ease;
    position: relative;
    max-height: none; /* Permitir que crezca */
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* ============================================
   ENTITY PICKER
   ============================================ */

.entity-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.entity-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.entity-option:hover {
    border-color: var(--border-light);
    background: rgba(255, 255, 255, 0.02);
}

.entity-option.selected {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.entity-icon {
    font-size: 24px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.entity-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.entity-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.entity-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.2;
}

    .entity-desc {
        display: none; 
    }


.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Card Type Picker */
.card-type-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.card-type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.card-type-option:hover {
    border-color: var(--border-light);
}

.card-type-option.selected {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.card-type-option[data-type="visa"].selected {
    border-color: #1a1f71;
    background: linear-gradient(135deg, rgba(26, 31, 113, 0.2), rgba(0, 87, 184, 0.1));
}

.card-type-option[data-type="mastercard"].selected {
    border-color: #eb001b;
    background: linear-gradient(135deg, rgba(235, 0, 27, 0.15), rgba(255, 95, 0, 0.1));
}

.card-type-option[data-type="amex"].selected {
    border-color: #006fcf;
    background: linear-gradient(135deg, rgba(0, 111, 207, 0.2), rgba(0, 150, 200, 0.1));
}

.card-type-icon {
    font-size: 20px;
}

.card-type-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.card-type-option.selected .card-type-name {
    color: var(--text-primary);
}

.card-entity-tag {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 2;
}

.tarjeta-card {
    position: relative; /* Para el tag absoluto */
    overflow: hidden;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .flex-1 {
    flex: 1;
}

.form-row .flex-2 {
    flex: 2;
}

.w-entity {
    flex: 1;
}

#onboarding_digitos {
    text-align: center;
}

/* Tarjeta colores por marca */
.tarjeta-card.visa {
    border-left-color: #1a1f71 !important;
    background: linear-gradient(135deg, var(--bg-input), rgba(26, 31, 113, 0.1));
}

.tarjeta-card.mastercard {
    border-left-color: #eb001b !important;
    background: linear-gradient(135deg, var(--bg-input), rgba(235, 0, 27, 0.08));
}

.tarjeta-card.amex {
    border-left-color: #006fcf !important;
    background: linear-gradient(135deg, var(--bg-input), rgba(0, 111, 207, 0.1));
}

.tarjeta-digitos {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    margin-top: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}


.modal-actions {
    padding: 16px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-danger {
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    color: var(--danger);
}

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

/* Color Picker */
.color-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: white;
    box-shadow: 0 0 0 2px var(--primary);
}

/* ============================================
   INFO TARJETA ACTIVA
   ============================================ */

.active-card-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 20px 24px;
    overflow: hidden;
}

.card-header-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.card-icon {
    font-size: 36px;
}

.card-details {
    flex: 1;
}

.card-details h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-limite {
    font-size: 14px;
    color: var(--text-secondary);
}

.card-limite strong {
    color: var(--primary-light);
}

.btn-edit-card {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-edit-card:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--primary-light);
}

/* ============================================
   RESUMEN CONSOLIDADO
   ============================================ */

.consolidated-summary {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
}

.consolidated-summary .stat-card {
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================
   ESTADO VACÍO
   ============================================ */

.empty-cards-state {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 80px 24px;
    text-align: center;
    overflow: hidden;
    position: relative;
}

.hero-image-container {
    margin-bottom: 32px;
    perspective: 1000px;
}

.hero-card-img {
    width: 100%;
    max-width: 280px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 
                0 0 20px rgba(37, 99, 235, 0.2);
    animation: floatCard 4s ease-in-out infinite;
    transform-style: preserve-3d;
}

@keyframes floatCard {
    0%, 100% { transform: translateY(0) rotateX(5deg) rotateY(-5deg); }
    50% { transform: translateY(-15px) rotateX(10deg) rotateY(5deg); }
}

.empty-cards-state h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.empty-cards-state p {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto 32px;
    line-height: 1.6;
}

/* ============================================
   RESPONSIVE
   ============================================ */



/* ============================================
   CTA EXPORTACIÓN PDF
   ============================================ */

.pdf-cta-section {
    margin-top: 10px;
    margin-bottom: 20px;
    animation: fadeIn 0.5s ease;
}

.pdf-cta-card {
    background: linear-gradient(135deg, var(--bg-secondary), #1e293b);
    border: 1px solid var(--primary);
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.15);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.pdf-cta-content h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.pdf-cta-content p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto;
    text-align: center; /* Sobrepasar el justify general para este CTA */
}

.btn-export-premium {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 700;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.btn-export-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
    filter: brightness(1.1);
}

.btn-export-premium:active {
    transform: translateY(0);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   SECCIÓN RESPONSIVA (MOBILE FIRST TUNING)
   ============================================ */

/* Pantallas Pequeñas (Mobile Standard) */
@media (max-width: 480px) {
    .container {
        padding: 12px;
        gap: 12px;
    }
    
    h2 {
        font-size: 18px !important;
    }
    
    h3 {
        font-size: 17px !important;
    }

    .logo-text h1 {
        font-size: 20px;
    }
    
    .lang-selector {
        gap: 4px;
        padding: 2px;
    }
    
    .lang-btn {
        padding: 4px 6px;
        font-size: 11px;
    }

    .stat-value {
        font-size: 15px;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        text-align: left;
    }

    .stat-label {
        margin-bottom: 0;
        font-size: 12px;
    }

    .stat-value {
        font-size: 17px;
    }

    .form-grid, .simulator-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    
    .btn-export-premium {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 15px;
    }

    .chart-container {
        height: 250px;
    }
    
    .pdf-cta-section {
        margin-top: 20px;
    }

    .pdf-cta-card {
        background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(30, 41, 59, 0.4));
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: var(--radius-lg);
        padding: 32px;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 20px;
    }

    .pdf-cta-title {
        font-size: 20px;
        font-weight: 700;
        margin-bottom: 8px;
        color: var(--text-primary);
    }

    .pdf-cta-desc {
        color: var(--text-secondary);
        font-size: 15px;
        max-width: 400px;
        margin: 0 auto;
    }

    .btn-export-premium {
        background: var(--primary);
        color: white;
        padding: 16px 32px;
        font-weight: 600;
        box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
    }

    .btn-export-premium:hover {
        background: var(--primary-dark);
        transform: translateY(-2px);
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .card-form, .credit-summary, .purchases-section, .chart-section, .simulator-section, .projection-section {
        padding: 20px;
        border-radius: var(--radius-lg);
    }

    .modal-content {
        max-width: 100%;
        border-radius: var(--radius-lg);
        margin: 10px auto; 
    }
}

/* Pantallas Extra Pequeñas (iPhone SE / 320px) */
@media (max-width: 360px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .logo-section {
        flex-direction: column;
        gap: 8px;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 10px;
    }
    
    .card-type-picker {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .entity-option {
        padding: 10px;
        gap: 10px;
    }
    
    .card-header-info {
        gap: 12px;
    }
    
    .card-icon {
        font-size: 28px;
    }
    
    .card-details h2 {
        font-size: 18px;
    }

    .projection-item {
        padding: 12px;
    }
    
    .projection-value {
        font-size: 16px;
    }
}

/* Landscape y Tablets pequeñas */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 16px 24px;
    }
}

/* ============================================
   MEJORAS EN TARJETA GRID
   ============================================ */

/* ============================================
   PANTALLA DE ONBOARDING
   ============================================ */

.onboarding-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a1c24 0%, #0a0b0e 100%);
    display: flex;
    align-items: flex-start; /* Cambiado de center a flex-start */
    justify-content: center;
    z-index: 10000;
    padding: 60px 20px; /* Aumentado padding superior */
    overflow-y: auto;
}

.onboarding-card {
    width: 100%;
    max-width: 500px;
    background: rgba(15, 23, 42, 0.8); /* var(--bg-primary) with transparency */
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 32px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    mix-blend-mode: normal; /* Ensure content is readable */
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.onboarding-header-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: -10px;
    position: relative;
    z-index: 10;
}

.hero-image {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.gold-card-img {
    width: 100%;
    max-width: 280px;
    height: auto;
    /* mix-blend-mode removed since the image now has the correct #0f172a background */
    /* Gold shadow removed as requested */
    animation: floatingCard 6s ease-in-out infinite;
}

@keyframes floatingCard {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50% { transform: translateY(-15px) rotate(1deg); }
}

.onboarding-content {
    text-align: center;
}

.onboarding-title {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 12px;
    color: #ffffff;
}

.logo-accent {
    background: linear-gradient(
        to right, 
        #bf953f 20%, 
        #fcf6ba 40%, 
        #bf953f 60%, 
        #fcf6ba 80%, 
        #bf953f 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    font-weight: 800;
    text-decoration: none; /* Remove standard underline to use a custom one if needed or just keep it clean */
    position: relative;
    animation: goldShimmer 4s linear infinite;
}

.logo-accent::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, #bf953f, #fcf6ba, #bf953f);
    background-size: 200% auto;
    animation: goldShimmer 4s linear infinite;
}

@keyframes goldShimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.onboarding-subtitle {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.onboarding-form {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.btn-large {
    height: 60px;
    font-size: 18px;
    font-weight: 700;
    margin-top: 10px;
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4);
}

.select-pro {
    width: 100%;
    height: 48px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: #ffffff;
    padding: 0 32px 0 12px;
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
}

.select-pro:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

@media (max-width: 480px) {
    .onboarding-card {
        padding: 30px 20px;
    }
    .onboarding-title {
        font-size: 26px;
    }
}
