/* =========================================================
   ROOT
========================================================= */

:root {

    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;

    --text: #172033;
    --text-soft: #64748b;
    --border: #e2e8f0;

    --primary: #2563eb;
    --primary-soft: #eff6ff;

    --green: #16a34a;
    --green-soft: #f0fdf4;

    --red: #ef4444;
    --orange: #f59e0b;
    --purple: #7c3aed;

    --shadow:
        0 10px 35px rgba(15, 23, 42, 0.07);

    --radius: 18px;

    --accent-indigo: #4f46e5;
    --accent-cyan: #0284c7;
    --accent-emerald: #059669;
    --accent-rose: #e11d48;
    --accent-amber: #d97706;

    --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 30px rgba(79, 70, 229, 0.05);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);

    --status-bg: rgba(15, 23, 42, 0.6);

    --border-color: rgba(0, 0, 0, 0.08);
    --border-dashed: #cbd5e1;
    --border-highlight: rgba(79, 70, 229, 0.3);
    --glass-backdrop: blur(16px) saturate(180%);
}


[data-theme="dark"] {

    --bg: #0b1120;
    --surface: #111827;
    --surface-soft: #172033;

    --text: #f1f5f9;
    --text-soft: #94a3b8;
    --border: #273449;

    --primary: #60a5fa;
    --primary-soft: #172554;

    --green: #4ade80;
    --green-soft: #052e16;

    --shadow:
        0 15px 40px rgba(0, 0, 0, 0.3);

    --accent-indigo: #6366f1;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;

    --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 30px rgba(79, 70, 229, 0.05);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);

    --status-bg: rgba(15, 23, 42, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-dashed: rgba(255, 255, 255, 0.15);
    --border-highlight: rgba(99, 102, 241, 0.3);
}


/* =========================================================
   RESET
========================================================= */

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


body {

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: var(--bg);
    color: var(--text);

    min-height: 100vh;

    transition:
        background .25s ease,
        color .25s ease;
}


button,
input {
    font: inherit;
}


/* =========================================================
   TOPBAR
========================================================= */

.topbar {

    height: 76px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 5%;

    background: var(--surface);

    border-bottom:
        1px solid var(--border);

    position: sticky;
    top: 0;

    z-index: 100;
}


.brand {

    display: flex;
    align-items: center;

    gap: 12px;
}


.brand-icon {

    width: 42px;
    height: 42px;

    border-radius: 12px;

    display: flex;
    align-items: center;
    justify-content: center;

    background:
        linear-gradient(135deg,
            #2563eb,
            #7c3aed);

    color: white;

    font-size: 24px;
    font-weight: 800;
}


.brand-text h1 {

    font-size: 18px;
    line-height: 1;
}


.brand-text span {

    display: block;

    font-size: 11px;

    color: var(--text-soft);

    margin-top: 4px;
}


.header-right {

    display: flex;
    align-items: center;
    gap: 18px;
}


.back-dashboard {

    color: var(--text-soft);

    text-decoration: none;

    font-size: 13px;
    font-weight: 600;

    padding: 9px 13px;

    border-radius: 10px;

    transition: .2s;
}


.back-dashboard:hover {

    color: var(--primary);
    background: var(--primary-soft);
}


.system-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--surface-soft);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    box-shadow: var(--shadow-lg);
    backdrop-filter: var(--glass-backdrop);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald);
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: var(--accent-rose);
    box-shadow: 0 0 10px var(--accent-rose);
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}


.theme-toggle {

    width: 38px;
    height: 38px;

    border-radius: 10px;

    border: 1px solid var(--border);

    background: var(--surface);

    color: var(--text);

    cursor: pointer;

    font-size: 17px;

    transition: .2s;
}


.theme-toggle:hover {

    background: var(--surface-soft);

    transform: translateY(-1px);
}


/* =========================================================
   PAGE
========================================================= */

.page-container {

    width: min(1400px, 90%);

    margin: auto;

    padding:
        48px 0 70px;
}


/* =========================================================
   PAGE HEADER
========================================================= */

.page-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 40px;

    margin-bottom: 35px;
}


