/* Light Helpdesk — ένα αρχείο CSS, χωρίς εξωτερικές βιβλιοθήκες. */
:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --border: #e1e4e8;
    --border-strong: #c9ced6;
    --text: #1d2430;
    --muted: #5d6878;
    --faint: #8b95a3;
    --accent: #1f4e79;
    --accent-hover: #173b5c;
    --accent-soft: #e8eff6;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --ok: #1a7f4b;
    --ok-soft: #e7f5ee;
    --warn: #9a6400;
    --warn-soft: #fdf3dc;
    --note: #fff8e1;
    --note-border: #f0dc9a;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12161c;
        --surface: #1a2028;
        --surface-2: #161b22;
        --border: #2b333e;
        --border-strong: #3a4452;
        --text: #e4e8ee;
        --muted: #a3adba;
        --faint: #7d8896;
        --accent: #5b9bd5;
        --accent-hover: #7bb0e0;
        --accent-soft: #1e2d3d;
        --danger: #f07167;
        --danger-soft: #3a1f1f;
        --ok: #4cc38a;
        --ok-soft: #173326;
        --warn: #e0b050;
        --warn-soft: #3a2f16;
        --note: #2e2a1a;
        --note-border: #5a4c22;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.inline { display: inline; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
    max-width: 1280px; margin: 0 auto;
    display: flex; align-items: center; gap: 24px;
    padding: 0 16px; min-height: 56px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 22px; height: 22px; border-radius: 6px;
    background: var(--accent);
    box-shadow: inset -7px -7px 0 0 rgba(255,255,255,.25);
}
.brand-sub { color: var(--faint); font-weight: 400; font-size: 13px; border-left: 1px solid var(--border); padding-left: 10px; }
.mainnav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.mainnav a {
    color: var(--muted); padding: 6px 10px; border-radius: 6px; font-weight: 500;
}
.mainnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.mainnav a.active { color: var(--accent); background: var(--accent-soft); }
.userbox { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.lang a { color: var(--faint); font-size: 12px; font-weight: 600; padding: 2px 4px; }
.lang a.on { color: var(--text); }
.username { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbtn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.linkbtn:hover { text-decoration: underline; }

.container { max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; }

/* ---------- Common blocks ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-body { padding: 16px; }
.card-head {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h2 { margin: 0; }
.stack > * + * { margin-top: 16px; }

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.pagehead h1 { margin: 0; }
.pagehead .sub { color: var(--muted); margin-top: 4px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.flash.error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.flash.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 500; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--faint); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=email], input[type=search], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=file] { font: inherit; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.validation, .field-error { color: var(--danger); font-size: 12px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn-ms { background: var(--surface); border-color: var(--border-strong); }
.ms-logo { width: 16px; height: 16px; display: inline-grid; grid-template-columns: 1fr 1fr; gap: 1px; }
.ms-logo i { display: block; }
.ms-logo i:nth-child(1) { background: #f25022; }
.ms-logo i:nth-child(2) { background: #7fba00; }
.ms-logo i:nth-child(3) { background: #00a4ef; }
.ms-logo i:nth-child(4) { background: #ffb900; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { width: 260px; max-width: 100%; }
.filters select { width: auto; min-width: 140px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: block; padding: 12px 16px; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat .n { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
    text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
    text-transform: uppercase; letter-spacing: .03em;
    padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list tr:last-child td { border-bottom: none; }
table.list tr.clickable:hover td { background: var(--surface-2); }
table.list .subj { font-weight: 500; color: var(--text); }
table.list .id { color: var(--faint); font-variant-numeric: tabular-nums; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* ---------- Pills ---------- */
.pill {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
    background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.pill.s-New { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.s-Open { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.s-Pending { background: var(--surface-2); color: var(--muted); }
.pill.s-Resolved { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.s-Closed { background: transparent; color: var(--faint); }
.prio { font-size: 12px; color: var(--muted); white-space: nowrap; }
.prio::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--border-strong); vertical-align: 1px; }
.prio.p-High::before { background: var(--warn); }
.prio.p-Urgent { color: var(--danger); font-weight: 600; }
.prio.p-Urgent::before { background: var(--danger); }
.prio.p-Low::before { background: transparent; border: 1px solid var(--border-strong); }

/* ---------- Ticket view ---------- */
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.ticket-title { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.ticket-title .id { color: var(--faint); font-weight: 400; }

.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.msg-head {
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.msg-head .who { font-weight: 600; }
.msg-head .who .role { font-weight: 400; color: var(--faint); margin-left: 6px; }
.msg-body { padding: 14px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.agent { border-left: 3px solid var(--accent); }
.msg.customer { border-left: 3px solid var(--border-strong); }
.msg.note { background: var(--note); border-color: var(--note-border); border-left: 3px solid var(--warn); }
.msg.note .msg-head { border-bottom-color: var(--note-border); }
.msg-files { padding: 0 14px 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.file {
    display: inline-flex; gap: 6px; align-items: center;
    padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface-2); font-size: 13px; color: var(--text);
}
.file .sz { color: var(--faint); }
.sysmsg { color: var(--faint); font-size: 12px; text-align: center; padding: 2px 0; }
.sysmsg b { color: var(--muted); font-weight: 500; }

.composer { margin-top: 20px; }
.composer .tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.composer .tabs label {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; font-weight: 500; margin: 0; background: var(--surface);
}
.composer .tabs input { margin: 0; }
.composer .tabs label:has(input:checked) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.composer.is-note textarea { background: var(--note); border-color: var(--note-border); }
.composer-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.composer-foot select { width: auto; }

.side .card + .card { margin-top: 16px; }
dl.props { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Login ---------- */
.auth-wrap { max-width: 880px; margin: 40px auto 0; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.auth-grid .card-body { padding: 24px; }
.auth-intro { margin-bottom: 24px; }
.auth-intro h1 { font-size: 24px; }
.center-card { max-width: 440px; margin: 60px auto 0; }

@media (max-width: 900px) {
    .ticket-layout { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .brand-sub { display: none; }
    .topbar-inner { gap: 10px; padding: 8px 16px; }
    .mainnav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
    table.list .hide-sm { display: none; }
}
.mt { margin-top: 12px; }
.mt-lg { margin-top: 20px; }
