/* Essay Checker — scoped styles that reuse SATForce theme tokens.
   All selectors are prefixed .ec- to avoid collisions with the rest of
   the site. Colour tokens inherit from :root in static/css/styles.css
   (--bg-primary, --accent-gold-dark, --text-*, etc).
   ------------------------------------------------------------------- */

.ec-page {
    --ec-slight: #E8AE3D;
    --ec-medium: #D97706;
    --ec-total:  var(--accent-red);
    --ec-ok:     var(--accent-green);
    --ec-warn:   #B45309;
    --ec-bad:    var(--accent-red);
    --ec-radius: var(--radius-md);
    --ec-radius-sm: var(--radius-sm);
    --ec-surface: var(--bg-card);
    --ec-surface-2: var(--bg-secondary);
    --ec-ink: var(--text-primary);
    --ec-ink-soft: var(--text-secondary);
    --ec-ink-mute: var(--text-muted);
    --ec-accent: var(--accent-gold-dark);
    --ec-accent-hover: var(--accent-gold);
    --ec-accent-soft: var(--bg-active);

    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    color: var(--ec-ink);
    font-family: var(--font-body);
}

/* History button badge: "+N" pill indicating unseen reports. */
.ec-history-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.ec-unseen-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--accent-red, #C75B5B);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    font-family: var(--font-body);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

/* ---------- topbar ---------- */
.ec-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.ec-title-row { min-width: 240px; }
.ec-title {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    color: var(--ec-ink);
    margin: 0 0 4px;
}
.ec-subtitle {
    margin: 0;
    color: var(--ec-ink-soft);
    font-size: .95rem;
    max-width: 640px;
    line-height: 1.55;
}
.ec-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.ec-quota {
    font-size: .85rem;
    color: var(--ec-ink-soft);
    background: var(--ec-accent-soft);
    border: 1px solid var(--border-light);
    padding: 6px 12px;
    border-radius: 999px;
}
.ec-quota strong { color: var(--ec-accent); }

/* ---------- badges ---------- */
.ec-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--ec-surface-2);
    color: var(--ec-ink-soft);
    font-size: .82rem;
    font-weight: 600;
}
.ec-badge.subtle {
    background: var(--ec-accent-soft);
    color: var(--ec-accent);
}

/* ---------- card shell ---------- */
.ec-card {
    background: var(--ec-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--ec-radius);
    box-shadow: var(--shadow-sm);
}

/* ---------- layout ---------- */
.ec-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}
.ec-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- prompt card ---------- */
.ec-prompt-card { padding: 18px 20px; }
.ec-prompt-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 0 4px;
}
.ec-prompt-head:first-child { margin-top: 0; }
.ec-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--ec-ink-mute);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.ec-label.accent { color: var(--ec-accent); }
.ec-counter { font-size: .8rem; color: var(--ec-ink-mute); }
.ec-prompt-body { margin: 0; color: var(--ec-ink-soft); }
.ec-prompt-question { margin: 0; font-weight: 700; font-size: 1.08rem; color: var(--ec-ink); }

/* ---------- editor ---------- */
.ec-editor-card {
    padding: 18px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ec-editor-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: var(--ec-ink-soft);
}
.ec-meta { font-size: .85rem; color: var(--ec-ink-mute); font-weight: 500; }

.ec-essay-stack {
    position: relative;
    border: 1px solid var(--border-medium);
    border-radius: var(--ec-radius-sm);
    background: var(--bg-primary);
    min-height: 420px;
}
.ec-essay-highlights,
.ec-essay-input {
    font-family: var(--font-body);
    font-size: 1.02rem;
    line-height: 1.75;
    padding: 14px 16px;
    margin: 0;
    border: 0;
    direction: rtl;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
    tab-size: 4;
}
.ec-essay-highlights {
    position: absolute;
    inset: 0;
    color: transparent;
    pointer-events: none;
    overflow: auto;
    user-select: none;
}
.ec-essay-input {
    position: relative;
    display: block;
    width: 100%;
    min-height: 420px;
    background: transparent;
    color: var(--ec-ink);
    resize: vertical;
    outline: none;
    caret-color: var(--ec-accent);
}

/* Highlights */
.ec-essay-highlights mark {
    background: transparent;
    color: transparent;
    border-radius: 4px;
    padding: 0;
    transition: background .15s ease, box-shadow .15s ease;
}
.ec-essay-highlights mark.dim { background: rgba(232, 174, 61, .22); }
.ec-essay-highlights mark.sev-slight.active { background: rgba(232, 174, 61, .55); box-shadow: 0 0 0 2px rgba(232, 174, 61, .35); }
.ec-essay-highlights mark.sev-medium.active { background: rgba(217, 119, 6, .55);  box-shadow: 0 0 0 2px rgba(217, 119, 6, .35); }
.ec-essay-highlights mark.sev-total.active  { background: rgba(199, 91, 91, .55);  box-shadow: 0 0 0 2px rgba(199, 91, 91, .35); }

