/* ============================================
   Sistema de Pagos Parcela - Estilos Globales
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600;700&display=swap');

/* ---- Reset & Variables ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Dark premium palette */
    --bg-primary: #06090f;
    --bg-secondary: #0c1220;
    --bg-card: #111827;
    --bg-card-hover: #1a2332;
    --bg-glass: rgba(17, 24, 39, 0.7);

    /* Accent colors */
    --accent-primary: #3b82f6;
    --accent-primary-glow: rgba(59, 130, 246, 0.3);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.25);
    --accent-amber: #f59e0b;
    --accent-amber-glow: rgba(245, 158, 11, 0.25);
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.25);
    --accent-purple: #8b5cf6;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Borders */
    --border-color: rgba(148, 163, 184, 0.1);
    --border-glow: rgba(59, 130, 246, 0.3);

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.15);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ---- Animated Background ---- */
.bg-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background: 
        radial-gradient(ellipse 80% 50% at 20% 40%, rgba(59, 130, 246, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 60% 40% at 80% 20%, rgba(139, 92, 246, 0.05) 0%, transparent 70%),
        radial-gradient(ellipse 70% 50% at 50% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 70%);
}

/* ---- Container ---- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* ---- Header ---- */
.header {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    background: rgba(6, 9, 15, 0.85);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.header-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.header-logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-logo-sub {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.header-nav {
    display: flex;
    gap: 8px;
}

.header-nav a {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.header-nav a:hover,
.header-nav a.active {
    color: var(--text-primary);
    background: var(--bg-card);
    border-color: var(--border-color);
}

.header-nav a.active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ---- Saldo Hero Section ---- */
.saldo-hero {
    text-align: center;
    padding: 60px 0 40px;
    position: relative;
}

.saldo-label {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 12px;
}

.saldo-amount {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(42px, 8vw, 80px);
    font-weight: 800;
    background: linear-gradient(135deg, #3b82f6, #60a5fa, #93c5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    margin-bottom: 8px;
    animation: pulseGlow 3s ease-in-out infinite alternate;
}

.saldo-amount.paid-off {
    background: linear-gradient(135deg, #10b981, #34d399, #6ee7b7);
    -webkit-background-clip: text;
    background-clip: text;
}

@keyframes pulseGlow {
    0% { filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.2)); }
    100% { filter: drop-shadow(0 0 40px rgba(59, 130, 246, 0.4)); }
}

.saldo-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ---- Stats Row ---- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 32px 0;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.stat-card.green::before { background: linear-gradient(90deg, var(--accent-green), #34d399); }
.stat-card.amber::before { background: linear-gradient(90deg, var(--accent-amber), #fbbf24); }
.stat-card.blue::before { background: linear-gradient(90deg, var(--accent-primary), #60a5fa); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--accent-purple), #a78bfa); }

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.stat-card-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-card-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card.green .stat-card-value { color: var(--accent-green); }
.stat-card.amber .stat-card-value { color: var(--accent-amber); }
.stat-card.blue .stat-card-value { color: var(--accent-primary); }

/* ---- Progress Bar ---- */
.progress-section {
    margin: 32px 0;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-percentage {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-green);
}

.progress-bar-track {
    width: 100%;
    height: 12px;
    background: var(--bg-card);
    border-radius: 100px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-bar-fill {
    height: 100%;
    border-radius: 100px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-green));
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-width: 0%;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ---- Último Pago Card ---- */
.ultimo-pago-section {
    margin: 40px 0;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.section-title .icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.section-title .icon.green { background: var(--accent-green-glow); }
.section-title .icon.blue { background: var(--accent-primary-glow); }
.section-title .icon.amber { background: var(--accent-amber-glow); }

.ultimo-pago-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.ultimo-pago-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-primary));
}

.ultimo-pago-card:hover {
    border-color: var(--accent-green-glow);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.1);
}

.ultimo-pago-info h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.ultimo-pago-info .fecha {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.ultimo-pago-monto {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 800;
    color: var(--accent-green);
    margin-bottom: 12px;
}

.ultimo-pago-obs {
    color: var(--text-secondary);
    font-size: 14px;
    font-style: italic;
}

.btn-comprobante {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-primary), #2563eb);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    align-self: center;
    white-space: nowrap;
    border: none;
    cursor: pointer;
}

.btn-comprobante:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

.no-pago-msg {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 15px;
}

.no-pago-msg .emoji {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
}

/* ---- Historial de Pagos ---- */
.historial-section {
    margin: 40px 0 60px;
}

.pago-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.pago-item:hover {
    border-color: var(--border-glow);
    background: var(--bg-card-hover);
    transform: translateX(4px);
}

.pago-num {
    width: 36px;
    height: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
}

.pago-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pago-fecha {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.pago-obs {
    font-size: 13px;
    color: var(--text-muted);
}

.pago-monto {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-green);
    white-space: nowrap;
}

.pago-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 16px;
}

.pago-link:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* ---- Footer ---- */
.footer {
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

/* ---- Admin Styles ---- */
.login-container {
    max-width: 420px;
    margin: 80px auto;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
}

.login-card h2 {
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 800;
}

.login-card p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    transition: all 0.2s ease;
    outline: none;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-input[type="file"] {
    padding: 10px 16px;
    cursor: pointer;
}

.form-input[type="file"]::file-selector-button {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 12px;
    transition: background 0.2s ease;
}

.form-input[type="file"]::file-selector-button:hover {
    background: #2563eb;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #2563eb);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
    background: var(--bg-card);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ---- Admin Panel ---- */
.admin-panel {
    display: none;
}

.admin-panel.active {
    display: block;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 32px 0;
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
}

.admin-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-card h3 .icon {
    font-size: 20px;
}

/* ---- Admin Table ---- */
.admin-table-wrapper {
    margin: 32px 0;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.admin-table th {
    background: var(--bg-secondary);
    padding: 14px 18px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
}

.admin-table td {
    padding: 14px 18px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: var(--bg-card-hover);
}

.admin-table .monto-col {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--accent-green);
}

/* ---- Preview Comprobante ---- */
.file-preview {
    margin-top: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-width: 300px;
    background: var(--bg-secondary);
}

.file-preview img {
    width: 100%;
    display: block;
}

.file-preview .pdf-icon {
    padding: 20px;
    text-align: center;
    color: var(--accent-red);
    font-size: 14px;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 90%;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}

.modal-content img {
    max-width: 100%;
    display: block;
    border-radius: var(--radius-md);
}

.modal-content iframe {
    width: 800px;
    max-width: 100%;
    height: 80vh;
    border: none;
    border-radius: var(--radius-md);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

/* ---- Toast / Notifications ---- */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    max-width: 360px;
    animation: slideIn 0.3s ease, slideOut 0.3s ease forwards;
    animation-delay: 0s, 3s;
    box-shadow: var(--shadow-card);
}

.toast.success {
    background: #0d2818;
    border: 1px solid #166534;
    color: #4ade80;
}

.toast.error {
    background: #2d0a0a;
    border: 1px solid #991b1b;
    color: #fca5a5;
}

.toast.info {
    background: #0a1a2d;
    border: 1px solid #1e40af;
    color: #93c5fd;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ---- Loading Spinner ---- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Password Toggle ---- */
.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .header-inner {
        flex-direction: column;
        gap: 12px;
    }

    .saldo-hero {
        padding: 40px 0 24px;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card-value {
        font-size: 18px;
    }

    .ultimo-pago-card {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .pago-item {
        grid-template-columns: auto 1fr;
        gap: 12px;
    }

    .pago-monto {
        grid-column: 2;
        font-size: 16px;
    }

    .pago-link {
        grid-column: 2;
        justify-self: start;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-table {
        font-size: 13px;
    }

    .admin-table th,
    .admin-table td {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .header-nav a {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* ---- Animations ---- */
.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
