@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --accent-color: #8b5cf6;
    --success-color: #10b981;
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-lg: 16px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    color: var(--text-color);
    line-height: 1.6;
    padding: 2rem 1rem;
    min-height: 100vh;
}

.container {
    margin: 0 auto;
}



header {
    text-align: center;
    margin-bottom: 2.5rem;
}

h1 {
    font-weight: 800;
    font-size: 2.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.75rem;
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    max-width: 90%;
    margin: 0 auto;
}

/* Card Styling */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    margin-bottom: 2rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

label small {
    display: block;
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

input[type="number"] {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-color);
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.5);
}

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

.btn-secondary {
    width: 100%;
    padding: 0.875rem;
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1.5rem;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: rgba(99, 102, 241, 0.05);
}

.note {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 1.25rem;
}

/* Results Section */
.hidden {
    display: none;
    animation: fadeOut 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

#result-section:not(.hidden) {
    animation: fadeIn 0.5s ease-out forwards;
}

h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Savings Card */
.savings-card {
    text-align: center;
    background: linear-gradient(135deg, #10b981, #059669);
    padding: 2rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
}

.savings-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.savings-value {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.savings-subtitle {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    opacity: 0.95;
}

.savings-interest {
    background: rgba(255, 255, 255, 0.2);
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
}

.savings-interest span {
    font-weight: 800;
    color: #fff;
}

/* Difference Grid */
.difference-grid {
    gap: 1rem;
}

.diff-item {
    text-align: center;
    padding: 1.5rem 1rem;
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.label-group {
    display: flex;
    justify-content: space-between;
}

/* Payment Mode Toggle */
.payment-mode-group {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    /* Removed background/padding to look more native/inline per user request */
}

.mode-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.radio-options {
    display: flex;
    gap: 1.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-color);
    cursor: pointer;
}

.radio-label input[type="radio"] {
    accent-color: var(--primary-color);
    width: 1.1rem;
    height: 1.1rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.diff-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.diff-item .value-date {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.diff-item .value-duration {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.diff-item.highlight .value-date {
    color: #059669;
}

/* Comparison Table */
.comparison-table {
    margin-top: 2rem;
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.comparison-table h3 {
    font-size: 1rem;
    margin: 0;
    padding: 1rem;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    font-weight: 600;
}

.row {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
}

.row:last-child {
    border-bottom: none;
}

.row.header {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.good-text {
    color: var(--success-color);
    font-weight: 700;
}

/* Ad Containers */
.ad-container {
    background-color: var(--bg-color);
    border: 2px dashed #cbd5e1;
    text-align: center;
    padding: 1rem;
    margin-bottom: 2rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    transition: opacity 0.3s ease;
}

.ad-placeholder {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0.6;
}

/* Mobile Tweaks */
@media (max-width: 480px) {
    .container {
        padding: 0 0.5rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .card {
        padding: 1.5rem;
    }
}

/* Visual Timeline */
.timeline-container {
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.timeline-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    gap: 0.35rem;
}

.timeline-label {
    width: 100%;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.2;
    text-align: left;
    padding-left: 4px;
}

.timeline-track {
    width: 100%;
    background-color: #e2e8f0;
    height: 36px;
    border-radius: 50px;
    position: relative;
    /* Overflow removed to show labels */
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.timeline-bar {
    height: 100%;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 14px;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Bouncy spring effect */
    white-space: nowrap;
    position: relative;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.timeline-bar.gray {
    background: linear-gradient(to bottom, #94a3b8, #64748b);
    width: 100%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.timeline-bar.green {
    background: linear-gradient(135deg, #34d399 0%, #059669 100%);
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Glassy Shine Overlay */
.timeline-bar.green::after,
.timeline-bar.gray::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.15), transparent);
    border-radius: 50px 50px 0 0;
    pointer-events: none;
}

.bar-label {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    z-index: 2;
    margin-right: -2px;
    /* Slight offset */
}

/* Ensure text is visible even if bar is small */
.timeline-bar {
    min-width: 0;
}

/* Toggle Switch */
.timeline-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}

.toggle-container {
    display: flex;
    align-items: center;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

.toggle-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
    padding-left: 4px;
}

.toggle-btn {
    border: none;
    background: transparent;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.toggle-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.5);
}

/* Educational Intro Box */
.intro-info {
    max-width: 600px;
    margin: 1.5rem auto 0;
    background-color: #eff6ff;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #dbeafe;
    color: #1e40af;
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: center;
}

.intro-info strong {
    color: #1d4ed8;
    font-weight: 700;
}

/* Welcome State */
.welcome-card {
    text-align: center;
    padding: 3rem 2rem;
    animation: fadeIn 0.5s ease-out;
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

.welcome-card h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--primary-dark);
}

.welcome-card p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 400px;
    margin: 0 auto 2rem;
}

.welcome-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.step-num {
    width: 32px;
    height: 32px;
    background: #e0e7ff;
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.step-line {
    flex: 1;
    height: 2px;
    background: #e2e8f0;
    min-width: 30px;
    margin-top: -24px;
    /* Align with dots */
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.step span {
    display: none;
    /* Hide text on very small screens, keep numbers */
}

/* End of float animation */

/* --- RESPONSIVE AD LAYOUT (Moved to end for specificty) --- */

/* Default (Mobile): Sidebars hidden, Stacked layout */
.ad-sidebar {
    display: none !important;
}

.mobile-ad {
    display: block;
}

.ad-placeholder.vertical {
    height: 600px;
    width: 100%;
    max-width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Desktop: Grid layout with Sidebars */
@media (min-width: 1200px) {
    .app-wrapper {
        display: grid;
        grid-template-columns: 1fr 540px 1fr;
        gap: 2rem;
        max-width: 1440px;
        margin: 0 auto;
        align-items: start;
    }

    .container {
        margin: 0;
        /* Grid handles spacing */
        max-width: 100%;
    }

    .ad-sidebar {
        display: flex !important;
        justify-content: center;
        position: sticky;
        top: 2rem;
        height: fit-content;
    }

    .ad-sidebar.left {
        justify-content: flex-end;
    }

    .ad-sidebar.right {
        justify-content: flex-start;
    }

    /* Hide Top/Bottom inline ads on desktop */
    .mobile-ad {
        display: none;
    }
}

/* UNIVERSAL CARD LAYOUT (Desktop & Mobile) */
.comparison-table {
    border: none;
    background: transparent;
    margin-top: 2rem;
}

.comparison-table h3 {
    display: none;
    /* Hide generic title */
}

.comparison-table .row.header {
    display: none;
    /* Hide header row */
}

.comparison-table .row {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    gap: 0.75rem;
    transition: transform 0.2s ease;
}

.comparison-table .row:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.comparison-table .row:last-child {
    border-bottom: 1px solid var(--border-color);
}

/* Metric Title (e.g. Total Interest) */
.comparison-table .row span:nth-child(1) {
    text-align: left;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary-color);
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
}

/* Data Values (Row Items) */
.comparison-table .row span:nth-child(2),
.comparison-table .row span:nth-child(3),
.comparison-table .row span:nth-child(4) {
    text-align: right !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Pseudo Labels */
.comparison-table .row span:nth-child(2)::before {
    content: "Current EMI:";
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.95rem;
}

.comparison-table .row span:nth-child(3)::before {
    content: "With Part Pay:";
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.95rem;
}

.comparison-table .row span:nth-child(4)::before {
    content: "You Save:";
    color: var(--success-color);
    font-weight: 700;
    font-size: 0.95rem;
}