/* ---------- buttons ---------- */
.ec-editor-actions {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.ec-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 10px;
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.ec-btn.primary {
    background: var(--ec-accent);
    color: var(--text-inverse);
    box-shadow: var(--shadow-glow);
}
.ec-btn.primary:hover { transform: translateY(-1px); background: var(--ec-accent-hover); }
.ec-btn.primary:disabled { opacity: .6; cursor: wait; transform: none; }
.ec-btn.primary.write-mode {
    background: var(--accent-purple);
    box-shadow: 0 4px 12px rgba(139, 93, 199, .28);
}
.ec-btn.ghost {
    background: var(--ec-surface-2);
    color: var(--ec-ink-soft);
}
.ec-btn.ghost:hover { background: var(--bg-hover); color: var(--ec-ink); }
.ec-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── filter chip (examples-only toggle) ── */
.ec-filter-chip {
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
}
.ec-filter-chip .ec-filter-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--text-muted);
    transition: background .15s, box-shadow .15s;
}
.ec-filter-chip[aria-pressed="true"] {
    background: var(--ec-accent-soft);
    color: var(--ec-ink);
    border-color: var(--ec-accent);
}
.ec-filter-chip[aria-pressed="true"] .ec-filter-dot {
    background: var(--ec-accent);
    box-shadow: 0 0 0 3px rgba(212, 165, 53, .18);
}
.ec-filter-chip[aria-pressed="false"] {
    opacity: .75;
}
.ec-filter-chip[aria-pressed="false"]:hover { opacity: 1; }

.ec-preset-group {
    display: inline-flex;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 10px;
    background: var(--bg-primary);
    border: 1px dashed var(--border-medium);
}
.ec-preset-group .ec-btn.preset { padding: 8px 12px; font-size: .9rem; border-radius: 8px; }
.ec-preset-group .ec-btn.preset.sev-slight { box-shadow: inset 0 -2px 0 rgba(93, 140, 97, .55); }
.ec-preset-group .ec-btn.preset.sev-medium { box-shadow: inset 0 -2px 0 rgba(217, 119, 6, .55); }
.ec-preset-group .ec-btn.preset.sev-total  { box-shadow: inset 0 -2px 0 rgba(199, 91, 91, .55); }
.ec-preset-group .ec-btn.preset:disabled   { box-shadow: none; }

.ec-status { color: var(--ec-ink-mute); font-size: .9rem; }

/* ---------- score card ---------- */
.ec-score-card {
    display: flex;
    padding: 18px 20px;
    align-items: center;
    gap: 18px;
}
.ec-score-block {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 2px;
}
.ec-score-label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--ec-ink-mute);
    letter-spacing: .04em;
}
.ec-score-value {
    font-family: var(--font-heading);
    font-size: 2.3rem;
    font-weight: 800;
    line-height: 1;
    color: var(--ec-ink);
    letter-spacing: -.02em;
}
.ec-score-scale { color: var(--ec-ink-mute); font-size: .9rem; }
.ec-score-divider {
    width: 1px;
    align-self: stretch;
    background: var(--border-light);
}

.ec-auto-fail {
    background: var(--accent-red-light);
    border: 1px solid var(--border-medium);
    color: var(--ec-bad);
    padding: 12px 14px;
    border-radius: var(--ec-radius-sm);
    font-weight: 600;
    font-size: .95rem;
}
.ec-stub-banner {
    background: rgba(217, 119, 6, .08);
    border: 1px solid rgba(217, 119, 6, .3);
    color: var(--ec-warn);
    padding: 10px 14px;
    border-radius: var(--ec-radius-sm);
    font-size: .88rem;
    line-height: 1.45;
}
.ec-stub-banner strong { color: var(--ec-warn); }
.ec-stub-banner code {
    background: rgba(217, 119, 6, .12);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: ui-monospace, 'SFMono-Regular', monospace;
    font-size: .85em;
    direction: ltr;
    display: inline-block;
}
.hidden { display: none !important; }

/* ---------- drawer ---------- */
.ec-drawer {
    display: flex;
    flex-direction: column;
    min-height: 300px;
    flex: 1;
}
.ec-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 700;
    color: var(--ec-ink-soft);
}
.ec-violation-list {
    padding: 6px;
    overflow-y: auto;
    flex: 1;
}
.ec-empty-state {
    padding: 30px 18px;
    text-align: center;
    color: var(--ec-ink-mute);
    font-size: .95rem;
}

