/* ========================================
   PennyWiz - Ultra Premium Design System
   Inspired by Apple, Stripe, and Linear
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Primary Palette - Refined Blues */
    --primary: #0071E3;
    --primary-hover: #0077ED;
    --primary-pressed: #006EDB;

    /* Neutral Palette - Sophisticated Grays */
    --background: #FFFFFF;
    --surface: #FFFFFF;
    --surface-raised: #FAFAFA;
    --surface-overlay: rgba(255, 255, 255, 0.9);

    /* Text Hierarchy */
    --text-primary: #1D1D1F;
    --text-secondary: #6E6E73;
    --text-tertiary: #86868B;
    --text-inverse: #FFFFFF;

    /* Borders */
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.1);
    --border-strong: rgba(0, 0, 0, 0.15);

    /* Shadows - Apple-inspired depth */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.12);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Blur */
    --blur-sm: 8px;
    --blur-md: 12px;
    --blur-lg: 24px;
}

[data-theme="dark"] {
    /* Primary Palette */
    --primary: #0A84FF;
    --primary-hover: #409CFF;
    --primary-pressed: #0077ED;

    /* Neutral Palette */
    --background: #000000;
    --surface: #1C1C1E;
    --surface-raised: #2C2C2E;
    --surface-overlay: rgba(28, 28, 30, 0.95);

    /* Text Hierarchy */
    --text-primary: #F5F5F7;
    --text-secondary: #A1A1A6;
    --text-tertiary: #6E6E73;
    --text-inverse: #FFFFFF;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.7);
}

/* ========================================
   Typography
   ======================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 17px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'kern' 1;
    text-rendering: optimizeLegibility;
    transition: background-color var(--transition-base), color var(--transition-base);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 48px;
}

@media (max-width: 1024px) {
    .container {
        padding: 0 40px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 24px;
    }
}

/* ========================================
   Header
   ======================================== */
header {
    background: var(--surface-overlay);
    backdrop-filter: saturate(180%) blur(var(--blur-lg));
    -webkit-backdrop-filter: saturate(180%) blur(var(--blur-lg));
    border-bottom: 1px solid var(--border-subtle);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all var(--transition-base);
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-content {
    display: flex;
    align-items: baseline;
    gap: 16px;
}

header h1 {
    font-size: 21px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

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

/* ========================================
   Main Content
   ======================================== */
main {
    padding: 88px 0 96px;
}

/* Intro Section */
.intro {
    margin-bottom: 72px;
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.intro h2 {
    font-size: 64px;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.025em;
    line-height: 1.05;
    color: var(--text-primary);
}

.intro p {
    font-size: 21px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 auto;
    font-weight: 400;
    max-width: 640px;
}

/* ========================================
   Calculator Grid
   ======================================== */
.calculators-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 1024px) {
    .calculators-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.calculator-card {
    background: var(--surface);
    padding: 44px 40px 40px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    transition: all var(--transition-slow);
    position: relative;
    cursor: pointer;
}

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

.calculator-card:active {
    transform: translateY(-2px);
}

.card-icon {
    font-size: 52px;
    margin-bottom: 24px;
    display: block;
    opacity: 0.95;
    transition: transform var(--transition-base);
}

.calculator-card:hover .card-icon {
    transform: scale(1.05);
}

.calculator-card h3 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: -0.015em;
    color: var(--text-primary);
    line-height: 1.2;
}

.calculator-card p {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 32px;
    font-size: 16px;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    background: var(--surface);
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
}

.btn:hover {
    background: var(--surface-raised);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.btn-success {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.btn-success:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.25);
}

.btn-success:active {
    background: var(--primary-pressed);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 40px;
    color: var(--primary);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.back-link:hover {
    opacity: 0.8;
    transform: translateX(-2px);
}

/* ========================================
   Calculator Pages
   ======================================== */
.calculator-page {
    max-width: 780px;
    margin: 0 auto;
}

.calculator-page h2 {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.025em;
    line-height: 1.1;
    color: var(--text-primary);
}

.calculator-page > p {
    color: var(--text-secondary);
    margin-bottom: 56px;
    font-size: 19px;
    line-height: 1.5;
}

/* Form Styles */
.form-group {
    margin-bottom: 28px;
}

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

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-size: 17px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    font-weight: 400;
}

.form-group input:hover,
.form-group select:hover {
    border-color: var(--border-strong);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-tertiary);
    font-size: 13px;
    font-weight: 400;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 40px;
}

.button-group button {
    flex: 1;
}

/* ========================================
   Results Section
   ======================================== */
.results {
    margin-top: 64px;
    padding: 48px;
    background: var(--surface);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border-subtle);
    max-width: 100%;
    box-shadow: var(--shadow-md);
}

