/* ============================================
   FCAI Drive-away Calculator — site.css
   Modern, responsive design with Inter font
   ============================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-bg: #f0f2f5;
    --color-surface: #ffffff;
    --color-primary: #1a56db;
    --color-primary-hover: #1447b8;
    --color-primary-light: #e8effc;
    --color-accent: #0ea5e9;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-border: #e2e8f0;
    --color-error: #dc2626;
    --color-error-bg: #fef2f2;
    --color-success: #16a34a;
    --color-success-bg: #f0fdf4;
    --color-warning-bg: #fffbeb;
    --color-warning: #d97706;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.05);
    --transition: 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html {
    font-size: 14px;
}

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

form {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Header --- */
.site-header {
    background: linear-gradient(135deg, #1a56db 0%, #0ea5e9 100%);
    color: #fff;
    padding: 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user {
    font-size: 0.875rem;
    opacity: 0.9;
}

.nav-logout {
    color: #fff;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius);
    transition: var(--transition);
}

.nav-logout:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.7);
    color: #fff;
    text-decoration: none;
}

/* --- Main & Footer --- */
.site-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

.site-footer {
    text-align: center;
    padding: 1rem;
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    border-top: 1px solid var(--color-border);
}

/* --- Login Page --- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.login-header p {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 0.75em 0.75em;
    padding-right: 2rem;
}

.field-error {
    color: var(--color-error);
    font-size: 0.8rem;
    margin-top: 0.2rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg);
}

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
}

/* --- Alerts --- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid #fecaca;
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid #bbf7d0;
}

/* --- Calculator Tabs --- */
.calc-tabs {
    display: flex;
    gap: 0;
    background: var(--color-surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-sm);
    border-bottom: 2px solid var(--color-border);
    overflow: hidden;
}

.calc-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.calc-tab:hover {
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.calc-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: var(--color-primary-light);
}

/* --- Calculator Card --- */
.calc-card {
    background: var(--color-surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.calc-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--color-border);
}

/* --- Form Grid Layout --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}

.form-grid .form-group {
    margin-bottom: 0;
}

/* --- Calculation Actions --- */
.calc-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.calc-actions .btn {
    flex: 0 1 auto;
}

/* --- Results Section --- */
.results-container {
    margin-top: 1.5rem;
}

.results-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.results-header {
    background: linear-gradient(135deg, #1a56db 0%, #0ea5e9 100%);
    color: #fff;
    padding: 1rem 1.5rem;
}

.results-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.results-body {
    padding: 1.25rem 1.5rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.875rem;
}

.result-row+.result-row {
    border-top: 1px solid var(--color-border);
}

.result-label {
    color: var(--color-text-secondary);
    font-weight: 500;
}

.result-value {
    font-weight: 600;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.result-row.result-total {
    padding: 0.75rem 0;
    margin-top: 0.5rem;
    border-top: 2px solid var(--color-primary);
}

.result-row.result-total .result-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.result-row.result-total .result-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .site-main {
        padding: 1rem;
    }

    .login-card {
        padding: 1.5rem;
    }

    .form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .calc-card {
        padding: 1rem;
    }

    .results-body {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .calc-tabs {
        flex-direction: column;
    }

    .calc-tab {
        border-bottom: none;
        border-left: 3px solid transparent;
    }

    .calc-tab.active {
        border-left-color: var(--color-primary);
    }

    .header-container {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* --- Tab Panels (show/hide) --- */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* --- Loading Overlay --- */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}