/* ═══════════════════════════════════════════════════════════════════
   Mortgage Calculator Pro — Frontend Styles
   A polished, production-grade UI system
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
    --mcp-bg: #f5f6fa;
    --mcp-surface: #ffffff;
    --mcp-surface-soft: #f7f8fc;
    --mcp-border: #e6e8ef;
    --mcp-border-strong: #d3d6e0;
    --mcp-text: #0f172a;
    --mcp-text-muted: #64748b;
    --mcp-text-subtle: #94a3b8;

    --mcp-primary: #4f46e5;
    --mcp-primary-600: #4338ca;
    --mcp-primary-700: #3730a3;
    --mcp-accent: #ec4899;
    --mcp-accent-600: #db2777;
    --mcp-success: #10b981;
    --mcp-danger: #ef4444;

    --mcp-radius-sm: 8px;
    --mcp-radius: 12px;
    --mcp-radius-lg: 18px;
    --mcp-radius-xl: 24px;

    --mcp-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --mcp-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
    --mcp-shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.08);
    --mcp-shadow-glow: 0 8px 32px rgba(79, 70, 229, 0.28);

    --mcp-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Calculator Wrapper ─── */
.mcp-calculator-wrapper {
    max-width: 1040px;
    margin: 48px auto;
    padding: 0 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--mcp-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

.mcp-calculator-card {
    background: var(--mcp-surface);
    border-radius: var(--mcp-radius-xl);
    box-shadow: var(--mcp-shadow-lg);
    padding: 40px 44px;
    border: 1px solid rgba(15, 23, 42, 0.04);
}

.mcp-calc-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--mcp-text);
    margin: 0 0 32px;
    text-align: center;
    letter-spacing: -0.025em;
}

/* ─── Grid Layout ─── */
.mcp-calc-grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 48px;
    align-items: start;
}

/* ─── Fields ─── */
.mcp-field {
    margin-bottom: 22px;
}

.mcp-field-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: 600;
    font-size: 13px;
    color: var(--mcp-text-muted);
    margin-bottom: 10px;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.mcp-field-value {
    color: var(--mcp-primary);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
    text-transform: none;
    font-variant-numeric: tabular-nums;
}

/* ─── Range Slider ─── */
.mcp-range {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: transparent;
    border-radius: 999px;
    outline: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    background-image: linear-gradient(
        to right,
        var(--mcp-primary) 0%,
        var(--mcp-primary) var(--mcp-fill, 0%),
        var(--mcp-border) var(--mcp-fill, 0%),
        var(--mcp-border) 100%
    );
    transition: background-image 0.12s linear;
}

/* WebKit thumb — solid filled, soft shadow, smooth scaling */
.mcp-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--mcp-primary);
    border: 3px solid #ffffff;
    cursor: grab;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        0 4px 12px rgba(79, 70, 229, 0.35);
    transition:
        transform 0.18s var(--mcp-ease),
        box-shadow 0.2s var(--mcp-ease),
        background-color 0.2s var(--mcp-ease);
    margin-top: -7px; /* (track 8 - thumb 22) / 2 = -7 → centers thumb on track */
}

.mcp-range:hover::-webkit-slider-thumb {
    transform: scale(1.08);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        0 6px 18px rgba(79, 70, 229, 0.45);
}

.mcp-range:active::-webkit-slider-thumb {
    cursor: grabbing;
    transform: scale(1.12);
    box-shadow:
        0 0 0 6px rgba(79, 70, 229, 0.14),
        0 6px 20px rgba(79, 70, 229, 0.5);
}

.mcp-range:focus-visible::-webkit-slider-thumb {
    box-shadow:
        0 0 0 4px rgba(79, 70, 229, 0.18),
        0 4px 12px rgba(79, 70, 229, 0.4);
}

/* Firefox thumb + track */
.mcp-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--mcp-primary);
    border: 3px solid #ffffff;
    cursor: grab;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        0 4px 12px rgba(79, 70, 229, 0.35);
    transition:
        transform 0.18s var(--mcp-ease),
        box-shadow 0.2s var(--mcp-ease);
}

.mcp-range:hover::-moz-range-thumb {
    transform: scale(1.08);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        0 6px 18px rgba(79, 70, 229, 0.45);
}

.mcp-range:active::-moz-range-thumb {
    cursor: grabbing;
    transform: scale(1.12);
}

.mcp-range::-moz-range-track {
    height: 8px;
    background: var(--mcp-border);
    border-radius: 999px;
    border: none;
}

.mcp-range::-moz-range-progress {
    height: 8px;
    background: var(--mcp-primary);
    border-radius: 999px;
}

/* IE / legacy Edge */
.mcp-range::-ms-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--mcp-primary);
    border: 3px solid #ffffff;
    cursor: grab;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.mcp-range::-ms-track {
    height: 8px;
    background: transparent;
    border-color: transparent;
    color: transparent;
}

