@import url('css/variables.css');

/* ===== Base Reset & Typography ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--prixly-text);
    background-color: var(--prixly-bg);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-family: var(--font-family-display);
    font-weight: var(--font-bold);
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--prixly-text);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }

/* Monospace tabular digits for dollar values and point balances — readability + alignment. */
.wallet-stat-value,
.summary-value,
.portfolio-total-value,
.dollar-amount,
.hero-subtitle,
.metrics-bar .metric-value,
.tabular-num {
    font-family: var(--font-family-mono);
    font-feature-settings: 'tnum' 1, 'zero' 1;
    letter-spacing: 0;
}

p {
    margin: 0;
    line-height: 1.6;
}

a {
    color: var(--prixly-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--prixly-primary-dark);
}

h1:focus {
    outline: none;
}

/* === Button System ===
   Primary actions (most prominent):    .btn-primary  (emerald)
   Secondary actions (less prominent):  .btn-secondary (outlined)
   Tertiary actions (lowest emphasis):  .btn-ghost (no border, transparent)
   Sizes: .btn-sm (compact), .btn-lg (large)
*/
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, opacity 150ms ease, transform 150ms ease;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--prixly-focus-ring, rgba(18, 201, 118, 0.3));
}

/* Custom non-.btn interactive elements — the reviewer flagged these as relying on UA-default
   focus rings which some browsers suppress. WCAG 2.4.7 requires a visible focus indicator. */
.btn-expand:focus-visible,
.toggle-btn:focus-visible,
.help-toggle:focus-visible,
.filter-select:focus-visible,
.setting-select:focus-visible,
.category-tile:focus-visible,
.hub-branch:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--prixly-focus-ring);
    border-color: var(--prixly-primary);
}

.btn:disabled,
.btn[disabled],
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;  /* prevent click on disabled <a> elements */
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: var(--prixly-success);
    color: white;
    border-color: var(--prixly-success);
}
.btn-primary:hover:not(:disabled):not([disabled]):not(.disabled) { filter: brightness(1.08); }
.btn-primary:active:not(:disabled):not([disabled]):not(.disabled) { filter: brightness(0.95); }

.btn-secondary {
    background: transparent;
    color: var(--prixly-text);
    border-color: var(--prixly-border);
}
.btn-secondary:hover:not(:disabled):not([disabled]):not(.disabled) { background: var(--prixly-surface-hover, rgba(255,255,255,0.04)); }

.btn-ghost {
    background: transparent;
    color: var(--prixly-text-secondary);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled):not([disabled]):not(.disabled) { background: var(--prixly-surface-hover, rgba(255,255,255,0.04)); color: var(--prixly-text); }

.btn-success { /* alias for primary, kept for backward compat */
    background: var(--prixly-success);
    color: white;
    border-color: var(--prixly-success);
}

.btn-sm { padding: var(--space-2) var(--space-3); font-size: var(--font-size-sm); }
.btn-lg { padding: var(--space-4) var(--space-6); font-size: var(--font-size-lg); }

/* ===== Cards (UI component, not credit cards) ===== */
.card {
    background: var(--prixly-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--prixly-border-light);
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-elevated {
    box-shadow: var(--shadow-md);
}

.card-elevated:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* ===== Feature Card ===== */
.feature-card {
    background: var(--prixly-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--prixly-border-light);
    transition: all var(--transition-base);
    cursor: pointer;
    text-align: center;
}

.feature-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: var(--prixly-primary-200);
}

.feature-card .feature-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-4);
    font-size: 1.75rem;
}

.feature-card .feature-icon.purple {
    background: var(--prixly-primary-100);
    color: var(--prixly-primary);
}

.feature-card .feature-icon.blue {
    background: var(--prixly-badge-airline-bg);
    color: var(--prixly-secondary);
}

.feature-card .feature-icon.green {
    background: var(--prixly-success-light);
    color: var(--prixly-success);
}