.results.hidden {
    display: none;
}

.results.wide {
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 1440px) {
    .results {
        padding: 56px;
    }
}

.results h3 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 32px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

.result-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.highlight-result {
    background: var(--primary);
    color: var(--text-inverse);
    padding: 48px;
    margin-top: 32px;
    text-align: center;
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 24px rgba(0, 113, 227, 0.25);
}

.highlight-result > div:first-child {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    opacity: 0.85;
    font-weight: 600;
}

.highlight-result > div:last-child {
    font-size: 56px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* ========================================
   Chart Container
   ======================================== */
.chart-container {
    margin-top: 56px;
    padding: 40px;
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border-subtle);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.chart-container h3 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 32px;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}

.chart-wrapper {
    position: relative;
    height: 420px;
    width: 100%;
}

@media (min-width: 1440px) {
    .chart-wrapper {
        height: 480px;
    }
}

/* ========================================
   Footer
   ======================================== */
footer {
    border-top: 1px solid var(--border-subtle);
    padding: 56px 0;
    margin-top: 120px;
    text-align: center;
}

footer p {
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 400;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Wide Desktop Enhancements */
@media (min-width: 1440px) {
    main {
        padding: 104px 0 120px;
    }

    .intro h2 {
        font-size: 72px;
    }

    .intro p {
        font-size: 24px;
    }

    .calculator-card {
        padding: 48px 44px 44px;
    }
}

/* Tablet */
@media (max-width: 1024px) {
    .calculator-page {
        max-width: 680px;
    }

    .intro h2 {
        font-size: 56px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    main {
        padding: 64px 0 56px;
    }

    .intro h2 {
        font-size: 40px;
        letter-spacing: -0.02em;
    }

    .intro p {
        font-size: 19px;
    }

    .intro {
        margin-bottom: 56px;
    }

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

    .calculator-card {
        padding: 36px 32px 32px;
    }

    .calculator-page {
        max-width: 100%;
        padding: 0;
    }

    .calculator-page h2 {
        font-size: 36px;
    }

    .button-group {
        flex-direction: column;
    }

    .result-item {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .results {
        padding: 32px;
    }

    .chart-container {
        padding: 28px;
    }

    .chart-wrapper {
        height: 300px;
    }

    .highlight-result > div:last-child {
        font-size: 40px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 19px;
    }

    .tagline {
        display: none;
    }

    .intro h2 {
        font-size: 36px;
    }

    .calculator-card {
        padding: 28px 24px 24px;
    }

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

    .calculator-card h3 {
        font-size: 21px;
    }
}

/* ========================================
   Net Worth Calculator Styles
   ======================================== */
.asset-entry {
    background: var(--surface);
    padding: 24px;
    margin-bottom: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-base);
}

.asset-entry:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-sm);
}

.asset-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr 1.5fr auto;
    gap: 16px;
    align-items: end;
}

.asset-category-select {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.category-chip {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-medium);
    background: var(--surface);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
}

.category-chip:hover {
    border-color: var(--primary);
    background: var(--surface-raised);
}

