/* ══════════════════════════════════════════════════════════════════════════════
   SentimentFusion · style.css
   Aesthetic: Editorial dark · Fraunces serif display · Hanken Grotesk body
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── RESET ─────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
img,
svg {
    display: block;
}
button {
    cursor: pointer;
    border: none;
    background: none;
    font: inherit;
}
input,
textarea {
    font: inherit;
}

/* ── TOKENS ─────────────────────────────────────────────────────────────────── */
:root {
    --bg: #0d0d0d;
    --surface: #141414;
    --surface2: #1a1a1a;
    --border: #252525;
    --border2: #2e2e2e;
    --text: #e8e3d8;
    --muted: #666;
    --muted2: #888;

    /* accents */
    --green: #b8f54a;
    --purple: #a78bfa;
    --amber: #fbbf24;
    --red: #f87171;

    /* sentiment */
    --pos: #b8f54a;
    --neu: #a78bfa;
    --neg: #f87171;

    /* model colors */
    --c-text: #b8f54a;
    --c-image: #a78bfa;
    --c-fusion: #fbbf24;

    /* typography */
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Hanken Grotesk", system-ui, sans-serif;
    --font-mono: "DM Mono", "Fira Code", monospace;

    --radius: 10px;
    --radius-sm: 6px;
}

/* ── BASE ───────────────────────────────────────────────────────────────────── */
html {
    scroll-behavior: smooth;
}
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* NOISE TEXTURE */
.noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 180px;
}

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

/* ── HEADER ─────────────────────────────────────────────────────────────────── */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: rgba(13, 13, 13, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.header-inner {
    max-width: 1160px;
    margin: 0 auto;
    padding: 0.85rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.logo-sf {
    width: 30px;
    height: 30px;
    background: var(--green);
    color: #0d0d0d;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    letter-spacing: 0.04em;
}
.logo-text {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* TAG */
.tag {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    padding: 3px 9px;
    border-radius: 4px;
    border: 1px solid var(--border2);
    color: var(--muted2);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.tag--green {
    border-color: #b8f54a30;
    color: var(--green);
}
.tag--green.online {
    border-color: #b8f54a60;
}
.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    transition: background 0.3s;
}
.tag--green.online .dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

/* ── MAIN ────────────────────────────────────────────────────────────────────── */
main {
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 2rem 6rem;
}

/* ── HERO ────────────────────────────────────────────────────────────────────── */
.hero {
    padding: 5rem 0 3.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 3rem;
}
.hero-eyebrow {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}
.sep {
    color: var(--border2);
}
.hero-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 7vw, 5.5rem);
    font-weight: 300;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 1.5rem;
}
.hero-title em {
    font-style: italic;
    color: var(--green);
}
.hero-desc {
    font-size: 0.9rem;
    color: var(--muted2);
    max-width: 520px;
    line-height: 1.7;
}

/* ── SECTION LABEL ───────────────────────────────────────────────────────────── */
.section-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

/* ── CONFIG ──────────────────────────────────────────────────────────────────── */
.config-section {
    margin-bottom: 2.5rem;
}
.config-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.field-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    color: var(--muted2);
    display: block;
    margin-bottom: 0.4rem;
}
.input-row {
    display: flex;
    gap: 0.5rem;
}
.text-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border2);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    outline: none;
    transition: border-color 0.2s;
}
.text-input:focus {
    border-color: var(--green);
}
.text-input::placeholder {
    color: var(--muted);
}

.btn-ping {
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--muted2);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1.1rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    transition:
        border-color 0.2s,
        color 0.2s;
}
.btn-ping:hover {
    border-color: var(--green);
    color: var(--green);
}

/* ── FORM ────────────────────────────────────────────────────────────────────── */
.form-section {
    margin-bottom: 2rem;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 700px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.field-block {
    display: flex;
    flex-direction: column;
}
.field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}
.char-count {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--muted);
}

.textarea {
    flex: 1;
    min-height: 160px;
    background: var(--surface);
    border: 1px solid var(--border2);
    color: var(--text);
    border-radius: var(--radius);
    padding: 1rem;
    font-size: 0.88rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}
.textarea:focus {
    border-color: var(--green);
}
.textarea::placeholder {
    color: var(--muted);
}

/* DROP ZONE */
.drop-zone {
    flex: 1;
    min-height: 160px;
    background: var(--surface);
    border: 1.5px dashed var(--border2);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    transition:
        border-color 0.2s,
        background 0.2s;
    cursor: pointer;
}
.drop-zone:hover {
    border-color: var(--green);
    background: #b8f54a06;
}
.drop-zone.has-file {
    border-style: solid;
    border-color: var(--green);
}
.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.drop-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    z-index: 1;
}
.drop-icon {
    color: var(--green);
    opacity: 0.7;
}
.drop-title {
    font-size: 0.85rem;
    color: var(--text);
}
.drop-sub {
    font-size: 0.72rem;
    color: var(--muted);
    font-family: var(--font-mono);
}

/* PREVIEW */
.drop-preview {
    position: absolute;
    inset: 0;
    z-index: 3;
}
.drop-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.75;
}
.preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#previewName {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: #fff;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.preview-clear {
    color: #fff;
    font-size: 0.75rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.15s;
}
.preview-clear:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── ACTION ROW ──────────────────────────────────────────────────────────────── */
.action-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: flex-end;
}