.feature-card h3 {
    margin-bottom: var(--space-2);
    font-size: var(--font-size-lg);
}

.feature-card p {
    color: var(--prixly-text-secondary);
    font-size: var(--font-size-sm);
}

/* ===== Badge / Chip ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-semibold);
}

.badge-primary {
    background: var(--prixly-primary-100);
    color: var(--prixly-primary-dark);
}

.badge-success {
    background: var(--prixly-success-light);
    color: var(--prixly-success-dark);
}

.badge-warning {
    background: var(--prixly-warning-light);
    color: var(--prixly-text-amber);
}

/* ===== Form Inputs ===== */
.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--prixly-border);
    border-radius: var(--radius-lg);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--prixly-text);
    background: var(--prixly-surface);
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--prixly-primary);
    box-shadow: 0 0 0 3px var(--prixly-primary-200);
}

.form-input::placeholder {
    color: var(--prixly-text-muted);
}

/* ===== Progress Bar ===== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--prixly-border-light);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--prixly-primary), var(--prixly-accent));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* ===== Savings Counter ===== */
.savings-counter {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--prixly-success-light);
    color: var(--prixly-success-dark);
    border-radius: var(--radius-full);
    font-weight: var(--font-semibold);
    font-size: var(--font-size-sm);
}

/* ===== Page Layout Helpers ===== */
.page-header {
    margin-bottom: var(--space-8);
}

.page-header h1 {
    margin-bottom: var(--space-2);
}

.page-header p {
    color: var(--prixly-text-secondary);
    font-size: var(--font-size-lg);
}

.section {
    margin-bottom: var(--space-8);
}

.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* Small phone safety: force single column */
@media (max-width: 480px) {
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .grid {
        gap: var(--space-4);
    }
}

/* ===== Tooltip / Info Popover ===== */
.info-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--prixly-primary-100);
    color: var(--prixly-primary);
    font-size: 11px;
    font-weight: var(--font-bold);
    cursor: help;
    margin-left: var(--space-1);
    vertical-align: middle;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes countUp {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.animate-fade-in {
    animation: fadeInUp 0.5s ease-out;
}

.animate-slide-in {
    animation: slideInRight 0.3s ease-out;
}

/* ===== Achievement Toast ===== */
.achievement-toast {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    background: var(--prixly-surface);
    border: 2px solid var(--prixly-primary-200);
    border-radius: var(--radius-xl);
    padding: var(--space-4) var(--space-6);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    animation: slideInRight 0.4s ease-out;
    z-index: 1000;
}

.achievement-toast .toast-icon {
    font-size: 2rem;
}

.achievement-toast .toast-content h4 {
    font-size: var(--font-size-sm);
    color: var(--prixly-primary);
    font-weight: var(--font-semibold);
}

.achievement-toast .toast-content p {
    font-size: var(--font-size-sm);
    color: var(--prixly-text-secondary);
}

/* ===== Loading ===== */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-8);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--prixly-border-light);
    border-top-color: var(--prixly-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Credit Card Visual ===== */
.credit-card-visual {
    background: linear-gradient(135deg, var(--prixly-primary), var(--prixly-secondary));
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    color: white;
    aspect-ratio: 1.586 / 1;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-lg);
}

/* ===== Blazor Error UI ===== */
/* Hide the default Blazor unhandled-error banner. Errors are handled by
   the ErrorBoundary component in Routes.razor instead. */
#blazor-error-ui {
    display: none !important;
}

.blazor-error-boundary {
    background: var(--prixly-error-light);
    padding: var(--space-4);
    color: var(--prixly-error);
    border-radius: var(--radius-lg);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ===== Validation ===== */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--prixly-success);
}

.invalid {
    outline: 1px solid var(--prixly-error);
}

.validation-message {
    color: var(--prixly-error);
    font-size: var(--font-size-sm);
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--prixly-text-secondary); }
.text-success { color: var(--prixly-success); }
.text-primary { color: var(--prixly-primary); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
