/* ===================================================================
   LexBridge CAT — stylesheet
   A calm bilingual translation workbench.
   =================================================================== */

:root {
    /* Surfaces & ink */
    --bg:            #eef1f4;
    --surface:       #ffffff;
    --ink:           #16202c;
    --muted:         #57626f;
    --faint:         #8b95a2;
    --line:          #e2e7ec;
    --line-strong:   #d2d9e0;

    /* Brand — petrol/teal, evokes localization without the usual terracotta */
    --brand:         #0e7c7b;
    --brand-700:     #0a5d5c;
    --brand-50:      #e4f2f1;

    /* Tints to separate the two languages */
    --source-tint:   #f8fafc;
    --target-tint:   #fffdf6;

    /* Status palette (must stay clearly distinct) */
    --pend-ink:  #b45309;  --pend-bg:  #fdf3e3;  --pend-line:  #f1d6a8;
    --trans-ink: #15803d;  --trans-bg: #e9f7ed;  --trans-line: #bce3c6;
    --rev-ink:   #6d28d9;  --rev-bg:   #f0eafb;  --rev-line:   #d6c6f2;
    --danger:    #c0392b;

    /* Type */
    --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    --font-ar:   'Noto Sans Arabic', 'Segoe UI', Tahoma, 'Geeza Pro', sans-serif;
    --font-mono: 'Space Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

    --r:    10px;
    --r-sm: 7px;
    --shadow-sm: 0 1px 2px rgba(20, 30, 45, .06), 0 1px 1px rgba(20, 30, 45, .04);
    --shadow:    0 6px 24px rgba(20, 30, 45, .08), 0 2px 6px rgba(20, 30, 45, .05);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-ui);
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: var(--font-mono);
    font-size: .86em;
    background: #eceff2;
    padding: 1px 6px;
    border-radius: 5px;
}

/* ----------------------------------------------------------- buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-weight: 600;
    line-height: 1;
    padding: 10px 16px;
    border: 1px solid var(--brand);
    background: var(--brand);
    color: #fff;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--brand-700); border-color: var(--brand-700); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--brand-50); outline-offset: 1px; }

.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 7px 11px; font-size: 13px; }

.btn-ghost {
    background: #fff;
    color: var(--ink);
    border-color: var(--line-strong);
}
.btn-ghost:hover { background: #f5f7f9; border-color: var(--line-strong); }

.btn-danger {
    background: #fff;
    color: var(--danger);
    border-color: #e7c3bd;
}
.btn-danger:hover { background: #fcefed; border-color: #e0aaa2; }

.link-danger {
    background: none; border: none; cursor: pointer;
    color: var(--faint); font-size: 14px; padding: 2px 4px;
}
.link-danger:hover { color: var(--danger); }

/* ------------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field-label .opt { font-weight: 400; color: var(--faint); }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

input[type=text], input[type=password], input[type=email],
textarea, select {
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-50);
}
textarea { resize: vertical; line-height: 1.5; }
.hint { font-size: 12px; color: var(--faint); }

.form-inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
.form-inline input { width: auto; flex: 1; min-width: 140px; }

.or-divider {
    display: flex; align-items: center; text-align: center;
    color: var(--faint); font-size: 12px; text-transform: uppercase;
    letter-spacing: .08em; margin: 2px 0;
}
.or-divider::before, .or-divider::after {
    content: ""; flex: 1; height: 1px; background: var(--line);
}
.or-divider span { padding: 0 12px; }

/* ------------------------------------------------------------ alerts */
.alert {
    padding: 12px 16px; border-radius: var(--r-sm);
    margin-bottom: 18px; font-size: 14px;
}
.alert-error {
    background: #fcefed; color: #8c2b1f; border: 1px solid #ecc4bd;
}

