/* ═══════════════════════════════════════════════════════════════
   InterestCalc Pro – Main Stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy:     #1e3a5f;
    --navy-dk:  #152d4a;
    --blue:     #2980b9;
    --blue-lt:  #3498db;
    --teal:     #1abc9c;
    --green:    #27ae60;
    --red:      #e74c3c;
    --orange:   #e67e22;
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;
    --white:    #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow:    0 4px 12px rgba(0,0,0,.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
    --radius:    10px;
    --radius-sm: 6px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Logo ───────────────────────────────────────────────────────── */
.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: .4rem;
    text-decoration: none !important;
}
.logo-icon {
    font-size: 1.6rem;
    color: var(--teal);
}

/* ══════════════════ APP HEADER ════════════════════════════════════ */
.app-header {
    background: var(--navy);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}
.main-nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    flex: 1;
}
.nav-link {
    color: rgba(255,255,255,.8);
    font-size: .875rem;
    font-weight: 500;
    padding: .4rem .75rem;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.1); color: var(--white); text-decoration: none; }
.nav-link--cta { background: var(--teal); color: var(--white) !important; }
.nav-link--cta:hover { background: #16a085; }
.nav-link--logout { color: rgba(255,255,255,.5); }

.header-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-left: auto;
}
.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.3);
}
.user-avatar--initials {
    background: var(--teal);
    color: var(--white);
    font-weight: 700;
    font-size: .85rem;
    display: flex; align-items: center; justify-content: center;
}
.user-name { color: rgba(255,255,255,.85); font-size: .875rem; }

.badge {
    font-size: .65rem;
    padding: .1rem .4rem;
    border-radius: 99px;
    font-weight: 700;
    letter-spacing: .03em;
}
.badge--free { background: var(--gray-300); color: var(--gray-700); }
.badge--pro  { background: var(--teal); color: var(--white); }

/* ══════════════════ MAIN CONTENT ══════════════════════════════════ */
.main-content { flex: 1; }

.page-wrap {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}
.page-title    { font-size: 1.75rem; font-weight: 700; color: var(--navy); }
.page-subtitle { color: var(--gray-500); margin-top: .25rem; }

/* ── Card ───────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
}
.card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; color: var(--navy); }

/* ══════════════════ BUTTONS ═══════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all .15s;
    line-height: 1.4;
    text-decoration: none !important;
    white-space: nowrap;
}
.btn--primary  { background: var(--blue); color: var(--white); border-color: var(--blue); }
.btn--primary:hover  { background: var(--navy); border-color: var(--navy); }
.btn--outline  { background: transparent; color: var(--blue); border-color: var(--blue); }
.btn--outline:hover  { background: var(--blue); color: var(--white); }
.btn--danger   { background: var(--red); color: var(--white); border-color: var(--red); }
.btn--danger:hover   { background: #c0392b; }
.btn--ghost    { background: transparent; color: var(--white); border-color: rgba(255,255,255,.4); }
.btn--ghost:hover    { background: rgba(255,255,255,.1); }
.btn--full     { width: 100%; }
.btn--lg       { padding: .7rem 2rem; font-size: 1rem; }
.btn--sm       { padding: .3rem .75rem; font-size: .8rem; }
.btn--calc     { margin-top: 1rem; padding: .65rem 2.5rem; font-size: 1rem; }
.btn--disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn--google {
    background: var(--white);
    color: var(--gray-700);
    border-color: var(--gray-300);
    font-weight: 600;
}
.btn--google:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-900); }

/* ══════════════════ FORMS ═════════════════════════════════════════ */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: .825rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: .35rem;
}
.form-group label small { font-weight: 400; color: var(--gray-500); }

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: .55rem .85rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    color: var(--gray-900);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
    appearance: auto;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(41,128,185,.15);
}
.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .875rem; }
input[type="checkbox"] { width: auto; margin: 0; }

.form-group-label {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-500);
    margin-bottom: .5rem;
    margin-top: .5rem;
}

/* ── Dynamic rows (rate schedule, installments, tax) ──────────────── */
.rate-row, .install-row, .tax-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}
.rate-row input, .install-row input, .tax-row input {
    flex: 1;
}

