/* ═══════════════════════════════════════════
   rd.css — RD Calculator specific styles
   Requires: calc-global.css
   ─────────────────────────────────────────
   SECTIONS:
   [CSS0]  CSS variables — RD colour palette
   [CSS1]  Colour utilities
   [CSS2]  Bank / rate chip grid
   [CSS3]  Tenure pill toggle
   [CSS4]  Effective rate note
   [CSS5]  TDS safe box
   [CSS6]  Hero TDS banner
   [CSS7]  Empty field prompt
   [CSS8]  4 unique stat cards
   [CSS9]  Donut tooltip
   [CSS10] Line chart legend
   [CSS11] Layout-shift prevention
   [CSS12] Responsive
═══════════════════════════════════════════ */


/* ═══════════════════════════════════════════
   [CSS0]  RD CSS VARIABLES
═══════════════════════════════════════════ */

:root {
    --rd-blue:       #1D4ED8;
    --rd-blue-soft:  #DBEAFE;
    --rd-amber:      #F59E0B;
    --rd-amber-soft: #FEF3C7;
}


/* ═══════════════════════════════════════════
   [CSS1]  COLOUR UTILITIES
═══════════════════════════════════════════ */

.c-blue  { color: var(--rd-blue); }
.c-amber { color: var(--rd-amber); }
.c-red   { color: var(--danger); }


/* ═══════════════════════════════════════════
   [CSS2]  BANK / RATE CHIP GRID
═══════════════════════════════════════════ */

.bank-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: .9rem;
}

.bank-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: .26rem .75rem;
    border-radius: 30px;
    border: 1.5px solid var(--slate-line);
    background: var(--white);
    font-size: .73rem;
    font-weight: 600;
    color: var(--slate);
    cursor: pointer;
    transition: all .18s var(--ease);
    user-select: none;
}
.bank-chip:hover {
    border-color: var(--rd-blue);
    color: var(--rd-blue);
}
.bank-chip.active {
    background: var(--rd-blue-soft);
    border-color: var(--rd-blue);
    color: #1e40af;
}
.bank-chip .chip-rate {
    font-size: .68rem;
    color: var(--emerald);
    font-weight: 700;
}


/* ═══════════════════════════════════════════
   [CSS3]  TENURE PILL TOGGLE
═══════════════════════════════════════════ */

.tenure-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    flex-wrap: wrap;
    gap: 8px;
}

.tenure-pill {
    display: flex;
    gap: 4px;
    background: var(--slate-light);
    border-radius: 20px;
    padding: 3px;
}

.tp-opt {
    padding: .18rem .6rem;
    border-radius: 16px;
    border: none;
    background: transparent;
    font-size: .7rem;
    font-weight: 600;
    color: var(--slate);
    cursor: pointer;
    transition: all .15s;
}
.tp-opt.active {
    background: var(--white);
    color: var(--navy);
    box-shadow: 0 1px 4px rgba(13,37,69,.12);
}
.tp-opt:hover:not(.active) { color: var(--navy); }


/* ═══════════════════════════════════════════
   [CSS4]  EFFECTIVE RATE NOTE
═══════════════════════════════════════════ */

.eff-rate-note {
    margin-top: 6px;
    background: var(--amber-soft);
    border: 1px solid #FDE68A;
    border-radius: 8px;
    padding: .35rem .7rem;
    font-size: .69rem;
    color: #92400E;
    font-weight: 500;
    display: none;
}
.eff-rate-note.show { display: block; }


/* ═══════════════════════════════════════════
   [CSS5]  TDS SAFE BOX
═══════════════════════════════════════════ */

.tds-safe-box {
    background: var(--emerald-soft);
    border: 1.5px solid #6EE7B7;
    border-radius: var(--r-md);
    padding: .75rem 1rem;
    margin-bottom: 1.2rem;
    display: none;
    font-size: .77rem;
    color: #065f46;
    font-weight: 500;
    align-items: center;
    gap: .5rem;
}
.tds-safe-box.show { display: flex; }
.tds-safe-box i    { color: var(--emerald); font-size: .9rem; flex-shrink: 0; }


/* ═══════════════════════════════════════════
   [CSS6]  HERO TDS BANNER
═══════════════════════════════════════════ */

.hero-tds-banner {
    margin-top: 10px;
    background: rgba(220, 38, 38, .1);
    border: 1px solid rgba(220, 38, 38, .22);
    border-radius: 12px;
    padding: .55rem .85rem;
    display: none;
    align-items: center;
    gap: 8px;
    font-size: .78rem;
    font-weight: 600;
}
.hero-tds-banner.show { display: flex; }
.hero-tds-banner i    { color: #FCA5A5; }

.tds-amt {
    color: #FCA5A5;
    font-family: var(--font-mono);
    font-weight: 700;
}


/* ═══════════════════════════════════════════
   [CSS7]  EMPTY FIELD PROMPT
═══════════════════════════════════════════ */

.field-empty-prompt {
    font-size: .7rem;
    color: var(--danger);
    margin-top: 5px;
    display: none;
    align-items: center;
    gap: 4px;
    background: var(--danger-soft);
    border: 1px solid #FECACA;
    border-radius: 8px;
    padding: .3rem .6rem;
}
.field-empty-prompt.show { display: flex; }


/* ═══════════════════════════════════════════
   [CSS8]  4 UNIQUE STAT CARDS
   Replace the standard result-grid with
   card-based layout unique to RD.
═══════════════════════════════════════════ */

.rd-stat-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1.2rem;
}