.category-chip.selected {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.remove-asset-btn {
    background: var(--text-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.remove-asset-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.add-asset-btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    background: var(--surface);
    transition: all var(--transition-fast);
    cursor: pointer;
    margin-top: 16px;
    width: 100%;
}

.add-asset-btn:hover {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 32px 0;
}

.metric-card {
    background: var(--surface);
    padding: 32px 28px;
    text-align: center;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-medium);
}

.metric-label {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.metric-value.positive {
    color: var(--primary);
}

.metric-value.negative {
    color: var(--text-secondary);
}

.metric-subtitle {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 8px;
    font-weight: 400;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 32px 0;
}

.chart-box {
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.chart-box.full-width {
    grid-column: 1 / -1;
}

.chart-box h3 {
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.assets-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 32px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.assets-table thead {
    background: var(--text-primary);
    color: var(--text-inverse);
}

.assets-table th,
.assets-table td {
    padding: 16px 18px;
    text-align: left;
}

.assets-table th {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    user-select: none;
}

.assets-table th:hover {
    opacity: 0.9;
}

.assets-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.assets-table tbody tr:hover {
    background: var(--surface-raised);
}

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

.roi-badge {
    padding: 4px 10px;
    font-weight: 600;
    font-size: 13px;
    border-radius: 6px;
}

.roi-badge.positive {
    color: var(--primary);
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
}

.roi-badge.negative {
    color: var(--text-secondary);
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
}

.category-badge {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    border-radius: 6px;
    background: var(--surface-raised);
    color: var(--primary);
    border: 1px solid var(--border-subtle);
}

.insights-section {
    background: var(--surface);
    color: var(--text-primary);
    padding: 40px;
    margin: 32px 0;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
}

.insights-section h3 {
    margin-top: 0;
    margin-bottom: 28px;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.insight-item {
    background: var(--surface-raised);
    color: var(--text-primary);
    padding: 16px 20px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    transition: all var(--transition-fast);
}

.insight-item:hover {
    background: var(--surface);
    border-color: var(--border-medium);
    transform: translateX(2px);
}

.insight-item:last-child {
    margin-bottom: 0;
}

.insight-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.insight-text {
    flex: 1;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.5;
}

.insight-text strong {
    font-weight: 600;
    color: var(--primary);
}

.intro-text {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 17px;
    line-height: 1.5;
}

/* ========================================
   Amortization Calculator Styles
   ======================================== */
.amortization-table {
    width: 100%;
    margin-top: 32px;
    border-collapse: collapse;
    font-size: 14px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.amortization-table thead {
    background: var(--text-primary);
    color: var(--text-inverse);
}

.amortization-table th {
    padding: 16px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.amortization-table td {
    padding: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.amortization-table tbody tr:hover {
    background: var(--surface-raised);
}

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

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

.text-gray {
    color: var(--text-secondary);
}

.table-container {
    max-height: 600px;
    overflow-y: auto;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    margin-top: 32px;
    box-shadow: var(--shadow-sm);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 32px;
}

.summary-item {
    background: var(--surface);
    padding: 32px 28px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.summary-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-medium);
}

.summary-label {
    font-size: 13px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
    font-weight: 500;
}

.summary-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

/* ========================================
   Responsive Design - Additional
   ======================================== */

/* Wide Desktop - Tables and Charts */
@media (min-width: 1440px) {
    .charts-container {
        gap: 20px;
    }

    .chart-box {
        padding: 40px;
    }

    .amortization-table th,
    .amortization-table td {
        padding: 16px;
    }
}

/* Tablet - Tables and Charts */
@media (max-width: 1024px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}

/* Mobile - Tables and Charts */
@media (max-width: 768px) {
    .asset-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    .chart-box.full-width {
        grid-column: 1;
    }

    .assets-table {
        font-size: 13px;
    }

    .assets-table th,
    .assets-table td {
        padding: 12px 10px;
    }

    .amortization-table {
        font-size: 12px;
    }

    .amortization-table th,
    .amortization-table td {
        padding: 10px 8px;
    }
}

/* ========================================
   Utility
   ======================================== */
html {
    scroll-behavior: smooth;
}

::selection {
    background: var(--primary);
    color: var(--text-inverse);
}

*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

/* ========================================
   Settings Panel
   ======================================== */
.settings-toggle {
    position: fixed;
    top: 28px;
    right: 48px;
    z-index: 10001;
    background: var(--surface-overlay);
    backdrop-filter: saturate(180%) blur(var(--blur-md));
    -webkit-backdrop-filter: saturate(180%) blur(var(--blur-md));
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 10px 18px;
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.settings-toggle:hover {
    background: var(--surface);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.settings-toggle:active {
    transform: translateY(0);
}

.settings-icon {
    font-size: 16px;
    line-height: 1;
}

.settings-text {
    font-family: inherit;
}

.settings-panel {
    position: fixed;
    top: 72px;
    right: 48px;
    background: var(--surface-overlay);
    backdrop-filter: saturate(180%) blur(var(--blur-lg));
    -webkit-backdrop-filter: saturate(180%) blur(var(--blur-lg));
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 24px;
    min-width: 280px;
    z-index: 10000;
    box-shadow: var(--shadow-xl);
    display: none;
    animation: slideDown var(--transition-base);
}

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

.settings-panel.active {
    display: block;
}

.settings-panel h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.theme-toggle {
    display: flex;
    gap: 8px;
}

.theme-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
}

.theme-btn:hover {
    border-color: var(--border-strong);
    background: var(--surface-raised);
}

.theme-btn.active {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.language-select,
.currency-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.language-select:hover,
.currency-select:hover {
    border-color: var(--border-strong);
    background: var(--surface-raised);
}

.language-select:focus,
.currency-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .settings-toggle {
        top: 24px;
        right: 24px;
        padding: 10px 14px;
    }

    .settings-text {
        display: none;
    }

    .settings-icon {
        font-size: 18px;
    }

    .settings-panel {
        right: 24px;
        left: 24px;
        top: 66px;
        min-width: unset;
    }
}

@media (max-width: 480px) {
    .settings-toggle {
        right: 16px;
        top: 20px;
    }

    .settings-panel {
        right: 16px;
        left: 16px;
        top: 62px;
    }
}

/* ========================================
   Onboarding Flow
   ======================================== */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.onboarding-overlay.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.onboarding-container {
    background: var(--surface);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.onboarding-content {
    padding: 48px;
    position: relative;
}

.onboarding-header {
    text-align: center;
    margin-bottom: 48px;
}

.onboarding-title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.onboarding-subtitle {
    font-size: 17px;
    color: var(--text-secondary);
    font-weight: 400;
}

.onboarding-body {
    margin-bottom: 48px;
}

.step-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-align: center;
}

/* Language Options */
.language-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) transparent;
}

.language-options::-webkit-scrollbar {
    width: 6px;
}

.language-options::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.language-options::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

.language-options::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

.language-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    background: var(--surface-raised);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
    min-height: 80px;
}

.language-option:hover {
    background: var(--surface);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.language-option:active {
    transform: translateY(0);
}

.language-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    margin-bottom: 4px;
}

.language-code {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Currency Options */
.currency-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) transparent;
}

.currency-options::-webkit-scrollbar {
    width: 6px;
}

.currency-options::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.currency-options::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

.currency-options::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

.currency-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 12px;
    background: var(--surface-raised);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
    min-height: 90px;
}

.currency-option:hover {
    background: var(--surface);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.currency-option:active {
    transform: translateY(0);
}

.currency-symbol {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.currency-name {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.3;
}

/* Theme Options */
.theme-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    background: var(--surface-raised);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
}

.theme-option:hover {
    background: var(--surface);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.theme-option:active {
    transform: translateY(0);
}

.theme-preview {
    width: 100%;
    height: 120px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid var(--border-medium);
}

.theme-preview-light {
    background: #FFFFFF;
}

.theme-preview-light .preview-header {
    background: linear-gradient(135deg, #0071E3 0%, #00A8E8 100%);
    height: 40px;
}

.theme-preview-light .preview-body {
    background: #FAFAFA;
    height: 80px;
}

.theme-preview-dark {
    background: #000000;
    border-color: rgba(255, 255, 255, 0.1);
}

.theme-preview-dark .preview-header {
    background: linear-gradient(135deg, #0A84FF 0%, #00A8E8 100%);
    height: 40px;
}

.theme-preview-dark .preview-body {
    background: #1C1C1E;
    height: 80px;
}

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

/* Onboarding Footer */
.onboarding-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

.step-indicators {
    display: flex;
    gap: 8px;
}

.step-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-medium);
    transition: all var(--transition-base);
}

.step-indicator.active {
    background: var(--primary);
    width: 24px;
    border-radius: 4px;
}

.onboarding-skip {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.onboarding-skip:hover {
    background: var(--surface-raised);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .onboarding-content {
        padding: 32px 24px;
    }

    .onboarding-title {
        font-size: 28px;
    }

    .currency-options {
        grid-template-columns: repeat(2, 1fr);
        max-height: 360px;
    }

    .language-options {
        grid-template-columns: repeat(2, 1fr);
        max-height: 360px;
    }
}

@media (max-width: 480px) {
    .onboarding-overlay {
        padding: 16px;
    }

    .onboarding-content {
        padding: 24px 20px;
    }

    .onboarding-title {
        font-size: 24px;
    }

    .onboarding-subtitle {
        font-size: 15px;
    }

    .step-title {
        font-size: 18px;
    }

    .currency-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        max-height: 320px;
    }

    .currency-option {
        padding: 14px 10px;
        min-height: 75px;
    }

    .currency-symbol {
        font-size: 24px;
        margin-bottom: 4px;
    }

    .currency-name {
        font-size: 11px;
    }

    .theme-options {
        grid-template-columns: 1fr;
    }

    .language-options {
        grid-template-columns: 1fr;
        gap: 8px;
        max-height: 320px;
    }

    .language-option {
        padding: 14px 12px;
        min-height: 70px;
    }

    .language-name {
        font-size: 15px;
    }

    .language-code {
        font-size: 11px;
    }
}