/* ══════════════════ ALERTS ════════════════════════════════════════ */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: 1rem;
    border: 1px solid;
}
.alert--error   { background: #fff5f5; color: #c0392b; border-color: #f5c6cb; }
.alert--success { background: #f0fff4; color: #155724; border-color: #c3e6cb; }

/* ══════════════════ BANNERS ═══════════════════════════════════════ */
.banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: 1rem;
}
.banner--upgrade { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }

/* ══════════════════ AUTH PAGES ════════════════════════════════════ */
.auth-body {
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}
.auth-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--navy);
    margin-bottom: 1.5rem;
}
.auth-logo .logo-icon { color: var(--teal); font-size: 1.8rem; }
.auth-title { font-size: 1.35rem; font-weight: 700; color: var(--gray-900); margin-bottom: 1.25rem; text-align: center; }
.auth-divider {
    text-align: center;
    margin: 1.25rem 0;
    position: relative;
    color: var(--gray-500);
    font-size: .8rem;
}
.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%; left: 0; right: 0;
    height: 1px;
    background: var(--gray-200);
}
.auth-divider span {
    background: var(--white);
    padding: 0 .75rem;
    position: relative;
}
.auth-footer { text-align: center; font-size: .875rem; color: var(--gray-500); margin-top: 1.25rem; }

/* ══════════════════ DASHBOARD ═════════════════════════════════════ */
.dashboard-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}
.dashboard-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.dash-toolbar {
    display: flex;
    gap: .75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.search-input { flex: 1; min-width: 200px; max-width: 400px; }
.select-input { width: auto; }

.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}
.calc-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, border-color .15s;
}
.calc-card:hover { box-shadow: var(--shadow); border-color: var(--blue); }
.calc-card-icon { font-size: 2rem; flex-shrink: 0; }
.calc-card-body { flex: 1; min-width: 0; }
.calc-card-type { font-size: .75rem; font-weight: 600; color: var(--blue); text-transform: uppercase; letter-spacing: .05em; }
.calc-card-name { font-weight: 600; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calc-card-date { font-size: .78rem; color: var(--gray-500); }
.calc-card-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.calc-loading { grid-column: 1/-1; text-align: center; color: var(--gray-500); padding: 2rem; }
.empty-state { grid-column: 1/-1; text-align: center; padding: 4rem 2rem; color: var(--gray-500); }
.empty-icon  { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { margin-bottom: 1.25rem; }

/* ══════════════════ CALCULATOR LAYOUT ═════════════════════════════ */
.calc-layout {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 64px);
}

/* Sidebar */
.calc-sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--navy);
    padding: 1.25rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.sidebar-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.4);
    padding: .4rem .75rem;
    margin-bottom: .25rem;
}
.sidebar-btn {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .55rem .75rem;
    background: transparent;
    border: none;
    color: rgba(255,255,255,.75);
    font-size: .825rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}
.sidebar-btn:hover { background: rgba(255,255,255,.1); color: var(--white); }
.sidebar-btn.active { background: var(--teal); color: var(--white); font-weight: 700; }
.sidebar-icon { font-size: 1.1rem; width: 1.4rem; text-align: center; }

/* Main calc area */
.calc-main {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
}
.calc-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.calc-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--navy);
}
.calc-header-actions { display: flex; gap: .5rem; }

.calc-form { max-width: 760px; }
.calc-form.hidden { display: none !important; }

/* ══════════════════ RESULTS ═══════════════════════════════════════ */
.results-divider { border: none; border-top: 2px solid var(--gray-200); margin: 2rem 0 1.5rem; }
.results-title   { font-size: 1.2rem; font-weight: 700; color: var(--navy); margin-bottom: 1rem; }