.rd-stat-card {
    border-radius: 14px;
    padding: .9rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    border: 1.5px solid transparent;
    transition: transform .15s var(--ease), box-shadow .15s;
    position: relative;
    overflow: hidden;
}
.rd-stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: .04;
    border-radius: inherit;
    pointer-events: none;
}
.rd-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13,37,69,.09);
}

/* Card 1: Invested — blue */
.rd-stat-card.card-invested {
    background: var(--rd-blue-soft);
    border-color: #bfdbfe;
}
.rd-stat-card.card-invested::before { background: var(--rd-blue); }
.rd-stat-card.card-invested .rsc-icon { color: var(--rd-blue); background: #dbeafe; }
.rd-stat-card.card-invested .rsc-value { color: var(--rd-blue); }

/* Card 2: Interest — amber */
.rd-stat-card.card-interest {
    background: var(--rd-amber-soft);
    border-color: #fde68a;
}
.rd-stat-card.card-interest::before { background: var(--rd-amber); }
.rd-stat-card.card-interest .rsc-icon { color: #b45309; background: #fef3c7; }
.rd-stat-card.card-interest .rsc-value { color: #b45309; }

/* Card 3: TDS — red (dynamic via JS: green when no TDS) */
.rd-stat-card.card-tds {
    background: #fff1f2;
    border-color: #fecdd3;
}
.rd-stat-card.card-tds .rsc-icon { color: #be123c; background: #ffe4e6; }

/* Card 4: Net — emerald */
.rd-stat-card.card-net {
    background: var(--emerald-soft);
    border-color: #6ee7b7;
}
.rd-stat-card.card-net .rsc-icon { color: #065f46; background: #d1fae5; }
.rd-stat-card.card-net .rsc-value { color: #065f46; }

.rsc-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}

.rsc-body { flex: 1; min-width: 0; }

.rsc-label {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--slate);
    margin-bottom: 3px;
}

.rsc-value {
    font-size: 1.05rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--navy);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rsc-sub {
    font-size: .67rem;
    color: var(--slate);
    margin-top: 2px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ═══════════════════════════════════════════
   [CSS9]  DONUT TOOLTIP
═══════════════════════════════════════════ */

#rdDonutTip {
    position: absolute;
    bottom: 105%;
    left: 50%;
    transform: translateX(-50%);
    background: #0D2545;
    border-radius: 16px;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity .18s;
    z-index: 20;
    width: 192px;
    box-shadow: 0 20px 40px rgba(13,37,69,.35), 0 4px 12px rgba(13,37,69,.2);
}

.donut-arc {
    transition: opacity .18s, stroke-width .15s;
    fill: none;
    stroke-width: 16px;
}

.dl-item.dl-active .dl-txt,
.dl-item.dl-active .dl-val { color: var(--navy); font-weight: 700; }
.dl-item.dl-dim { opacity: .4; }


/* ═══════════════════════════════════════════
   [CSS10] LINE CHART LEGEND
═══════════════════════════════════════════ */

.chart-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--slate-line);
}

.cl-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    color: var(--slate);
    font-weight: 500;
}

.cl-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}


/* ═══════════════════════════════════════════
   [CSS11] LAYOUT-SHIFT PREVENTION
═══════════════════════════════════════════ */

.inputs-sticky {
    contain: layout;
}

.insights-body {
    contain: layout;
}

.yr-chart-wrap {
    min-height: 320px;
    position: relative;
}

#yrBars {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 260px;
    box-sizing: border-box;
    position: relative;
}

#vSummary {
    min-height: 360px;
}

#insightList {
    transition: min-height .2s ease;
}

@media (min-width: 768px) {
    .insights-body { overflow: visible; }
    #insightList {
        min-height: 200px;
        max-height: 420px;
        overflow-y: auto;
        overflow-x: hidden;
        scroll-behavior: smooth;
    }
}


/* ═══════════════════════════════════════════
   [CSS12] RESPONSIVE
═══════════════════════════════════════════ */

@media (max-width: 700px) {
    .rd-stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
    .rsc-value { font-size: .9rem; }
    .tenure-hd { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .rd-stat-cards { grid-template-columns: 1fr 1fr; gap: 6px; }
    .rd-stat-card { padding: .7rem .75rem; }
    .bank-grid { gap: 5px; }
    .bank-chip { font-size: .68rem; padding: .22rem .6rem; }
    .rsc-icon { width: 28px; height: 28px; font-size: .8rem; }
    .rsc-value { font-size: .82rem; }
    .rsc-sub { font-size: .62rem; }
}