.mcp-range::-ms-fill-lower {
    background: var(--mcp-primary);
    border-radius: 999px;
}

.mcp-range::-ms-fill-upper {
    background: var(--mcp-border);
    border-radius: 999px;
}

.mcp-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--mcp-text-subtle);
    margin-top: 8px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ─── Segmented Tabs (Residency Status) ─── */
.mcp-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    background: var(--mcp-surface-soft);
    border: 1px solid var(--mcp-border);
    border-radius: var(--mcp-radius);
    position: relative;
}

.mcp-tab {
    appearance: none;
    background: transparent;
    border: none;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--mcp-text-muted);
    cursor: pointer;
    border-radius: 9px;
    transition: color 0.18s var(--mcp-ease), background 0.18s var(--mcp-ease), box-shadow 0.18s var(--mcp-ease), font-weight 0.18s var(--mcp-ease);
    text-align: center;
    letter-spacing: -0.005em;
    position: relative;
    z-index: 1;
}

.mcp-tab:hover:not(.active) {
    color: var(--mcp-text);
}

.mcp-tab.active {
    background: var(--mcp-surface);
    color: var(--mcp-text) !important;
    box-shadow:
        var(--mcp-shadow-sm),
        0 0 0 1px rgba(79, 70, 229, 0.18),
        0 2px 6px rgba(79, 70, 229, 0.12);
}

.mcp-tab.active:hover {
    color: var(--mcp-text) !important;
}

.mcp-tab:focus-visible {
    outline: 2px solid var(--mcp-primary);
    outline-offset: 2px;
}

/* ─── Result Column ─── */
.mcp-calc-result {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ─── Monthly Payment Card ─── */
.mcp-monthly-payment-card {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #8b5cf6 100%);
    border-radius: var(--mcp-radius-lg);
    padding: 36px 28px;
    text-align: center;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--mcp-shadow-glow);
}

.mcp-monthly-payment-card::before {
    content: "";
    position: absolute;
    top: -40%;
    right: -20%;
    width: 240px;
    height: 240px;
    background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 70%);
    pointer-events: none;
}

.mcp-monthly-payment-card::after {
    content: "";
    position: absolute;
    bottom: -60%;
    left: -10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.25) 0%, transparent 70%);
    pointer-events: none;
}

.mcp-payment-label {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.85;
    display: block;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    position: relative;
    z-index: 1;
}

.mcp-payment-amount {
    display: block;
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    position: relative;
    z-index: 1;
}

.mcp-payment-amount .mcp-currency {
    font-size: 22px;
    font-weight: 600;
    opacity: 0.85;
    margin-left: 6px;
}

/* ─── Cost Breakdown Card ─── */
/* Compact tri-stat strip: three peer percentages sit side by side so the card
   stays short, with hairline dividers reading them as one related set. */
.mcp-cost-breakdown {
    background: var(--mcp-surface-soft);
    border: 1px solid var(--mcp-border);
    border-radius: var(--mcp-radius);
    padding: 14px 16px;
}

.mcp-breakdown-title {
    display: block;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--mcp-text-subtle);
    margin-bottom: 12px;
}

.mcp-breakdown-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

.mcp-breakdown-stat {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 6px;
}

/* Vertical hairline between adjacent stats, centered on the value row. */
.mcp-breakdown-stat + .mcp-breakdown-stat::before {
    content: "";
    position: absolute;
    left: 0;
    top: 2px;
    height: 22px;
    width: 1px;
    background: var(--mcp-border);
}

.mcp-breakdown-value {
    font-size: 21px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--mcp-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.mcp-breakdown-label {
    margin-top: 5px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1.3;
    color: var(--mcp-text-muted);
}

/* ─── Lead Form Card ─── */
.mcp-lead-form {
    background: var(--mcp-surface-soft);
    border: 1px solid var(--mcp-border);
    border-radius: var(--mcp-radius-lg);
    padding: 28px;
}

.mcp-lead-form h3 {
    font-size: 19px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--mcp-text);
    letter-spacing: -0.02em;
}

.mcp-form-subtitle {
    font-size: 13px;
    color: var(--mcp-text-muted);
    margin: 0 0 22px;
    line-height: 1.5;
}

/* ─── Form Elements ─── */
.mcp-form-group {
    margin-bottom: 12px;
}

.mcp-input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--mcp-border);
    border-radius: var(--mcp-radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--mcp-surface);
    color: var(--mcp-text);
    transition: border-color 0.18s var(--mcp-ease), box-shadow 0.18s var(--mcp-ease);
    box-sizing: border-box;
    font-weight: 500;
}

.mcp-input::placeholder {
    color: var(--mcp-text-subtle);
    font-weight: 400;
}