.status-msg {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    flex: 1;
}
.status-msg.loading {
    background: #b8f54a0d;
    border: 1px solid #b8f54a30;
    color: var(--green);
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
}
.status-msg.loading::before {
    content: "";
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--green);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
.status-msg.error {
    background: #f8717110;
    border: 1px solid #f8717130;
    color: var(--red);
    display: block !important;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-run {
    background: var(--green);
    color: #0d0d0d;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.75rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition:
        opacity 0.15s,
        transform 0.1s;
    white-space: nowrap;
}
.btn-run:hover {
    opacity: 0.88;
}
.btn-run:active {
    transform: scale(0.98);
}
.btn-run:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.btn-run-icon {
    font-size: 1rem;
    transition: transform 0.2s;
}
.btn-run:hover .btn-run-icon {
    transform: translateX(3px);
}

/* ── RESULTS ─────────────────────────────────────────────────────────────────── */
.results {
    animation: fadeUp 0.4s ease both;
}
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* VERDICT */
.verdict-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.75rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}
.verdict-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}
.verdict-pill-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.verdict-pill {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    padding: 0.2rem 0.8rem;
    border-radius: var(--radius-sm);
    transition:
        background 0.3s,
        color 0.3s;
}
.verdict-pill.pos {
    background: #b8f54a18;
    color: var(--pos);
}
.verdict-pill.neu {
    background: #a78bfa18;
    color: var(--neu);
}
.verdict-pill.neg {
    background: #f8717118;
    color: var(--neg);
}
.verdict-conf {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted2);
}

/* ── BREAKDOWN GRID 1×3 ──────────────────────────────────────────────────────── */
.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 3rem;
}
@media (max-width: 700px) {
    .breakdown-grid {
        grid-template-columns: 1fr;
    }
}

.bcard {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.bcard--fusion {
    border-color: #fbbf2430;
}

.bcard-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.1rem;
}
.bcard-title {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted2);
}
.bcard-pred {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 4px;
}
.bcard-pred.pos {
    background: #b8f54a18;
    color: var(--pos);
}
.bcard-pred.neu {
    background: #a78bfa18;
    color: var(--neu);
}
.bcard-pred.neg {
    background: #f8717118;
    color: var(--neg);
}

/* BARS */
.bars {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.bar-row {
    display: grid;
    grid-template-columns: 52px 1fr 40px;
    align-items: center;
    gap: 0.5rem;
}
.bar-label {
    font-size: 0.72rem;
    color: var(--muted);
    font-family: var(--font-mono);
}
.bar-track {
    height: 5px;
    background: var(--border2);
    border-radius: 3px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    border-radius: 3px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.bar--pos {
    background: var(--pos);
}
.bar--neu {
    background: var(--neu);
}
.bar--neg {
    background: var(--neg);
}
.bar-pct {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--muted2);
    text-align: right;
}

/* ── METRICS / CHARTS GRID 1×3 ───────────────────────────────────────────────── */
.metrics-header {
    margin-bottom: 1rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
@media (max-width: 900px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.chart-card--text {
    border-top: 2px solid var(--c-text);
}
.chart-card--image {
    border-top: 2px solid var(--c-image);
}
.chart-card--fusion {
    border-top: 2px solid var(--c-fusion);
}

.chart-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.chart-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 0.15rem;
}
.chart-card-sub {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--muted);
}
.chart-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
}
.chart-badge--text {
    background: #b8f54a18;
    color: var(--c-text);
}
.chart-badge--image {
    background: #a78bfa18;
    color: var(--c-image);
}
.chart-badge--fusion {
    background: #fbbf2418;
    color: var(--c-fusion);
}

/* METRIC LIST */
.metric-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.metric-item {
    display: grid;
    grid-template-columns: 64px 1fr 44px;
    align-items: center;
    gap: 0.5rem;
}
.metric-name {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--muted);
}
.metric-bar-wrap {
    height: 4px;
    background: var(--border2);
    border-radius: 2px;
    overflow: hidden;
}
.metric-bar {
    height: 100%;
    border-radius: 2px;
}
.metric-bar--text {
    background: var(--c-text);
}
.metric-bar--image {
    background: var(--c-image);
}
.metric-bar--fusion {
    background: var(--c-fusion);
}
.metric-val {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--muted2);
    text-align: right;
}

/* ── MATPLOTLIB PLACEHOLDER ─────────────────────────────────────────────────── */
.mpl-zone {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}
.mpl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 120px;
    background: var(--surface2);
    border: 1.5px dashed var(--border2);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.04em;
}
/* Ẩn placeholder khi có ảnh */
.mpl-zone.loaded .mpl-empty {
    display: none;
}
.mpl-zone.loaded .mpl-img {
    display: block !important;
}

.mpl-img {
    width: 100%;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

/* ── FOOTER ──────────────────────────────────────────────────────────────────── */
footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
}
.footer-inner {
    max-width: 1160px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--muted);
}
.footer-sep {
    color: var(--border2);
}
