/* ════════════════════════════════════════════════════════════
   AMATISTA Pawn — Componentes UI
   Cards, Buttons, Progress Bars, Forms, Tables
   ════════════════════════════════════════════════════════════ */

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.625rem 1.25rem;
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    color: white;
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    box-shadow: var(--shadow-lg), 0 0 30px rgba(147, 51, 234, 0.4);
    transform: translateY(-1px);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
    color: var(--bg-primary);
    box-shadow: var(--shadow-md), var(--shadow-gold);
}

.btn-gold:hover {
    background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--primary-400);
    border: 1px solid var(--border-medium);
}

.btn-outline:hover {
    background: var(--bg-glass);
    border-color: var(--primary-400);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-icon {
    padding: 0.5rem;
    aspect-ratio: 1;
}

/* ── Theme Toggle Button ──────────────────────────────────── */
.theme-toggle {
    position: fixed;
    top: var(--space-md);
    right: var(--space-md);
    z-index: 1000;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    font-size: 1.25rem;
}

.theme-toggle:hover {
    transform: translateY(-2px);
    border-color: var(--primary-400);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.theme-toggle .sun-icon {
    display: none;
}

.theme-toggle .moon-icon {
    display: block;
}

[data-theme="light"] .theme-toggle .sun-icon {
    display: block;
}

[data-theme="light"] .theme-toggle .moon-icon {
    display: none;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all var(--transition-normal), background-color var(--transition-normal);
}

.card:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Stat Cards (Dashboard) ───────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-600), var(--primary-400));
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-medium);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* ── Sidebar Navigation Active States ── */
.nav-item.active {
    background: var(--bg-glass);
    color: var(--gold-primary) !important;
    border-left: 3px solid var(--gold-primary);
    padding-left: calc(var(--space-md) - 3px);
    box-shadow: inset 5px 0 15px rgba(212, 175, 55, 0.05);
}

.nav-item.active .nav-icon {
    filter: drop-shadow(0 0 5px var(--gold-primary));
}

.stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: var(--space-md);
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card.gold::before {
    background: linear-gradient(90deg, var(--gold-500), var(--gold-400));
}

.stat-card.success::before {
    background: linear-gradient(90deg, var(--success), #4ade80);
}

.stat-card.warning::before {
    background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.stat-card.danger::before {
    background: linear-gradient(90deg, var(--danger), #f87171);
}

/* ── Progress Bar ─────────────────────────────────────────── */
.progress-container {
    width: 100%;
    margin: var(--space-md) 0;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.progress-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-value {
    font-size: 0.875rem;
    font-weight: 700;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.2) 50%,
            transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

.progress-fill.green {
    background: linear-gradient(90deg, #22c55e, #4ade80);
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.progress-fill.yellow {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.progress-fill.red {
    background: linear-gradient(90deg, #ef4444, #f87171);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.progress-fill.purple {
    background: linear-gradient(90deg, var(--primary-600), var(--primary-400));
    box-shadow: var(--shadow-glow);
}

/* ── Progress Ring (Circular) ─────────────────────────────── */
.progress-ring-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    stroke: var(--bg-tertiary);
}

.progress-ring-fill {
    transition: stroke-dashoffset 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    stroke-linecap: round;
}

.progress-ring-text {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.progress-ring-subtext {
    position: absolute;
    bottom: 30%;
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-family);
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.15);
}

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

.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238b7a9e' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: var(--space-xs);
}

/* ── Tables ───────────────────────────────────────────────── */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead {
    background: var(--bg-tertiary);
}

.data-table th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-glass);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-active {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-expired {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-paid {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-defaulted {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ── Boleta Card ──────────────────────────────────────────── */
.boleta-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.boleta-card:hover {
    border-color: var(--border-medium);
    transform: translateX(4px);
}

.boleta-card .boleta-icon {
    font-size: 1.25rem;
    color: var(--primary-400);
}

.boleta-card .boleta-info {
    flex: 1;
}

.boleta-card .boleta-receipt {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.boleta-card .boleta-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.boleta-card .boleta-amount {
    font-weight: 700;
    font-size: 1rem;
    color: var(--success);
}

/* ── Wizard Stepper ───────────────────────────────────────── */
.wizard-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl) 0;
    gap: 0;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.wizard-step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    border: 2px solid var(--border-subtle);
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    transition: all var(--transition-normal);
}

.wizard-step-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-tertiary);
    transition: color var(--transition-normal);
}

.wizard-step.active .wizard-step-number {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    border-color: var(--primary-400);
    color: white;
    box-shadow: var(--shadow-glow);
}

.wizard-step.active .wizard-step-label {
    color: var(--text-primary);
}

.wizard-step.completed .wizard-step-number {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.wizard-step.completed .wizard-step-label {
    color: var(--success);
}

.wizard-connector {
    width: 60px;
    height: 2px;
    background: var(--border-subtle);
    margin: 0 var(--space-sm);
    transition: background var(--transition-normal);
}

.wizard-connector.active {
    background: linear-gradient(90deg, var(--primary-600), var(--primary-400));
}

@media (max-width: 640px) {
    .wizard-step-label {
        display: none;
    }

    .wizard-connector {
        width: 30px;
    }
}

/* ── Login Form ───────────────────────────────────────────── */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-xl);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-3xl);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.5s ease-out;
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.login-card .login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-glow);
    animation: pulse-glow 3s infinite;
}

.login-card .login-title {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-300), var(--gold-400));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-card .login-subtitle {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

/* ── Toast / Notifications ────────────────────────────────── */
.toast-container {
    position: fixed;
    top: var(--space-xl);
    right: var(--space-xl);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    animation: slideInLeft 0.3s ease-out;
    min-width: 300px;
    max-width: 450px;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1.125rem;
    padding: 0;
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-3xl);
    color: var(--text-tertiary);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.empty-state .empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

/* ── Loading Skeleton ─────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-tertiary) 25%,
            var(--bg-card-hover) 50%,
            var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1rem;
    width: 80%;
    margin-bottom: var(--space-sm);
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: var(--space-md);
}

.skeleton-card {
    height: 120px;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 500px;
    /* Altura máxima razonable para evitar empujar el footer */
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
}

/* ── Modals ───────────────────────────────────────────────── */
.modal,
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal.active,
.modal-overlay.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2xl);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: var(--space-2xl);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.close-modal {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-xl);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-modal:hover {
    color: var(--danger);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ════════════════════════════════════════════════════════════
   GLOBAL LOADING INDICATOR
   ════════════════════════════════════════════════════════════ */

#global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    background: rgba(15, 10, 26, 0.85);
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(4px);
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(107, 33, 168, 0.2);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader-text {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}