.mcp-input:hover {
    border-color: var(--mcp-border-strong);
}

.mcp-input:focus {
    border-color: var(--mcp-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    outline: none;
}

/* ─── Phone Row (unified, dial-code chip) ─── */
.mcp-phone-row {
    display: flex;
    align-items: stretch;
    margin-bottom: 12px;
    background: var(--mcp-surface);
    border: 1.5px solid var(--mcp-border);
    border-radius: var(--mcp-radius);
    overflow: hidden;
    transition: border-color 0.18s var(--mcp-ease), box-shadow 0.18s var(--mcp-ease);
}

.mcp-phone-row:hover {
    border-color: var(--mcp-border-strong);
}

.mcp-phone-row:focus-within {
    border-color: var(--mcp-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.mcp-dial-code {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    padding-right: 26px;
    padding-left: 14px;
    background: transparent;
    border-right: 1px solid var(--mcp-border);
    cursor: pointer;
    min-height: 46px;
}

.mcp-dial-code::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 1.8px solid var(--mcp-text-muted);
    border-bottom: 1.8px solid var(--mcp-text-muted);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
    transition: border-color 0.18s var(--mcp-ease);
}

.mcp-phone-row:focus-within .mcp-dial-code::after {
    border-color: var(--mcp-primary);
}

.mcp-dial-code select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--mcp-text);
    cursor: pointer;
    width: auto;
    min-width: 78px;
    outline: none;
    letter-spacing: -0.01em;
    line-height: 1;
    text-overflow: ellipsis;
}

.mcp-dial-code select::-ms-expand {
    display: none;
}

.mcp-dial-code select option {
    padding: 8px;
    font-weight: 500;
    background: var(--mcp-surface);
    color: var(--mcp-text);
}

.mcp-phone-input-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    min-width: 0;
}

.mcp-phone-input {
    width: 100%;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    padding: 13px 16px !important;
    box-shadow: none !important;
    outline: none;
}

.mcp-phone-input:focus {
    box-shadow: none !important;
    border: none !important;
}

/* ─── Submit Button ─── */
.mcp-submit-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--mcp-accent) 0%, var(--mcp-accent-600) 100%);
    color: #fff;
    border: none;
    border-radius: var(--mcp-radius);
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 0.15s var(--mcp-ease), box-shadow 0.2s var(--mcp-ease), filter 0.18s var(--mcp-ease);
    box-shadow: 0 6px 18px rgba(236, 72, 153, 0.32);
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mcp-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(236, 72, 153, 0.4);
    filter: brightness(1.04);
}

.mcp-submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.mcp-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ─── Form Messages ─── */
.mcp-form-message {
    margin-top: 14px;
    padding: 11px 14px;
    border-radius: var(--mcp-radius-sm);
    font-size: 13px;
    font-weight: 500;
    display: none;
    line-height: 1.45;
}

.mcp-form-message.success {
    display: block;
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.mcp-form-message.error {
    display: block;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ─── Loading Spinner ─── */
.mcp-submit-btn .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mcp-spin 0.6s linear infinite;
}
.mcp-submit-btn.loading .spinner {
    display: inline-block;
}
.mcp-submit-btn.loading .btn-text {
    display: none;
}
@keyframes mcp-spin {
    to { transform: rotate(360deg); }
}

/* ─── Responsive ─── */
@media (max-width: 880px) {
    .mcp-calculator-card {
        padding: 32px 24px;
    }
    .mcp-calc-grid {
        gap: 32px;
    }
}

@media (max-width: 768px) {
    .mcp-calculator-wrapper {
        margin: 24px auto;
    }
    .mcp-calc-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }
    .mcp-calculator-card {
        padding: 28px 20px;
        border-radius: var(--mcp-radius-lg);
    }
    .mcp-calc-title {
        font-size: 24px;
        margin-bottom: 24px;
    }
    .mcp-payment-amount {
        font-size: 36px;
    }
    .mcp-tabs {
        grid-template-columns: repeat(3, 1fr);
    }
    .mcp-tab {
        font-size: 12px;
        padding: 9px 6px;
    }
}

@media (max-width: 480px) {
    .mcp-calculator-wrapper {
        padding: 0 12px;
    }
    .mcp-calculator-card {
        padding: 24px 16px;
    }
    .mcp-calc-title {
        font-size: 22px;
    }
    .mcp-payment-amount {
        font-size: 32px;
    }
    .mcp-payment-amount .mcp-currency {
        font-size: 18px;
    }
    .mcp-phone-row {
        grid-template-columns: 110px 1fr;
    }
    .mcp-dial-code {
        padding-left: 12px;
    }
    .mcp-dial-code select {
        font-size: 13px;
        padding-right: 20px;
    }
}
