:root {
    --primary: #10b981; /* Premium Emerald */
    --primary-light: #ecfdf5;
    --primary-dark: #059669;
    --accent: #34d399; /* Soft emerald for gradients */
    --background: #ffffff; /* White to match logo */
    --surface: #ffffff;
    --text: #334155; /* Slate text */
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.05); /* Premium soft shadow */
    --glass-bg: rgba(255, 255, 255, 0.85); /* Proper glassmorphism */
    --glass-border: rgba(255, 255, 255, 0.4);
    --card-radius: 1rem; /* More rounded premium look */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --primary: #34d399; /* Bright emerald for dark mode */
    --primary-light: rgba(16, 185, 129, 0.15);
    --primary-dark: #059669;
    --accent: #6ee7b7; 
    --background: #000000; /* Pure black */
    --surface: #121212; /* Very dark gray */
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #2a2a2a;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    --glass-bg: rgba(18, 18, 18, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    transition: background-color var(--transition), color var(--transition);
}

[data-theme="dark"] body {
    background: var(--background);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text);
}

.text-primary { color: var(--primary); }
.text-error { color: var(--error); }
.text-success { color: var(--success); }
.text-muted { color: var(--text-muted); }

/* Utility Classes */
.hidden {
    display: none !important;
}
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1 1 0%; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }

/* Layout & Containers */
.container {
    max-width: 95%;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.app-title {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

/* Setup Container (Page 1) */
.setup-container {
    max-width: 700px;
    margin: 4rem auto;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 3rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

.setup-container h2 {
    font-size: 1.75rem;
    text-align: center;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    transition: var(--transition);
}

/* Stepper Progress */
.stepper-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    position: relative;
}

.stepper-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border);
    transform: translateY(-50%);
    z-index: 0;
    border-radius: 2px;
}

#progress-bar {
    position: absolute;
    top: 50%;
    left: 0;
    height: 4px;
    background: var(--primary);
    transform: translateY(-50%);
    z-index: 1;
    transition: width 0.5s ease;
    border-radius: 2px;
}

.step-indicator {
    position: relative;
    z-index: 2;
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--text-muted);
    transition: var(--transition);
}

.step-indicator.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.step-indicator.completed {
    border-color: var(--success);
    background: var(--success);
    color: white;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.col-span-2 {
    grid-column: span 2;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Radio Cards (for Yes/No choices) */
.radio-group {
    display: flex;
    gap: 1rem;
}

.radio-card {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.radio-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-card-content {
    display: block;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-align: center;
    font-weight: 500;
    transition: var(--transition);
    background: var(--surface);
}

.radio-card input[type="radio"]:checked + .radio-card-content {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    /* In dark mode, primary-light might be too dark for text, adjust if needed */
}
[data-theme="dark"] .radio-card input[type="radio"]:checked + .radio-card-content {
    color: white;
}


/* Validation Errors */
.error-msg {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    display: none;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--background);
    border-color: var(--text-muted);
}

.btn-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

/* Premium Card */
.premium-card {
    text-align: center;
    padding: 3rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border-radius: var(--card-radius);
    margin-bottom: 2rem;
    box-shadow: 0 20px 25px -5px rgba(76, 175, 80, 0.2);
}

.premium-amount {
    font-size: 4rem;
    font-weight: 700;
    margin: 1rem 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Table */
.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.breakdown-table th,
.breakdown-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.breakdown-table th {
    background: rgba(0,0,0,0.02);
    font-weight: 600;
}
[data-theme="dark"] .breakdown-table th {
    background: rgba(255,255,255,0.02);
}

/* Utilities */
.hidden { display: none !important; }
.text-right { text-align: right; }
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.slide-in {
    opacity: 0;
    animation: slideInUp 0.5s ease forwards;
}

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

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

.pulse {
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Theme Toggle */
.theme-switch-wrapper {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
}

.theme-switch {
    display: inline-block;
    height: 30px;
    position: relative;
    width: 50px;
}

.theme-switch input {
    display: none;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    background-color: white;
    bottom: 4px;
    content: "";
    height: 22px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 22px;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }
    .glass-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    .btn-actions, .theme-switch-wrapper, .stepper-container, header p {
        display: none !important;
    }
    .premium-card {
        background: #f8fafc !important; /* Force light bg for printing */
        color: black !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        border: 2px solid #0ea5e9;
    }
    .premium-amount {
        color: #1a56db;
    }
}

/* Help Button & Modal */
.help-circle-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 5;
}

.help-circle-btn:hover {
    background-color: var(--primary);
    color: white;
    transform: scale(1.05);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: var(--transition);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    background-color: var(--surface);
    color: var(--text);
    padding: 1.75rem;
    border-radius: var(--card-radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    position: relative;
    border: 1px solid var(--border);
    animation: modalFadeIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.35rem;
    color: var(--primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    line-height: 1;
}

.close-btn:hover {
    color: var(--error);
}

.help-section {
    margin-bottom: 1.25rem;
}

.help-section h4 {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.help-section p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .col-span-2 {
        grid-column: span 1;
    }
    .container {
        padding: 1rem 0.75rem;
    }
    .glass-card {
        padding: 1.25rem 1rem;
    }
    .theme-switch-wrapper {
        position: relative;
        top: auto;
        right: auto;
        transform: none;
        margin-top: 1rem;
        justify-content: center;
    }
    header {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 1.5rem;
    }
    .app-title {
        font-size: 1.85rem;
        margin-bottom: 0.25rem;
    }
    header p {
        font-size: 0.9rem;
    }
    .checkbox-align {
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }
    .btn-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    .btn-actions > div {
        width: 100%;
        flex-direction: column;
        gap: 0.75rem;
    }
    .btn-actions button {
        width: 100%;
    }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-logo-wrapper { margin-bottom: 0.5rem; }
.app-logo { max-height: 48px; width: auto; }
.logo-dark { display: none; }
[data-theme='dark'] .logo-light { display: none; }
[data-theme='dark'] .logo-dark { display: block; }

.app-logo-wrapper { display: flex; justify-content: center; margin-bottom: 0.5rem; }
.top-actions { position: absolute; top: 1.5rem; right: 1.5rem; display: flex; align-items: center; gap: 1.5rem; }
.whatsapp-chat-btn { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: #25D366; font-weight: 600; font-size: 0.9rem; background: rgba(37, 211, 102, 0.1); padding: 0.4rem 0.8rem; border-radius: 20px; transition: background 0.3s; }
.theme-switch-wrapper { position: static; transform: none; top: auto; right: auto; margin: 0; display: flex; align-items: center; }
@media (max-width: 768px) {
  .top-actions { position: static; justify-content: center; margin-top: 1rem; flex-wrap: wrap; gap: 1rem; }
  header { padding-top: 1rem; }
}

[data-theme='dark'] .logo-dark { display: block; max-height: 72px !important; margin: -12px 0; }

.emi-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.final-premium-cell { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
@media (max-width: 768px) {
  .emi-options-grid { grid-template-columns: 1fr; }
  .final-premium-cell { flex-direction: column; align-items: flex-end; gap: 0.5rem; }
}