.summary-cards {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.summary-card {
    background: var(--navy);
    color: var(--white);
    border-radius: var(--radius-sm);
    padding: .85rem 1.25rem;
    min-width: 150px;
}
.sc-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.55);
    margin-bottom: .25rem;
    font-weight: 600;
}
.sc-val {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Data table */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.data-table th {
    background: var(--navy);
    color: var(--white);
    padding: .6rem .9rem;
    text-align: left;
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
.data-table td {
    padding: .55rem .9rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:nth-child(even) td { background: var(--gray-50); }
.data-table tbody tr:hover td { background: #eef4fb; }

/* ══════════════════ SAVE MODAL ════════════════════════════════════ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}
.modal h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--navy); }
.modal-actions { display: flex; gap: .75rem; margin-top: 1.25rem; }
#save-msg { margin-top: .75rem; font-size: .875rem; }

/* ══════════════════ LANDING PAGE ══════════════════════════════════ */
.landing-body { background: var(--white); }

.landing-header {
    background: var(--navy);
    padding: 1rem 1.5rem;
}
.landing-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.landing-header nav { display: flex; gap: .75rem; align-items: center; }

.hero {
    background: linear-gradient(135deg, var(--navy-dk) 0%, var(--navy) 50%, #1a5276 100%);
    padding: 5rem 1.5rem;
    text-align: center;
}
.hero-inner { max-width: 720px; margin: 0 auto; }
.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    color: var(--white);
    line-height: 1.2;
    margin-bottom: 1.25rem;
}
.hero h1 span { color: var(--teal); }
.hero p { font-size: 1.125rem; color: rgba(255,255,255,.8); margin-bottom: 2rem; }
.hero .btn { margin: .25rem .4rem; }

.features { padding: 4rem 1.5rem; background: var(--gray-50); }
.features-inner { max-width: 1100px; margin: 0 auto; }
.features h2 { text-align: center; font-size: 1.75rem; font-weight: 800; color: var(--navy); margin-bottom: 2.5rem; }
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}
.feature-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem 1.25rem;
    text-align: center;
    transition: box-shadow .15s;
}
.feature-card:hover { box-shadow: var(--shadow); }
.feature-icon { font-size: 2rem; margin-bottom: .75rem; }
.feature-card h3 { font-size: .95rem; font-weight: 700; color: var(--navy); margin-bottom: .5rem; }
.feature-card p  { font-size: .825rem; color: var(--gray-500); }

.pricing { padding: 4rem 1.5rem; background: var(--white); }
.pricing-inner { max-width: 900px; margin: 0 auto; }
.pricing h2 { text-align: center; font-size: 1.75rem; font-weight: 800; color: var(--navy); margin-bottom: 2.5rem; }
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    align-items: start;
}
.pricing-card {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    background: var(--white);
    position: relative;
}
.pricing-card--featured {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(41,128,185,.12);
}
.pricing-card--current { border-color: var(--teal); }
.plan-badge {
    position: absolute;
    top: -13px; left: 50%;
    transform: translateX(-50%);
    background: var(--blue);
    color: var(--white);
    font-size: .7rem;
    font-weight: 700;
    padding: .2rem .9rem;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}
.plan-name  { font-size: 1rem; font-weight: 700; color: var(--navy); margin-bottom: .4rem; }
.plan-price { font-size: 2.5rem; font-weight: 800; color: var(--navy); margin-bottom: 1.25rem; line-height: 1.1; }
.plan-price span { font-size: 1rem; font-weight: 400; color: var(--gray-500); }
.pricing-card ul { list-style: none; margin-bottom: 1.5rem; }
.pricing-card ul li {
    font-size: .875rem;
    color: var(--gray-700);
    padding: .3rem 0;
    border-bottom: 1px solid var(--gray-100);
    padding-left: 1.2rem;
    position: relative;
}
.pricing-card ul li::before { content: '✓'; position: absolute; left: 0; color: var(--teal); font-weight: 700; }

.landing-footer {
    background: var(--navy);
    color: rgba(255,255,255,.5);
    text-align: center;
    padding: 1.25rem;
    font-size: .825rem;
}

/* ══════════════════ SETTINGS ══════════════════════════════════════ */
/* (uses .page-wrap and .card already defined) */

/* ══════════════════ APP FOOTER ════════════════════════════════════ */
.app-footer {
    background: var(--navy);
    padding: .85rem 1.5rem;
    margin-top: auto;
}
.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    font-size: .78rem;
    color: rgba(255,255,255,.4);
    flex-wrap: wrap;
    gap: .5rem;
}

/* ══════════════════ PRINT STYLES ══════════════════════════════════ */
@media print {
    .app-header, .calc-sidebar, .calc-header-actions,
    .btn--calc, .btn--save, #btn-save, #btn-print,
    .modal-backdrop, .app-footer { display: none !important; }
    .calc-layout { display: block; }
    .calc-main { padding: 0; }
    .summary-card { background: var(--navy) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .data-table th { background: var(--navy) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ══════════════════ RESPONSIVE ════════════════════════════════════ */
@media (max-width: 900px) {
    .calc-layout { flex-direction: column; }
    .calc-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: .75rem; gap: .25rem; }
    .sidebar-title { display: none; }
    .sidebar-btn { flex: 0 0 auto; padding: .35rem .65rem; font-size: .75rem; }
    .sidebar-icon { display: none; }
    .calc-main { padding: 1.25rem; }
    .form-row { grid-template-columns: 1fr; }
    .header-inner { flex-wrap: wrap; }
    .main-nav { order: 3; width: 100%; }
}
@media (max-width: 600px) {
    .dashboard-top { flex-direction: column; }
    .calc-grid { grid-template-columns: 1fr; }
    .summary-cards { flex-direction: column; }
    .summary-card { min-width: unset; }
    .pricing-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 1.75rem 1.25rem; }
}