.eyebrow {

    display: flex;
    align-items: center;

    gap: 8px;

    color: var(--primary);

    font-size: 11px;

    font-weight: 800;

    letter-spacing: .12em;

    margin-bottom: 12px;
}


.eyebrow span {

    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: var(--primary);
}


.page-header h2 {

    font-size:
        clamp(30px, 4vw, 46px);

    line-height: 1.08;

    letter-spacing: -.035em;
}


.page-header h2 span {

    color: var(--primary);
}


.page-header p {

    max-width: 650px;

    margin-top: 14px;

    color: var(--text-soft);

    line-height: 1.7;

    font-size: 15px;
}


.header-badge {

    min-width: 170px;

    display: flex;

    align-items: center;

    gap: 13px;

    padding: 16px;

    background: var(--surface);

    border:
        1px solid var(--border);

    border-radius: 16px;

    box-shadow: var(--shadow);
}


.badge-icon {

    width: 48px;
    height: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 13px;

    background:
        var(--primary-soft);

    color: var(--primary);

    font-weight: 800;
}


.header-badge strong {

    display: block;

    font-size: 14px;
}


.header-badge span {

    display: block;

    color: var(--text-soft);

    font-size: 11px;

    margin-top: 3px;
}


/* =========================================================
   PANEL
========================================================= */

.panel {

    background: var(--surface);

    border:
        1px solid var(--border);

    border-radius: var(--radius);

    box-shadow: var(--shadow);

    padding: 25px;
}


.panel-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 22px;
}


.panel-label {

    color: var(--primary);

    font-size: 10px;

    font-weight: 800;

    letter-spacing: .14em;
}


.panel-header h3 {

    margin-top: 5px;

    font-size: 19px;
}


/* =========================================================
   MODEL GRID
========================================================= */

.model-grid {

    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 15px;
}


.model-card {

    text-align: left;

    border:
        1px solid var(--border);

    background: var(--surface-soft);

    color: var(--text);

    border-radius: 15px;

    padding: 18px;

    cursor: pointer;

    transition:
        transform .2s,
        border .2s,
        box-shadow .2s;
}


.model-card:hover {

    transform: translateY(-2px);

    border-color: var(--primary);
}


.model-card.active {

    border:
        2px solid var(--primary);

    background:
        var(--primary-soft);

    box-shadow:
        0 8px 25px rgba(37, 99, 235, .10);
}


.model-card-top {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 14px;
}


.model-icon {

    width: 42px;
    height: 42px;

    border-radius: 11px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--surface);

    border:
        1px solid var(--border);

    color: var(--primary);

    font-size: 12px;

    font-weight: 800;
}


.model-check {

    opacity: 0;

    width: 24px;
    height: 24px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: var(--primary);

    color: white;

    font-size: 12px;
}


.model-card.active .model-check {

    opacity: 1;
}


.model-card h4 {

    font-size: 15px;

    margin-bottom: 7px;
}


.model-card p {

    color: var(--text-soft);

    font-size: 12px;

    line-height: 1.6;

    min-height: 58px;
}


.model-type {

    display: inline-block;

    margin-top: 13px;

    font-size: 9px;

    font-weight: 800;

    letter-spacing: .08em;

    color: var(--text-soft);
}

/* Card Footer Layout (Keeps type and status aligned) */
.model-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

/* Adjust model-type margin since it's now inside footer */
.model-type {
    display: inline-block;
    margin-top: 0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

/* Base Model Status Badge */
.model-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: capitalize;
    letter-spacing: 0.02em;
    transition: all 0.2s ease;
}

