/* ============================================
   NUCHAL TRANSLUCENCY CALCULATOR - CSS
   Version 1.0
============================================ */

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

.ntc-wrap * { box-sizing: border-box; margin: 0; padding: 0; }

.ntc-wrap {
    --pink:        #F72585;
    --purple:      #7209B7;
    --violet:      #560BAD;
    --blue:        #480CA8;
    --lightblue:   #4CC9F0;
    --green:       #06A77D;
    --amber:       #E8A33D;
    --red:         #E5484D;
    --darkred:     #8B1E24;
    --grad:        linear-gradient(135deg, #F72585 0%, #7209B7 100%);
    --grad-soft:   linear-gradient(135deg, rgba(247,37,133,0.08) 0%, rgba(114,9,183,0.08) 100%);
    --white:       #FFFFFF;
    --bg:          #F8F4FF;
    --card-bg:     #FFFFFF;
    --border:      rgba(114,9,183,0.12);
    --text:        #1A1A2E;
    --text-muted:  #6B7280;
    --shadow-card: 0 32px 80px rgba(114,9,183,0.18), 0 8px 24px rgba(247,37,133,0.10);
    --shadow-btn:  0 12px 32px rgba(247,37,133,0.45);
    --radius-xl:   24px;
    --radius-lg:   16px;
    --radius-md:   12px;
    --radius-sm:   8px;
    font-family: 'Inter', sans-serif;
    position: relative;
    padding: 40px 16px;
    background: var(--bg);
    min-height: 100%;
}

.ntc-blob { position: absolute; border-radius: 50%; filter: blur(60px); pointer-events: none; z-index: 0; }
.ntc-blob-1 { width: 300px; height: 300px; background: rgba(247,37,133,0.12); top: -60px; left: -80px; }
.ntc-blob-2 { width: 250px; height: 250px; background: rgba(114,9,183,0.10); bottom: 40px; right: -60px; }
.ntc-blob-3 { width: 180px; height: 180px; background: rgba(72,12,168,0.08); top: 50%; left: 50%; transform: translate(-50%,-50%); }

.ntc-card {
    position: relative;
    z-index: 1;
    max-width: 580px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* ---- Header ---- */
.ntc-header { background: var(--grad); padding: 28px 30px; display: flex; align-items: center; gap: 16px; position: relative; overflow: hidden; }
.ntc-header::after { content: ''; position: absolute; width: 200px; height: 200px; background: rgba(255,255,255,0.06); border-radius: 50%; top: -80px; right: -60px; }
.ntc-header::before { content: ''; position: absolute; width: 120px; height: 120px; background: rgba(255,255,255,0.04); border-radius: 50%; bottom: -40px; left: 30%; }
.ntc-header-icon { width: 52px; height: 52px; background: rgba(255,255,255,0.18); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.25); }
.ntc-header-icon svg { width: 28px; height: 28px; }
.ntc-header-text { flex: 1; min-width: 0; }
.ntc-header-text h2 { color: #FFFFFF; font-size: 17px; font-weight: 800; letter-spacing: -0.4px; line-height: 1.25; }
.ntc-header-text p { color: rgba(255,255,255,0.75); font-size: 12px; font-weight: 400; margin-top: 3px; }

.ntc-history-btn { width: 40px; height: 40px; background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.25); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; position: relative; z-index: 2; transition: background 0.2s; }
.ntc-history-btn:hover { background: rgba(255,255,255,0.28); }

/* ---- History Panel ---- */
.ntc-history-panel { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; background: #FAFAFF; border-bottom: 1px solid var(--border); }
.ntc-history-panel.ntc-history-open { max-height: 320px; overflow-y: auto; }
.ntc-history-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px 8px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.ntc-history-clear { background: none; border: none; color: var(--pink); font-size: 11px; font-weight: 700; cursor: pointer; }
.ntc-history-list { padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.ntc-history-empty { font-size: 13px; color: var(--text-muted); padding: 12px 0; text-align: center; }
.ntc-history-item { background: white; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.ntc-history-item-score { font-size: 12.5px; font-weight: 700; color: var(--text); }
.ntc-history-item-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- Demo Button ---- */
.ntc-demo-row { padding: 16px 30px 0; }
.ntc-demo-btn {
    width: 100%; padding: 10px;
    background: var(--grad-soft); border: 1.5px dashed var(--pink); border-radius: var(--radius-md);
    color: var(--pink); font-size: 12.5px; font-weight: 700; font-family: 'Inter', sans-serif;
    cursor: pointer; transition: all 0.2s;
}
.ntc-demo-btn:hover { background: var(--grad); color: white; border-style: solid; border-color: transparent; }

/* ---- Sections ---- */
.ntc-section { padding: 0; }
.ntc-section-title { font-size: 14px; font-weight: 800; color: var(--text); padding: 20px 30px 0; }
.ntc-section + .ntc-section { border-top: 1px solid var(--border); margin-top: 4px; }

.ntc-body { padding: 16px 30px 24px; display: flex; flex-direction: column; gap: 16px; }

.ntc-step-label { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ntc-step-label span { font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: 0.1px; }
.ntc-hint { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin-top: 8px; }

.ntc-help-btn {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--grad-soft);
    border: 1px solid var(--border);
    color: var(--purple);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}
.ntc-help-btn:hover { background: var(--grad); color: white; border-color: transparent; }

/* Plain / Unit Input */
.ntc-plain-input {
    width: 100%; padding: 14px 16px;
    border: 2px solid var(--border); border-radius: var(--radius-md);
    font-size: 15px; font-family: 'Inter', sans-serif; font-weight: 600;
    color: var(--text); background: #FAFAFF; outline: none;
    transition: all 0.25s ease;
}
.ntc-plain-input:focus { border-color: var(--pink); background: white; box-shadow: 0 0 0 4px rgba(247,37,133,0.08); }

/* Unit Input Row (input/readonly + unit select dropdown) */
.ntc-unit-input-wrap { display: flex; gap: 8px; align-items: center; }
.ntc-unit-input-wrap input,
.ntc-unit-input-wrap .ntc-readonly-field { flex: 1; min-width: 0; }
.ntc-unit-select-wrap { position: relative; flex-shrink: 0; width: 130px; }
.ntc-unit-select {
    width: 100%; padding: 14px 28px 14px 12px;
    border: 2px solid var(--border); border-radius: var(--radius-md);
    font-size: 12.5px; font-family: 'Inter', sans-serif; font-weight: 600;
    color: var(--purple); background: var(--grad-soft); cursor: pointer;
    appearance: none; -webkit-appearance: none; outline: none;
}
.ntc-unit-select-arrow { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--purple); pointer-events: none; }

/* Read-only computed field */
.ntc-readonly-field {
    padding: 14px 16px;
    border: 2px solid var(--border); border-radius: var(--radius-md);
    font-size: 15px; font-weight: 700;
    color: var(--purple); background: var(--grad-soft);
}

/* ---- Calculate Button ---- */
#ntc_btn {
    width: 100%; padding: 16px 24px;
    background: var(--grad); color: white; border: none; border-radius: var(--radius-md);
    font-size: 15px; font-weight: 700; font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-btn);
}
#ntc_btn::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent); opacity: 0; transition: opacity 0.3s; }
#ntc_btn:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(247,37,133,0.50); }
#ntc_btn:hover::before { opacity: 1; }
.ntc-btn-text { font-size: 15px; font-weight: 700; }
.ntc-btn-icon { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: rgba(255,255,255,0.20); border-radius: 50%; flex-shrink: 0; }

/* ---- Help Popover ---- */
.ntc-help-overlay { display: none; position: fixed; inset: 0; background: rgba(26,26,46,0.55); z-index: 9999; align-items: center; justify-content: center; padding: 20px; }
.ntc-help-overlay.ntc-help-open { display: flex; }
.ntc-help-popover { background: white; border-radius: var(--radius-lg); padding: 24px; max-width: 380px; width: 100%; box-shadow: 0 24px 60px rgba(0,0,0,0.3); }
.ntc-help-popover-title { font-size: 16px; font-weight: 800; color: var(--pink); margin-bottom: 10px; }
.ntc-help-popover-text { font-size: 13.5px; color: var(--text); line-height: 1.65; margin-bottom: 18px; }
.ntc-help-close { width: 100%; padding: 10px; background: var(--grad); color: white; border: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; font-family: 'Inter', sans-serif; cursor: pointer; }

/* ---- Result Section ---- */
.ntc-result {
    display: none; opacity: 0; transform: translateY(16px);
    transition: all 0.45s cubic-bezier(0.34,1.56,0.64,1);
    border-top: 1px solid var(--border);
    padding: 28px 30px;
    background: linear-gradient(180deg, rgba(247,37,133,0.02) 0%, rgba(114,9,183,0.03) 100%);
}
.ntc-result-visible { opacity: 1 !important; transform: translateY(0) !important; }
.ntc-result-header { display: flex; justify-content: center; margin-bottom: 20px; }
.ntc-result-badge { background: var(--grad); color: white; padding: 6px 18px; border-radius: 100px; font-size: 13px; font-weight: 700; letter-spacing: 0.5px; box-shadow: 0 4px 14px rgba(247,37,133,0.30); }

/* Percentile Big Card */
.ntc-due-card {
    background: var(--grad); border-radius: var(--radius-lg); padding: 22px;
    text-align: center; margin-bottom: 16px; position: relative; overflow: hidden;
    box-shadow: 0 16px 40px rgba(247,37,133,0.25);
}
.ntc-due-card::before { content: ''; position: absolute; width: 150px; height: 150px; background: rgba(255,255,255,0.07); border-radius: 50%; top: -50px; right: -30px; }
.ntc-due-card::after { content: ''; position: absolute; width: 100px; height: 100px; background: rgba(255,255,255,0.05); border-radius: 50%; bottom: -30px; left: -20px; }
.ntc-due-label { color: rgba(255,255,255,0.80); font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.ntc-due-date { color: white; font-size: 32px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.2; margin-bottom: 4px; }
.ntc-due-sub { color: rgba(255,255,255,0.80); font-size: 13px; font-weight: 500; }

.ntc-score-watch, .ntc-score-elevated { background: linear-gradient(135deg, #E8A33D 0%, #C97A0F 100%); }
.ntc-score-high { background: linear-gradient(135deg, #E5484D 0%, #AD2831 100%); }
.ntc-score-very-high { background: linear-gradient(135deg, #8B1E24 0%, #5C0F13 100%); }

/* Risk Alert */
.ntc-alert-card { display: flex; gap: 12px; border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 20px; border: 1.5px solid var(--border); }
.ntc-alert-icon { font-size: 20px; flex-shrink: 0; }
.ntc-alert-title { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.ntc-alert-text { font-size: 11.5px; color: var(--text-muted); line-height: 1.55; }
.ntc-alert-normal { background: rgba(6,167,125,0.08); border-color: rgba(6,167,125,0.3); }
.ntc-alert-watch { background: rgba(232,163,61,0.08); border-color: rgba(232,163,61,0.3); }
.ntc-alert-elevated { background: rgba(232,163,61,0.12); border-color: rgba(232,163,61,0.4); }
.ntc-alert-high { background: rgba(229,72,77,0.08); border-color: rgba(229,72,77,0.35); }
.ntc-alert-very-high { background: rgba(139,30,36,0.10); border-color: rgba(139,30,36,0.4); }

/* Percentile Chart */
.ntc-chart-card { background: white; border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 16px 18px; margin-bottom: 20px; }
.ntc-chart-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 12px; }
.ntc-chart-container { width: 100%; }
.ntc-chart-svg { width: 100%; height: auto; display: block; }
.ntc-grid-line { stroke: #EFE9F5; stroke-width: 1; }
.ntc-axis-label { font-size: 8px; fill: #9CA3AF; font-family: 'Inter', sans-serif; }
.ntc-axis-label-x { font-size: 7.5px; }
.ntc-curve { fill: none; stroke-width: 1.5; }
.ntc-curve-p5 { stroke: var(--pink); }
.ntc-curve-p25 { stroke: var(--amber); }
.ntc-curve-p50 { stroke: #B0AAB8; }
.ntc-curve-p75 { stroke: var(--blue); }
.ntc-curve-p95 { stroke: var(--darkred); }
.ntc-curve-dot.ntc-curve-p5 { fill: var(--pink); }
.ntc-curve-dot.ntc-curve-p25 { fill: var(--amber); }
.ntc-curve-dot.ntc-curve-p50 { fill: #B0AAB8; }
.ntc-curve-dot.ntc-curve-p75 { fill: var(--blue); }
.ntc-curve-dot.ntc-curve-p95 { fill: var(--darkred); }
.ntc-user-line { stroke: var(--purple); stroke-width: 1.5; stroke-dasharray: 4 3; }
.ntc-user-point { fill: var(--purple); stroke: white; stroke-width: 2; }
.ntc-hover-strip { fill: transparent; cursor: pointer; }
.ntc-hover-line { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.4; pointer-events: none; }

/* Interactive Chart Tooltip */
.ntc-chart-tooltip {
    position: absolute;
    top: 6%;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px rgba(0,0,0,0.18);
    padding: 10px 14px;
    min-width: 130px;
    pointer-events: none;
    z-index: 10;
}
.ntc-tt-header { font-size: 12px; font-weight: 800; color: var(--text); margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.ntc-tt-row { display: flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 2px 0; }
.ntc-tt-label { color: var(--text-muted); flex: 1; }
.ntc-tt-value { font-weight: 700; color: var(--text); }
.ntc-tt-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ntc-tt-you { background: var(--purple); }
.ntc-tt-p5 { background: var(--pink); }
.ntc-tt-p25 { background: var(--amber); }
.ntc-tt-p50 { background: #B0AAB8; }
.ntc-tt-p75 { background: var(--blue); }
.ntc-tt-p95 { background: var(--darkred); }
.ntc-chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.ntc-chart-legend-item { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--text-muted); font-weight: 500; }
.ntc-legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.ntc-legend-you { background: var(--purple); }
.ntc-legend-p5 { background: var(--pink); }
.ntc-legend-p25 { background: var(--amber); }
.ntc-legend-p50 { background: #B0AAB8; }
.ntc-legend-p75 { background: var(--blue); }
.ntc-legend-p95 { background: var(--darkred); }

/* Save Button */
.ntc-save-btn {
    width: 100%; padding: 12px 16px;
    background: white; border: 1.5px dashed var(--purple); border-radius: var(--radius-md);
    color: var(--purple); font-size: 13px; font-weight: 700; font-family: 'Inter', sans-serif;
    cursor: pointer; margin-bottom: 16px;
    transition: all 0.25s ease;
}
.ntc-save-btn:hover { background: var(--grad-soft); }

/* Export Buttons */
.ntc-export-row { display: flex; gap: 12px; }
.ntc-export-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 14px; background: white; border: 1.5px solid var(--border); border-radius: var(--radius-md);
    font-size: 13px; font-weight: 700; font-family: 'Inter', sans-serif;
    color: var(--purple); cursor: pointer;
    transition: all 0.25s ease;
}
.ntc-export-btn:hover { border-color: var(--pink); background: var(--grad-soft); color: var(--pink); transform: translateY(-1px); }
.ntc-export-btn svg { flex-shrink: 0; }

/* ---- Footer ---- */
.ntc-footer { display: flex; align-items: flex-start; gap: 8px; padding: 16px 30px 24px; font-size: 10.5px; color: var(--text-muted); line-height: 1.6; border-top: 1px solid var(--border); background: #FAFAFF; }
.ntc-footer svg { flex-shrink: 0; margin-top: 2px; color: var(--purple); }

/* ---- Mobile ---- */
@media (max-width: 600px) {
    .ntc-wrap { padding: 20px 10px; }
    .ntc-card { border-radius: var(--radius-lg); }
    .ntc-header { padding: 22px 20px; }
    .ntc-demo-row { padding: 14px 20px 0; }
    .ntc-section-title { padding: 18px 20px 0; }
    .ntc-body { padding: 14px 20px 20px; gap: 14px; }
    .ntc-result { padding: 22px 20px; }
    .ntc-footer { padding: 14px 20px 20px; }
    .ntc-due-date { font-size: 26px; }
    .ntc-header-text h2 { font-size: 15px; }
    .ntc-export-row { flex-direction: column; }
    .ntc-chart-legend { gap: 8px; }
}