.ec-violation-item {
    border: 1px solid transparent;
    border-radius: var(--ec-radius-sm);
    padding: 12px 14px;
    margin: 4px;
    cursor: pointer;
    background: var(--ec-surface);
    transition: background .12s ease, border-color .12s ease;
}
.ec-violation-item:hover { background: var(--bg-hover); border-color: var(--border-medium); }
.ec-violation-item.open  { background: var(--ec-surface); border-color: var(--ec-accent); box-shadow: var(--shadow-md); }

.ec-violation-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.ec-violation-title { font-weight: 700; color: var(--ec-ink); font-size: .98rem; }

.ec-sev-chip {
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: .03em;
    color: #fff;
    white-space: nowrap;
}
.ec-sev-chip.sev-slight { background: var(--ec-slight); color: #4a3700; }
.ec-sev-chip.sev-medium { background: var(--ec-medium); }
.ec-sev-chip.sev-total  { background: var(--ec-total); }

.ec-violation-meta {
    font-size: .82rem;
    color: var(--ec-ink-mute);
    margin-top: 4px;
    display: flex; gap: 10px; flex-wrap: wrap;
}
.ec-violation-body { margin-top: 10px; display: none; }
.ec-violation-item.open .ec-violation-body { display: block; }

.ec-explanation {
    background: var(--ec-surface-2);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ec-ink-soft);
    font-size: .92rem;
}
.ec-replacement {
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--accent-green-light);
    border: 1px dashed rgba(93, 140, 97, .35);
    border-radius: 8px;
    font-size: .92rem;
}
.ec-replacement .label { font-weight: 700; color: var(--ec-ok); display: block; margin-bottom: 4px; }
.ec-replacement.flow-broken { background: rgba(217, 119, 6, .08); border-color: rgba(217, 119, 6, .35); }
.ec-replacement.flow-broken .label { color: var(--ec-warn); }
.ec-replacement del { color: var(--ec-ink-mute); }
.ec-replacement ins { text-decoration: none; font-weight: 700; color: var(--ec-ok); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
    .ec-layout { grid-template-columns: 1fr; }
}

/* ---------- loading overlay (rotating-phrase variant) ----------
   Shown only while the Vertex evaluation is in flight — typically
   60–120 seconds. The rotating phrases give the user something
   friendly to read instead of staring at a spinner alone. */
.ec-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(30, 24, 16, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}
.ec-loading-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}
.ec-loading-card {
    max-width: 460px;
    width: 100%;
    padding: 36px 32px 30px;
    text-align: center;
    background: var(--ec-surface, #fffdf7);
    border: 1px solid var(--border-light, rgba(61, 57, 41, 0.12));
    border-radius: 18px;
    box-shadow: 0 24px 60px -20px rgba(40, 28, 14, 0.45);
    transform: translateY(8px) scale(0.98);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.ec-loading-overlay.is-visible .ec-loading-card {
    transform: translateY(0) scale(1);
}

/* Triple-ring spinner */
.ec-loading-spinner {
    position: relative;
    width: 68px;
    height: 68px;
    margin: 0 auto 22px;
}
.ec-loading-spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--ec-accent, #a97750);
    animation: ec-spin 1.1s linear infinite;
}
.ec-loading-spinner-ring:nth-child(2) {
    inset: 8px;
    border-top-color: var(--ec-accent-hover, #c49a6a);
    animation-duration: 1.5s;
    animation-direction: reverse;
    opacity: 0.75;
}
.ec-loading-spinner-ring:nth-child(3) {
    inset: 16px;
    border-top-color: var(--ec-slight, #E8AE3D);
    animation-duration: 1.9s;
    opacity: 0.55;
}
@keyframes ec-spin {
    to { transform: rotate(360deg); }
}

.ec-loading-title {
    font-family: var(--font-heading, inherit);
    font-size: 1.2rem;
    font-weight: 650;
    color: var(--ec-ink, #3D3929);
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}
.ec-loading-phrase {
    font-size: 1rem;
    line-height: 1.55;
    color: var(--ec-ink-soft, #6b6354);
    min-height: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    animation: ec-phrase-in 0.4s ease both;
}
@keyframes ec-phrase-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ec-loading-sub {
    margin-top: 18px;
    font-size: 0.82rem;
    color: var(--ec-ink-mute, #9A9080);
    line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
    .ec-loading-overlay,
    .ec-loading-card,
    .ec-loading-phrase { transition: none; animation: none; }
    .ec-loading-spinner-ring { animation-duration: 2s; }
}