/* Status Indicator Dot */
.model-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* --- STATE 1: Ready --- */
.model-status.ready {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.model-status.ready::before {
    background-color: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* --- STATE 2: Coming Soon --- */
.model-status.coming-soon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.model-status.coming-soon::before {
    background-color: #f59e0b;
}

/* --- OPTIONAL: Disabled Card Styling for Coming Soon --- */
.model-card.disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.model-card.disabled:hover {
    transform: none;
    border-color: var(--border);
}

/* =========================================================
   WORKSPACE
========================================================= */

.workspace {

    display: grid;

    grid-template-columns:
        minmax(350px, .8fr) minmax(500px, 1.2fr);

    gap: 20px;

    margin-top: 20px;

    align-items: start;
}


/* =========================================================
   UPLOAD
========================================================= */

.upload-area {

    min-height: 350px;

    border:
        2px dashed var(--border);

    border-radius: 15px;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 20px;

    cursor: pointer;

    background: var(--surface-soft);

    transition: .2s;

    overflow: hidden;
}


.upload-area:hover,
.upload-area.dragover {

    border-color: var(--primary);

    background: var(--primary-soft);
}


.upload-placeholder {

    text-align: center;

    max-width: 300px;
}


.upload-icon {

    width: 62px;
    height: 62px;

    margin:
        0 auto 16px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 17px;

    background: var(--primary-soft);

    color: var(--primary);

    font-size: 28px;
}


.upload-placeholder h4 {

    font-size: 16px;

    margin-bottom: 8px;
}


.upload-placeholder p {

    color: var(--text-soft);

    font-size: 12px;

    line-height: 1.6;
}


.upload-placeholder>span {

    display: inline-block;

    margin-top: 12px;

    color: var(--text-soft);

    font-size: 10px;

    font-weight: 700;
}


.image-preview {

    width: 100%;

    max-height: 390px;

    object-fit: contain;

    border-radius: 10px;

    display: none;
}


.change-image {

    width: 100%;

    margin-top: 12px;

    padding: 10px;

    border:
        1px solid var(--border);

    background: var(--surface);

    color: var(--text);

    border-radius: 10px;

    cursor: pointer;

    font-size: 12px;

    font-weight: 600;
}


.analyze-button {

    width: 100%;

    margin-top: 15px;

    padding: 14px;

    border: none;

    border-radius: 12px;

    background:
        linear-gradient(135deg,
            #2563eb,
            #4f46e5);

    color: white;

    font-weight: 700;

    cursor: pointer;

    display: flex;

    justify-content: center;

    align-items: center;

    gap: 9px;

    transition: .2s;
}


.analyze-button:hover:not(:disabled) {

    transform: translateY(-1px);

    box-shadow:
        0 8px 20px rgba(37, 99, 235, .25);
}


.analyze-button:disabled {

    opacity: .45;

    cursor: not-allowed;
}


.loading-state {

    display: none;

    align-items: center;

    gap: 12px;

    margin-top: 15px;

    padding: 13px;

    background: var(--primary-soft);

    border-radius: 11px;

    color: var(--primary);

    font-size: 12px;
}


.loading-state strong,
.loading-state span {

    display: block;
}


.loading-state span {

    color: var(--text-soft);

    margin-top: 3px;
}


.spinner {

    width: 25px;
    height: 25px;

    border:
        3px solid color-mix(in srgb,
            var(--primary) 20%,
            transparent);

    border-top-color: var(--primary);

    border-radius: 50%;

    animation:
        spin .7s linear infinite;
}


@keyframes spin {

    to {
        transform: rotate(360deg);
    }

}


.error-message {

    display: none;

    margin-top: 12px;

    padding: 11px;

    border-radius: 10px;

    background: #fef2f2;

    color: #dc2626;

    font-size: 12px;
}


/* =========================================================
   RESULT
========================================================= */

.result-status {

    padding:
        6px 10px;

    border-radius: 20px;

    background: var(--surface-soft);

    color: var(--text-soft);

    font-size: 10px;

    font-weight: 700;
}


.result-status.success {

    background: var(--green-soft);

    color: var(--green);
}


.result-empty {

    min-height: 350px;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    text-align: center;
}


.empty-icon {

    width: 62px;
    height: 62px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 17px;

    background: var(--surface-soft);

    color: var(--primary);

    font-weight: 800;

    margin-bottom: 15px;
}


.result-empty h4 {

    font-size: 16px;

    margin-bottom: 7px;
}


.result-empty p {

    color: var(--text-soft);

    font-size: 12px;

    max-width: 300px;

    line-height: 1.6;
}


/* =========================================================
   PREDICTION
========================================================= */

.prediction-box {

    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 18px;

    border-radius: 14px;

    background: var(--green-soft);

    border:
        1px solid color-mix(in srgb,
            var(--green) 20%,
            var(--border));
}


.prediction-box span,
.confidence span {

    display: block;

    font-size: 9px;

    font-weight: 800;

    letter-spacing: .1em;

    color: var(--text-soft);
}


.prediction-box h4 {

    color: var(--green);

    font-size: 25px;

    margin-top: 6px;
}


.confidence {

    text-align: right;
}


.confidence strong {

    display: block;

    margin-top: 5px;

    font-size: 24px;

    color: var(--green);
}


/* =========================================================
   PROBABILITIES
========================================================= */

.probability-section {

    margin-top: 25px;
}


.sub-heading {

    font-size: 10px;

    font-weight: 800;

    letter-spacing: .1em;

    color: var(--text-soft);

    margin-bottom: 16px;
}


.probability-list {

    display: flex;

    flex-direction: column;

    gap: 13px;
}


.probability-row {

    display: grid;

    grid-template-columns:
        145px 1fr 48px;

    gap: 12px;

    align-items: center;
}


.probability-label {

    font-size: 11px;

    display: flex;

    align-items: center;

    gap: 7px;
}


.grade-dot {

    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: var(--primary);
}


.grade-0 {
    background: #16a34a;
}

.grade-1 {
    background: #84cc16;
}

.grade-2 {
    background: #f59e0b;
}

.grade-3 {
    background: #f97316;
}

.grade-4 {
    background: #dc2626;
}


.probability-track {

    height: 8px;

    background: var(--surface-soft);

    border-radius: 20px;

    overflow: hidden;
}


.probability-bar {

    height: 100%;

    width: 0%;

    border-radius: 20px;

    background:
        linear-gradient(90deg,
            var(--primary),
            #6366f1);

    transition:
        width .7s ease;
}


.probability-value {

    text-align: right;

    font-size: 11px;

    font-weight: 700;
}


/* =========================================================
   VISUALIZATION
========================================================= */

.visualization-section {

    margin-top: 28px;
}


.visualization-grid {

    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 12px;
}


.visual-card {

    border:
        1px solid var(--border);

    border-radius: 12px;

    overflow: hidden;

    background: var(--surface-soft);
}


.visual-title {

    padding: 9px 11px;

    font-size: 10px;

    font-weight: 700;

    color: var(--text-soft);

    border-bottom:
        1px solid var(--border);
}


.visual-card img {

    width: 100%;

    height: 300px;

    object-fit: contain;

    display: block;

    background: #050505;
}


/* =========================================================
   RESEARCH NOTE
========================================================= */

.research-note {

    margin-top: 20px;

    padding: 18px;

    display: flex;

    gap: 14px;

    background: var(--surface);

    border:
        1px solid var(--border);

    border-radius: 15px;
}


.research-icon {

    width: 40px;
    height: 40px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 11px;

    background: var(--primary-soft);

    color: var(--primary);

    font-size: 11px;

    font-weight: 800;
}


.research-note strong {

    font-size: 13px;
}


.research-note p {

    margin-top: 5px;

    color: var(--text-soft);

    font-size: 11px;

    line-height: 1.6;
}


/* =========================================================
   FOOTER
========================================================= */

footer {

    padding:
        20px 5%;

    border-top:
        1px solid var(--border);

    display: flex;

    justify-content: space-between;

    color: var(--text-soft);

    font-size: 11px;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1000px) {

    .workspace {

        grid-template-columns: 1fr;

    }

}


@media (max-width: 750px) {

    .model-grid {

        grid-template-columns: 1fr;

    }


    .page-header {

        align-items: flex-start;

        flex-direction: column;

    }


    .header-badge {

        width: 100%;

    }


    .backend-status {

        display: none;

    }


    .topbar {

        padding: 0 20px;

    }


    .page-container {

        width: 92%;

        padding-top: 30px;

    }


    .probability-row {

        grid-template-columns:
            125px 1fr 45px;

    }


    footer {

        flex-direction: column;

        gap: 7px;

    }

}


@media (max-width: 500px) {

    .back-dashboard {

        font-size: 0;

    }


    .back-dashboard::before {

        content: "←";

        font-size: 18px;

    }


    .visualization-grid {

        grid-template-columns: 1fr;

    }


    .prediction-box {

        align-items: flex-start;

        flex-direction: column;

        gap: 15px;

    }


    .confidence {

        text-align: left;

    }

}