/* ================================================================
   Off-Plan Payment Plan Calculator – Premium Dark Theme
   ================================================================ */

:root {
    --bg-base: #18130c;
    --bg-surface: #1e1810;
    --bg-card: #261f14;
    --bg-card2: #2e2618;
    --bg-hover: #362d1d;
    --border: #423624;
    --border-light: #4e412b;

    --gold: #ad8152;
    --gold-light: #c29566;
    --gold-dim: #9a7147;
    --green: #3dca7c;
    --green-dim: #256843;
    --red: #e05656;
    --red-dim: #7a2a2a;
    --blue: #4a90d9;
    --blue-dim: #2a527a;
    --purple: #9b6dff;

    --text-primary: #e8eaf0;
    --text-second: #8fa3c0;
    --text-dim: #4d6080;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;

    --shadow: 0 4px 24px rgba(0, 0, 0, .45);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    --transition: all .18s ease;
}

.offplan-calc *,
.offplan-calc *::before,
.offplan-calc *::after { box-sizing: border-box; }

.offplan-calc {
    font-family: 'Jost', sans-serif;
    color: var(--text-primary);
    background: var(--bg-base);
    padding: 50px 24px 40px;
    min-height: 100vh;
}

.offplan-layout {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.offplan-col { display: flex; flex-direction: column; gap: 20px; }

/* ── DISCLAIMER ─────────────────────────────────────────────────── */
.offplan-disclaimer {
    max-width: 1200px;
    margin: 0 auto 20px;
    background: rgba(201,168,76,0.08);
    border: 1px solid var(--gold-dim);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: .78rem;
    color: var(--text-second);
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

/* ── CARD ───────────────────────────────────────────────────────── */
.offplan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.offplan-card h3 {
    margin: 0 0 16px;
    font-size: .95rem;
    font-weight: 600;
    color: var(--gold-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── FORM ───────────────────────────────────────────────────────── */
.offplan-field {
    margin-bottom: 14px;
}

.offplan-field label {
    display: block;
    font-size: .78rem;
    color: var(--text-second);
    margin-bottom: 5px;
    font-weight: 500;
}

.offplan-field input,
.offplan-field select,
.offplan-field textarea {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: .88rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.offplan-field input:focus,
.offplan-field select:focus,
.offplan-field textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(173,129,82,0.15);
}

.offplan-field textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.offplan-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.offplan-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

/* ── MODE TABS ──────────────────────────────────────────────────── */
.offplan-mode-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
}

.offplan-mode-tab {
    flex: 1;
    padding: 14px 16px;
    background: var(--bg-card);
    color: var(--text-second);
    border: none;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.offplan-mode-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.offplan-mode-tab.active {
    color: var(--gold-light);
    background: var(--bg-card);
}

.offplan-mode-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gold);
}

.offplan-mode-tab:first-child { border-radius: var(--radius) 0 0 0; }
.offplan-mode-tab:last-child { border-radius: 0 var(--radius) 0 0; }

/* ── AI PARSE BOX ───────────────────────────────────────────────── */
.ai-parse-box {
    background: linear-gradient(135deg, rgba(155,109,255,0.08), rgba(74,144,217,0.06));
    border: 1px dashed var(--purple);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.ai-parse-box h4 {
    margin: 0 0 10px;
    font-size: .88rem;
    color: var(--purple);
    font-weight: 600;
}

.ai-parse-box .ai-note {
    font-size: .72rem;
    color: var(--text-dim);
    margin-top: 8px;
    line-height: 1.5;
}

.ai-parse-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: var(--purple);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 10px;
}

.ai-parse-btn:hover { opacity: .85; }
.ai-parse-btn:disabled { opacity: .4; cursor: not-allowed; }

.ai-parse-btn .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: none;
}

.ai-parse-btn.loading .spinner { display: inline-block; }
.ai-parse-btn.loading .btn-text { display: none; }

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

.ai-key-field {
    margin-top: 10px;
}

.ai-key-field input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 10px;
    font-size: .78rem;
    font-family: monospace;
    outline: none;
}

.ai-key-field input:focus {
    border-color: var(--purple);
}

/* ── MILESTONE LIST ─────────────────────────────────────────────── */
.milestone-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.milestone-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1.2fr auto;
    gap: 8px;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: .82rem;
}

.milestone-item input {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 6px 8px;
    font-size: .82rem;
    font-family: inherit;
    outline: none;
    width: 100%;
}

.milestone-item input:focus {
    border-color: var(--gold);
}

.milestone-remove {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.milestone-remove:hover { background: var(--red-dim); }

.milestone-add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(173,129,82,0.15);
    color: var(--gold-light);
    border: 1px dashed var(--gold-dim);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .82rem;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.milestone-add:hover { background: rgba(173,129,82,0.25); }

.milestone-pct-bar {
    height: 6px;
    background: var(--bg-surface);
    border-radius: 3px;
    margin-top: 12px;
    overflow: hidden;
    display: flex;
}

.milestone-pct-bar .seg {
    height: 100%;
    transition: width 0.3s ease;
}

.milestone-pct-label {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ── TIMELINE ───────────────────────────────────────────────────── */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding: 12px 0 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 16px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--bg-card);
}

.timeline-item.paid::before { background: var(--green); }
.timeline-item.upcoming::before { background: var(--blue); }

.timeline-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.timeline-date {
    font-size: .75rem;
    color: var(--text-second);
}

.timeline-amount {
    font-size: .95rem;
    font-weight: 700;
    color: var(--gold-light);
    margin-top: 4px;
}

/* ── SUMMARY TABLE ──────────────────────────────────────────────── */
.offplan-summary {
    width: 100%;
    font-size: .84rem;
    border-collapse: collapse;
}

.offplan-summary tr { border-bottom: 1px solid var(--border); }
.offplan-summary tr:last-child { border-bottom: none; }

.offplan-summary td {
    padding: 10px 4px;
    color: var(--text-second);
}

.offplan-summary td:last-child {
    text-align: right;
    color: var(--text-primary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.offplan-summary .total-row td {
    color: var(--gold-light);
    font-weight: 700;
    border-top: 2px solid var(--gold-dim);
    padding-top: 14px;
    font-size: .95rem;
}

/* ── KPI GRID ───────────────────────────────────────────────────── */
.offplan-kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.offplan-kpi {
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.offplan-kpi .kpi-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold-light);
    margin-bottom: 2px;
}

.offplan-kpi .kpi-label {
    font-size: .68rem;
    color: var(--text-second);
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ── CHART ──────────────────────────────────────────────────────── */
.offplan-chart-wrap {
    position: relative;
    width: 100%;
    height: 280px;
}

.offplan-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── CTA ────────────────────────────────────────────────────────── */
.offplan-cta {
    background: linear-gradient(135deg, rgba(173,129,82,0.15), rgba(173,129,82,0.05));
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.offplan-cta p {
    margin: 0 0 12px;
    font-size: .88rem;
    color: var(--text-second);
}

.offplan-cta a {
    display: inline-block;
    background: var(--gold);
    color: #fff;
    padding: 10px 28px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: .88rem;
    transition: var(--transition);
}

.offplan-cta a:hover {
    background: var(--gold-light);
    transform: translateY(-1px);
}

/* ── RESPONSIVE ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .offplan-layout { grid-template-columns: 1fr; }
    .offplan-calc { padding: 40px 14px 30px; }
}

@media (max-width: 540px) {
    .offplan-row, .offplan-row-3 { grid-template-columns: 1fr; }
    .offplan-kpi-grid { grid-template-columns: 1fr 1fr; }
    .milestone-item { grid-template-columns: 1fr; gap: 6px; }
}
