/* ================================================================
   DPS — Diabetes Prediction System  •  Dark Tech UI
   ================================================================ */

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

:root {
    /* Core palette */
    --bg-primary: #0a0e17;
    --bg-card: rgba(14, 20, 33, 0.85);
    --bg-input: rgba(20, 28, 48, 0.7);
    --border-subtle: rgba(99, 140, 255, 0.12);
    --border-focus: rgba(99, 180, 255, 0.45);

    /* Accent */
    --accent-blue: #4d8bff;
    --accent-cyan: #22d3ee;
    --accent-purple: #a78bfa;
    --accent-gradient: linear-gradient(135deg, #4d8bff 0%, #22d3ee 50%, #a78bfa 100%);

    /* Risk colors */
    --risk-low: #00e676;
    --risk-moderate: #ffab00;
    --risk-high: #ff1744;

    /* Text */
    --text-primary: #e8ecf4;
    --text-secondary: #8899b8;
    --text-muted: #556688;

    /* Shadows */
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--border-subtle);
    --shadow-glow: 0 0 40px rgba(77, 139, 255, 0.15);

    /* Sizing */
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ─── Ambient Background ─── */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(77, 139, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(77, 139, 255, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
}

.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.12;
    z-index: 0;
    pointer-events: none;
}
.bg-glow--1 {
    top: -200px;
    left: -100px;
    background: var(--accent-blue);
    animation: float-glow 12s ease-in-out infinite alternate;
}
.bg-glow--2 {
    bottom: -200px;
    right: -100px;
    background: var(--accent-purple);
    animation: float-glow 15s ease-in-out infinite alternate-reverse;
}

@keyframes float-glow {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, -30px) scale(1.15); }
}

/* ─── Header ─── */
.header {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 40px;
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(20px);
    background: rgba(10, 14, 23, 0.7);
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header__icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 20px rgba(77, 139, 255, 0.35);
}
.header__icon svg {
    width: 24px;
    height: 24px;
}

.header__title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.04em;
}

.header__badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(77, 139, 255, 0.1);
    border: 1px solid rgba(77, 139, 255, 0.2);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-blue);
    letter-spacing: 0.04em;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-cyan);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.5); }
    50% { opacity: 0.6; box-shadow: 0 0 0 8px rgba(34, 211, 238, 0); }
}

/* ─── Main Layout ─── */
.main {
    position: relative;
    z-index: 5;
    max-width: 780px;
    margin: 48px auto;
    padding: 0 24px;
}

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 36px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(24px);
    animation: card-enter 0.6s ease-out;
}
.card + .card {
    margin-top: 32px;
}

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

.card__header {
    margin-bottom: 28px;
}

.card__title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
}

.card__desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* ─── Form Grid ─── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.input-group input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 500;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    transition: all 0.25s ease;
}

.input-group input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(77, 139, 255, 0.12), var(--shadow-glow);
}

.input-group input:hover {
    border-color: rgba(99, 140, 255, 0.25);
}

.input-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ─── Segmented Control ─── */
.segmented-control {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
    padding: 4px;
    gap: 4px;
}
.segmented-control input[type="radio"] {
    display: none;
}
.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all 0.25s ease;
}
.segmented-control input[type="radio"]:checked + label {
    background: var(--accent-blue);
    color: #fff;
    box-shadow: 0 2px 10px rgba(77, 139, 255, 0.3);
}

/* ─── Predict Button ─── */
.btn-predict {
    grid-column: 1 / -1;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.btn-predict:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(77, 139, 255, 0.4);
}

.btn-predict:active {
    transform: translateY(0);
}

.btn-predict__icon {
    width: 20px;
    height: 20px;
}

.btn-predict__loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-predict.loading .btn-predict__text { display: none; }
.btn-predict.loading .btn-predict__icon { display: none; }
.btn-predict.loading .btn-predict__loader { display: block; }

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

/* ─── Results ─── */
.hidden {
    display: none !important;
}

.card--result {
    text-align: center;
}

/* Gauge */
.result-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin: 24px 0 32px;
}

.gauge-ring {
    position: relative;
    width: 200px;
    height: 200px;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.gauge-track {
    fill: none;
    stroke: rgba(77, 139, 255, 0.08);
    stroke-width: 10;
}

.gauge-fill {
    fill: none;
    stroke: var(--accent-blue);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 534;
    stroke-dashoffset: 534;
    transition: stroke-dashoffset 1.8s cubic-bezier(0.4, 0, 0.2, 1),
                stroke 0.5s ease;
    filter: drop-shadow(0 0 8px currentColor);
}

.gauge-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gauge-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1;
}

.gauge-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* Verdict */
.result-verdict {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.verdict-badge {
    display: inline-block;
    padding: 10px 28px;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    animation: badge-pop 0.5s ease-out 0.8s both;
}

@keyframes badge-pop {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
}

.verdict-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 400px;
}

/* ─── SHAP Explanation ─── */
.explanation-section {
    margin-top: 32px;
    text-align: left;
}

.explanation-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.explanation-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.exp-row {
    display: grid;
    grid-template-columns: 140px 1fr 70px;
    align-items: center;
    gap: 12px;
    animation: exp-slide 0.4s ease-out backwards;
}
.exp-row:nth-child(1) { animation-delay: 0.9s; }
.exp-row:nth-child(2) { animation-delay: 1.0s; }
.exp-row:nth-child(3) { animation-delay: 1.1s; }
.exp-row:nth-child(4) { animation-delay: 1.2s; }
.exp-row:nth-child(5) { animation-delay: 1.3s; }
.exp-row:nth-child(6) { animation-delay: 1.4s; }
.exp-row:nth-child(7) { animation-delay: 1.5s; }
.exp-row:nth-child(8) { animation-delay: 1.6s; }

@keyframes exp-slide {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}

.exp-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exp-bar-container {
    height: 24px;
    background: rgba(77, 139, 255, 0.06);
    border-radius: var(--radius-xs);
    position: relative;
    overflow: hidden;
}

.exp-bar {
    position: absolute;
    top: 2px;
    bottom: 2px;
    border-radius: 4px;
    transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.exp-bar--positive {
    left: 50%;
    background: linear-gradient(90deg, rgba(255, 23, 68, 0.6), #ff1744);
}
.exp-bar--negative {
    right: 50%;
    background: linear-gradient(270deg, rgba(0, 230, 118, 0.6), #00e676);
}

.exp-bar-container::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-subtle);
}

.exp-impact {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: right;
}

/* ─── Disclaimer ─── */
.disclaimer {
    margin-top: 28px;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    background: rgba(255, 171, 0, 0.06);
    border: 1px solid rgba(255, 171, 0, 0.15);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: left;
    line-height: 1.6;
}
.disclaimer strong {
    color: var(--risk-moderate);
}

/* ─── Reset Button ─── */
.btn-reset {
    margin-top: 24px;
    padding: 12px 28px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}
.btn-reset:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(77, 139, 255, 0.06);
}

/* ─── Footer ─── */
.footer {
    position: relative;
    z-index: 5;
    text-align: center;
    padding: 32px 24px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .header {
        padding: 16px 20px;
    }
    .header__badge {
        display: none;
    }
    .main {
        margin: 24px auto;
        padding: 0 16px;
    }
    .card {
        padding: 24px;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .gauge-ring {
        width: 160px;
        height: 160px;
    }
    .gauge-value {
        font-size: 1.8rem;
    }
    .exp-row {
        grid-template-columns: 100px 1fr 60px;
        gap: 8px;
    }
}