/* ------------------------------------------------------------ topbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    max-width: 1080px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px;
}
.brand { display: inline-flex; align-items: baseline; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark {
    font-size: 20px; color: var(--brand); font-weight: 700;
    transform: translateY(2px);
}
.brand-name { font-weight: 700; letter-spacing: -.01em; color: var(--ink); font-size: 18px; }
.brand-sub {
    font-size: 11px; font-weight: 700; letter-spacing: .12em;
    color: #fff; background: var(--brand); padding: 2px 6px; border-radius: 5px;
}
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav a { color: var(--muted); font-weight: 500; }
.topnav .who { color: var(--ink); font-weight: 600; font-size: 14px; }

.page { min-height: calc(100vh - 120px); }

/* --------------------------------------------------------- auth pages */
.auth-wrap {
    min-height: calc(100vh - 60px);
    display: flex; align-items: center; justify-content: center;
    padding: 40px 20px;
}
.auth-card {
    width: 100%; max-width: 380px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r); padding: 32px; box-shadow: var(--shadow);
}
.auth-title { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.auth-lead { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.auth-alt { margin: 18px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.auth-demo {
    margin-top: 20px; padding: 12px 14px; border: 1px dashed var(--line-strong);
    border-radius: var(--r-sm); display: flex; flex-direction: column; gap: 3px;
    font-size: 13px; color: var(--muted); background: #fafbfc;
}
.auth-demo strong { color: var(--ink); }

/* -------------------------------------------------------- containers */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 22px;
}
.h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.breadcrumb {
    font-size: 13px; color: var(--faint); margin-bottom: 14px;
    display: flex; gap: 8px; align-items: center;
}
.breadcrumb a { color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.mt { margin-top: 20px; }

.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r); padding: 22px; box-shadow: var(--shadow-sm);
}
.card-title {
    font-size: 13px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: var(--muted);
    margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.empty { color: var(--faint); font-size: 14px; padding: 8px 0; }

/* --------------------------------------------------------------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px;
}
.list-row:last-child { border-bottom: none; }
.list-main { display: flex; flex-direction: column; gap: 2px; }
.list-main:hover { text-decoration: none; }
.list-title { font-weight: 600; color: var(--ink); }
.list-meta { font-size: 12px; color: var(--faint); }

/* -------------------------------------------------------- mini tables */
.mini-table, .doc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mini-table th, .doc-table th {
    text-align: left; font-size: 11px; text-transform: uppercase;
    letter-spacing: .06em; color: var(--faint); font-weight: 700;
    padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.mini-table td, .doc-table td {
    padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle;
}
.mini-table tr:last-child td, .doc-table tr:last-child td { border-bottom: none; }
.ta-right { text-align: right; }
.tag-global {
    font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--faint); background: #eef1f4; padding: 2px 6px; border-radius: 4px;
}
.mini-table form { display: inline; }

.doc-name { font-weight: 600; }
.chip {
    display: inline-block; font-size: 11px; font-weight: 700;
    letter-spacing: .04em; color: var(--brand-700);
    background: var(--brand-50); padding: 3px 8px; border-radius: 5px;
}
.row-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.row-actions form { display: inline; }

/* --------------------------------------------------- progress bars */
.bar {
    width: 130px; height: 8px; background: #e7ebef;
    border-radius: 99px; overflow: hidden;
}
.bar-fill {
    height: 100%; background: linear-gradient(90deg, var(--brand), #1aa39b);
    border-radius: 99px; transition: width .3s;
}
.bar-label { display: block; font-size: 11px; color: var(--faint); margin-top: 4px; }

.sitefoot {
    text-align: center; color: var(--faint); font-size: 12px;
    padding: 22px; border-top: 1px solid var(--line); background: var(--surface);
}

/* ===================================================================
   EDITOR — the workbench
   =================================================================== */

.editor-body {
    background: var(--bg);
    display: flex; flex-direction: column;
    min-height: 100vh;
}

/* Top bar */
.editor-bar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 24px;
    padding: 10px 20px;
    background: var(--surface); border-bottom: 1px solid var(--line-strong);
    box-shadow: var(--shadow-sm);
}
.eb-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.eb-back {
    width: 34px; height: 34px; border-radius: var(--r-sm);
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line-strong); color: var(--muted);
    font-size: 18px; flex: none;
}
.eb-back:hover { background: #f5f7f9; text-decoration: none; }
.eb-titles { display: flex; flex-direction: column; min-width: 0; }
.eb-doc {
    font-weight: 700; letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}
.eb-pair { font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: .05em; }

.eb-progress { flex: 1; min-width: 160px; }
.prog {
    height: 8px; background: #e7ebef; border-radius: 99px; overflow: hidden;
}
.prog-fill {
    height: 100%; background: linear-gradient(90deg, var(--brand), #1aa39b);
    transition: width .35s;
}
.prog-stats {
    display: flex; gap: 16px; margin-top: 6px;
    font-size: 12px; color: var(--muted);
}
.prog-stats b { color: var(--ink); }
.stat-rev b { color: var(--rev-ink); }
.stat-pend b { color: var(--pend-ink); }
.stat-pct { margin-left: auto; font-weight: 600; }

.eb-right { display: flex; align-items: center; gap: 14px; }

.filters { display: inline-flex; background: #eef1f4; padding: 3px; border-radius: 8px; }
.filter {
    font: inherit; font-size: 12.5px; font-weight: 600;
    border: none; background: none; color: var(--muted);
    padding: 6px 11px; border-radius: 6px; cursor: pointer;
}
.filter:hover { color: var(--ink); }
.filter.is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

.exports { display: inline-flex; gap: 6px; }

.save-indicator { font-size: 12px; color: var(--faint); min-width: 96px; text-align: right; }
.save-indicator.saving  { color: var(--brand-700); }
.save-indicator.saved   { color: var(--trans-ink); }
.save-indicator.editing { color: var(--muted); }
.save-indicator.error   { color: var(--danger); }

/* Column header */
.grid-head {
    display: grid; grid-template-columns: 56px 1fr 1fr;
    gap: 0; position: sticky; top: 55px; z-index: 10;
    background: #f7f9fb; border-bottom: 1px solid var(--line-strong);
    font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--faint); font-weight: 700;
}
.grid-head > div { padding: 9px 16px; }
.gh-num { text-align: center; }
.gh-tgt { direction: rtl; text-align: right; border-left: 1px solid var(--line); }

/* Segment list */
.seg-list { flex: 1; }
.para-break { height: 14px; background: repeating-linear-gradient(
    -45deg, transparent, transparent 6px, #e9edf1 6px, #e9edf1 7px); opacity: .5; }

.seg-row {
    display: grid; grid-template-columns: 56px 1fr 1fr;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    transition: background .12s;
}
.seg-row:hover { background: #fcfdfe; }
.seg-row:focus-within { background: #fbfdff; }

/* Status rail (left edge color) */
.seg-row { border-left: 3px solid transparent; }
.seg-row.status-pending    { border-left-color: var(--pend-line); }
.seg-row.status-translated { border-left-color: var(--trans-line); }
.seg-row.status-reviewed   { border-left-color: var(--rev-line); }

.seg-gutter {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 14px 0; background: #fafbfc; border-right: 1px solid var(--line);
}
.seg-num { font-family: var(--font-mono); font-size: 12px; color: var(--faint); }
.seg-dot { width: 9px; height: 9px; border-radius: 99px; background: var(--pend-line); }
.status-pending    .seg-dot { background: var(--pend-ink); }
.status-translated .seg-dot { background: var(--trans-ink); }
.status-reviewed   .seg-dot { background: var(--rev-ink); }

.seg-source {
    padding: 14px 16px;
    background: var(--source-tint);
    font-size: 15px; line-height: 1.6;
    border-right: 1px solid var(--line);
    white-space: pre-wrap; word-wrap: break-word;
}

.seg-target {
    padding: 10px 16px 12px;
    background: var(--target-tint);
    display: flex; flex-direction: column; gap: 8px;
}
.tgt-input {
    font-family: var(--font-ar);
    font-size: 16px; line-height: 1.7;
    border: 1px solid transparent;
    background: transparent;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    resize: none; overflow: hidden;
    min-height: 40px;
}
.tgt-input:hover { background: #fff; border-color: var(--line); }
.tgt-input:focus {
    background: #fff; border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-50);
}
.tgt-input::placeholder { color: #c4ccd4; }

/* Per-row action bar — quiet until the row is engaged */
.seg-actions {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    opacity: 0; transition: opacity .12s;
}
.seg-row:hover .seg-actions,
.seg-row:focus-within .seg-actions { opacity: 1; }

.mini-btn {
    font: inherit; font-size: 12px; font-weight: 600;
    border: 1px solid var(--line-strong); background: #fff; color: var(--muted);
    padding: 5px 9px; border-radius: 6px; cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.mini-btn:hover { color: var(--ink); border-color: var(--brand); }
.act-confirm:hover { color: var(--trans-ink); border-color: var(--trans-line); background: var(--trans-bg); }
.act-review:hover  { color: var(--rev-ink);   border-color: var(--rev-line);   background: var(--rev-bg); }
.act-suggest:hover { color: var(--brand-700); border-color: var(--brand);       background: var(--brand-50); }

.seg-status-pill {
    margin-left: auto; font-size: 11px; font-weight: 700;
    letter-spacing: .03em; padding: 3px 9px; border-radius: 99px;
    border: 1px solid; 
}
.status-pending    .seg-status-pill { color: var(--pend-ink);  background: var(--pend-bg);  border-color: var(--pend-line); }
.status-translated .seg-status-pill { color: var(--trans-ink); background: var(--trans-bg); border-color: var(--trans-line); }
.status-reviewed   .seg-status-pill { color: var(--rev-ink);   background: var(--rev-bg);   border-color: var(--rev-line); }

.seg-suggest-meta { font-size: 11px; color: var(--faint); font-family: var(--font-mono); }

/* Editor footer */
.editor-foot {
    position: sticky; bottom: 0;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 8px 20px; font-size: 12px; color: var(--faint); text-align: center;
}
kbd {
    font-family: var(--font-mono); font-size: 11px;
    background: #eef1f4; border: 1px solid var(--line-strong);
    border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--muted);
}

/* ----------------------------------------------------- responsive */
@media (max-width: 860px) {
    .grid-2 { grid-template-columns: 1fr; }
    .eb-progress { display: none; }
    .filters { display: none; }
}
@media (max-width: 720px) {
    .grid-head { display: none; }
    .seg-row { grid-template-columns: 40px 1fr; }
    .seg-source { border-right: none; border-bottom: 1px dashed var(--line); }
    .seg-target { grid-column: 2 / 3; }
    .seg-gutter { grid-row: span 2; }
}

/* Accessibility: respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
    html { scroll-behavior: auto; }
}
