/* EnterYourHours Support Ticket System — layout and components per UI_SupportTicket.pdf / UI_Admin.pdf */

:root {
    --eyh-green: #1a7f4e;
    --eyh-green-dark: #156a41;
    --eyh-green-soft: #dff3e6;
    --eyh-green-tint: #f1f9f4;
    --eyh-border: #e1e4e8;
    --eyh-border-strong: #cfd5da;
    --eyh-text: #222;
    --eyh-muted: #6b7378;
    --eyh-bg: #f7f8f9;
    --header-height: 56px;
}

html { font-size: 14px; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--eyh-text);
    background: #fff;
    margin: 0;
}
a { color: var(--eyh-green); }
a:hover { color: var(--eyh-green-dark); }

/* ---------- Header ---------- */
.sts-header {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 18px;
    height: var(--header-height); padding: 0 18px;
    background: #fff; border-bottom: 1px solid var(--eyh-border);
    white-space: nowrap; overflow-x: auto;
}
.sts-brand img { height: 44px; display: block; }
.sts-cta { margin-left: 20px; padding: 7px 16px; font-size: 14px; text-decoration: none; white-space: nowrap; }
.sts-cta:hover { color: #fff; }
.sts-nav a { font-size: 17px; color: #333; text-decoration: none; margin-right: 16px; }
.sts-nav a:hover { color: var(--eyh-green); }
.sts-nav a.active { color: var(--eyh-green); font-weight: 600; }
.sts-identity { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--eyh-border); font-size: 15px; }
.sts-identity .name { font-weight: 600; }
.sts-identity .company { color: #555; }
.badge-plan { background: var(--eyh-green-soft); color: #1a5c38; border-radius: 4px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.sts-filters { margin-left: auto; display: flex; align-items: center; gap: 16px; color: #555; }
.sts-filters .show-label { color: var(--eyh-muted); }
.sts-filters label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 0; }
.sts-filters input[type=checkbox] { accent-color: var(--eyh-green); width: 15px; height: 15px; }
.sts-filters .count { color: #9aa3a8; font-size: 12px; }
.sts-signout { color: var(--eyh-muted); padding: 6px; }

/* ---------- Two-pane shell (customer) ---------- */
.sts-shell { display: flex; height: calc(100vh - var(--header-height)); }
.sts-rail { width: 300px; flex: 0 0 300px; border-right: 1px solid var(--eyh-border); overflow-y: auto; padding: 14px 12px 24px 14px; background: #fff; }
.sts-main { flex: 1; overflow-y: auto; padding: 24px 40px 48px 40px; background: #fff; }
.rail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 600; font-size: 15px; }
.rail-head .count { color: #9aa3a8; font-weight: 400; margin-left: 4px; }
.btn-outline-eyh { border: 1px solid var(--eyh-green); color: var(--eyh-green); background: #fff; border-radius: 4px; padding: 3px 10px; font-weight: 600; text-decoration: none; font-size: 13px; }
.btn-outline-eyh:hover, .btn-outline-eyh.active { background: var(--eyh-green); color: #fff; }
.btn-eyh { background: var(--eyh-green); color: #fff; border: 1px solid var(--eyh-green); border-radius: 4px; padding: 8px 18px; font-weight: 600; font-size: 15px; }
.btn-eyh:hover { background: var(--eyh-green-dark); color: #fff; }
.btn-eyh:disabled { opacity: .5; }

/* Ticket cards in the rail */
.rail-item { margin-bottom: 8px; }
.ticket-card { display: block; border: 1px solid #a9b3ba; border-radius: 6px; padding: 10px 12px; background: #fff; color: inherit; text-decoration: none; }
.ticket-card:hover { border-color: #7f8b93; color: inherit; }
.ticket-card.waiting-customer { background: var(--eyh-green-tint); border-color: #8fc6a4; }
.ticket-card.closed, .ticket-card.archived { background: #dde1e4; border-color: #98a2a9; color: #4a5054; }
.ticket-card.closed .status-text, .ticket-card.archived .status-text { font-weight: 700; color: #333; }
.ticket-card.active { box-shadow: 0 0 0 2px rgba(26, 127, 78, .25); border-color: var(--eyh-green); }
.ticket-card .card-top { display: flex; align-items: center; font-size: 12px; color: var(--eyh-muted); }
.ticket-card .num { color: var(--eyh-green); font-weight: 600; font-size: 13px; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 0 5px 0 8px; background: #b5bdc2; }
.status-dot.waiting-customer { background: #1a9a5a; }
.status-dot.waiting-support { background: #8a9aa0; }
.status-dot.closed, .status-dot.archived { background: #c9cfd3; }
.ticket-card .subject { font-weight: 600; font-size: 15px; line-height: 1.25; margin: 5px 0 6px 0; color: #1d1d1d; }
.ticket-card .meta { display: grid; grid-template-columns: 64px 1fr; gap: 2px 8px; font-size: 12px; color: #333; }
.ticket-card .meta .k { color: #8a9297; }
.chip { display: inline-block; border: 1px solid var(--eyh-border-strong); border-radius: 4px; padding: 7px 9px; font-size: 11px; font-weight: 600; color: #444; background: #fff; margin: 8px 6px 0 0; text-decoration: none; }
.chip:hover { border-color: var(--eyh-green); color: var(--eyh-green); }
.chip.img { background: repeating-linear-gradient(135deg, #e6f3ea 0 3px, #f7fbf8 3px 6px); border-color: #bfe3cc; color: #1a5c38; }
.chip.rejected { border-style: dashed; color: #b04040; text-decoration: line-through; }
.rail-thread { margin: 6px 0 4px 18px; border-left: 2px solid #98a3ab; padding-left: 12px; }
.rail-msg { position: relative; border: 1px solid #b8c1c7; border-radius: 6px; padding: 6px 10px; margin: 6px 0; font-size: 12px; background: #fff; }
.rail-msg::before { content: ""; position: absolute; left: -14px; top: 14px; width: 12px; border-top: 2px solid #98a3ab; }
.rail-msg.staff { border-color: #cfe6d7; }
.rail-msg .head { display: flex; justify-content: space-between; gap: 8px; }
.rail-msg .who { font-weight: 600; color: #555; }
.rail-msg.staff .who { color: var(--eyh-green); }
.rail-msg .when { color: #9aa3a8; }
.rail-msg .snip { color: #333; margin-top: 2px; }
.rail-msg .chip { padding: 5px 7px; margin-top: 6px; }
.rail-divider { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; font-weight: 600; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #6b7378; }
.rail-divider::after { content: ""; flex: 1; border-top: 1px solid #b8c1c7; }
.rail-divider:not(:has(~ .rail-item:not([hidden]))) { display: none; }
.rail-empty { color: var(--eyh-muted); font-size: 13px; padding: 12px 4px; }

/* ---------- Thread (customer and admin) ---------- */
.thread-head { margin-bottom: 18px; }
.thread-head .num { color: var(--eyh-green); font-weight: 600; font-size: 14px; margin-right: 8px; }
.thread-head h1 { font-size: 24px; font-weight: 600; margin: 4px 0 6px 0; }
.thread-meta { color: var(--eyh-muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.thread-meta b { color: #444; font-weight: 600; }
.pill { display: inline-block; border-radius: 4px; padding: 2px 9px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.pill.waiting-support { border: 1px solid var(--eyh-green); color: var(--eyh-green); background: #fff; }
.pill.waiting-customer { background: var(--eyh-green-soft); color: #1a5c38; }
.pill.closed { background: #e9ecef; color: #555; }
.pill.archived { background: #f1f1f1; color: #888; }
.pill.priority-high { background: #fdecec; color: #a93030; }
.pill.priority-low { background: #f1f1f1; color: #666; }
.pill.priority-normal { background: #eef1f3; color: #555; }
.msg { border: 1px solid var(--eyh-border); border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; background: #fff; max-width: 860px; }
.msg.staff { border-left: 3px solid var(--eyh-green); }
.msg.customer { border-left: 3px solid #b9c2c8; }
.msg.internal { background: #fff8e1; border-color: #f0d78c; border-left-color: #e0b84a; }
.msg.system { background: var(--eyh-bg); color: var(--eyh-muted); font-size: 13px; padding: 8px 14px; }
.msg .head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; margin-bottom: 6px; color: var(--eyh-muted); }
.msg .who { font-weight: 600; color: #444; font-size: 13px; }
.msg.staff .who { color: var(--eyh-green); }
.msg .tag { font-size: 11px; border-radius: 3px; padding: 1px 6px; background: #eef1f3; color: #555; margin-left: 6px; }
.msg.internal .tag { background: #f3e2a4; color: #6b5300; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; }
.msg .attachments { margin-top: 6px; }
.msg .attachments .chip { margin-top: 6px; }
.msg details.raw { margin-top: 10px; font-size: 12px; }
.msg details.raw summary { cursor: pointer; color: var(--eyh-muted); }
.msg details.raw pre { background: var(--eyh-bg); border: 1px solid var(--eyh-border); border-radius: 4px; padding: 10px; max-height: 320px; overflow: auto; white-space: pre-wrap; margin-top: 6px; font-size: 12px; }
.reply-box { border: 1px solid var(--eyh-border); border-radius: 6px; padding: 14px; max-width: 860px; margin-top: 18px; background: #fff; }
.reply-box textarea { min-height: 110px; }
.notice { max-width: 860px; margin-top: 18px; padding: 12px 14px; border-radius: 6px; background: var(--eyh-bg); border: 1px solid var(--eyh-border); color: #555; }

/* ---------- Forms (new ticket) ---------- */
.sts-form-card { border: 1px solid var(--eyh-border); border-radius: 6px; padding: 20px 22px; max-width: 640px; background: #fff; }
.sts-lead { color: #555; max-width: 640px; margin-bottom: 18px; }
.form-label { color: #444; margin-bottom: 4px; font-size: 13px; }
.form-control, .form-select { border-color: var(--eyh-border-strong); }
.form-control:focus, .form-select:focus { border-color: var(--eyh-green); box-shadow: 0 0 0 .2rem rgba(26,127,78,.15); }
.seg { display: inline-flex; border: 1px solid var(--eyh-border-strong); border-radius: 4px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 7px 16px; margin: 0; cursor: pointer; border-right: 1px solid var(--eyh-border-strong); color: #333; }
.seg label:last-child { border-right: 0; }
.seg input:checked + label { background: var(--eyh-green); color: #fff; }
.dropzone { border: 1px dashed var(--eyh-border-strong); border-radius: 6px; padding: 12px 14px; color: #666; display: flex; gap: 12px; align-items: center; background: #fafbfc; flex-wrap: wrap; }
.dropzone.drag { border-color: var(--eyh-green); background: var(--eyh-green-tint); }
.dropzone .btn-add { border: 1px solid var(--eyh-border-strong); background: #fff; border-radius: 4px; padding: 6px 12px; color: #333; }
.dropzone .btn-add:hover { border-color: var(--eyh-green); color: var(--eyh-green); }
.file-list { margin-top: 8px; }
.file-list .chip { cursor: default; }
.file-list .chip .rm { margin-left: 8px; color: #999; cursor: pointer; }
.file-list .chip .rm:hover { color: #b04040; }
.sla-line { color: #555; margin-left: 14px; }
.staged-preview { display: flex; gap: 12px; align-items: center; border: 1px solid #bfe3cc; background: var(--eyh-green-tint); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; }
.staged-preview img { max-height: 64px; border-radius: 4px; border: 1px solid var(--eyh-border); }

/* ---------- Admin grid ---------- */
.admin-page { padding: 18px 18px 40px 18px; }
.admin-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.admin-toolbar h1 { font-size: 24px; font-weight: 600; margin: 0 8px 0 0; }
.admin-toolbar .form-control, .admin-toolbar .form-select { width: auto; min-width: 160px; }
.admin-toolbar .search { min-width: 220px; }
.admin-toolbar .shown { margin-left: auto; color: var(--eyh-muted); font-size: 13px; }
.grid-wrap { border: 1px solid var(--eyh-border); border-radius: 6px; overflow: auto; background: #fff; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.grid th { position: sticky; top: 0; background: #f7f8f9; border-bottom: 1px solid var(--eyh-border); padding: 10px 12px; text-align: left; font-weight: 600; white-space: nowrap; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid #eef0f2; white-space: nowrap; vertical-align: middle; }
table.grid tr.trow { cursor: pointer; }
table.grid tr.trow:hover td { background: #f7fbf8; }
table.grid td.num a { color: var(--eyh-green); font-weight: 600; text-decoration: none; }
table.grid td.subject { white-space: normal; min-width: 240px; }
table.grid td.company { color: #666; }
table.grid td.requestor.admin { font-weight: 600; }
table.grid .col-hidden { display: none; }
table.grid tfoot td { background: #f7f8f9; font-weight: 600; color: #444; }
.col-menu { min-width: 200px; padding: 8px 12px; }
.col-menu label { display: flex; gap: 8px; align-items: center; padding: 3px 0; cursor: pointer; margin: 0; font-size: 13px; }

/* ---------- Admin ticket ---------- */
.admin-ticket { display: flex; gap: 24px; padding: 20px 24px 48px 24px; align-items: flex-start; }
.admin-ticket .thread { flex: 1; min-width: 0; }
.admin-ticket .side { width: 300px; flex: 0 0 300px; position: sticky; top: calc(var(--header-height) + 16px); }
.side-card { border: 1px solid var(--eyh-border); border-radius: 6px; padding: 14px; background: #fff; margin-bottom: 14px; }
.side-card h6 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--eyh-muted); margin-bottom: 10px; }
.side-card .kv { display: grid; grid-template-columns: 90px 1fr; gap: 4px 8px; font-size: 13px; }
.side-card .kv .k { color: #8a9297; }
.side-card .form-label { font-size: 12px; margin-top: 8px; }
.reply-mode { display: flex; gap: 14px; margin-bottom: 8px; font-size: 13px; }
.reply-mode label { display: inline-flex; gap: 6px; align-items: center; margin: 0; cursor: pointer; }
.reply-box.internal-mode { background: #fff8e1; border-color: #f0d78c; }

/* ---------- Misc ---------- */
.sts-panel { border: 1px solid var(--eyh-border); border-radius: 6px; padding: 22px 24px; background: #fff; }
.page-pad { padding: 20px 24px 48px 24px; }
.page-pad h1 { font-size: 24px; font-weight: 600; }
.table-sm td, .table-sm th { vertical-align: middle; }
.text-eyh { color: var(--eyh-green) !important; }
.flash { max-width: 860px; }
code.inline { background: var(--eyh-bg); border: 1px solid var(--eyh-border); border-radius: 3px; padding: 1px 5px; font-size: 12px; }
.dev-banner { background: #fff3cd; border-bottom: 1px solid #ffe69c; color: #664d03; padding: 6px 18px; font-size: 13px; }

@media (max-width: 900px) {
    .sts-shell { flex-direction: column; height: auto; }
    .sts-rail { width: auto; flex: none; border-right: 0; border-bottom: 1px solid var(--eyh-border); max-height: 40vh; }
    .sts-main { padding: 18px; }
    .admin-ticket { flex-direction: column; }
    .admin-ticket .side { width: auto; flex: none; position: static; }
}

/* Image attachment viewer */
.sts-viewer { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: rgba(20, 24, 28, .78); padding: 24px; }
.sts-viewer.show { display: flex; }
.sts-viewer-box { display: flex; flex-direction: column; max-width: min(1200px, 96vw); max-height: 94vh; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.sts-viewer-bar { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-bottom: 1px solid var(--eyh-border); }
.sts-viewer-bar .name { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sts-viewer-bar .dl { padding: 6px 14px; font-size: 13px; text-decoration: none; }
.sts-viewer-bar .close { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--eyh-muted); cursor: pointer; padding: 0 4px; }
.sts-viewer-bar .close:hover { color: var(--eyh-text); }
.sts-viewer img { display: block; max-width: 100%; max-height: calc(94vh - 56px); object-fit: contain; background: #f0f2f4; margin: 0 auto; }
.sts-viewer-open { overflow: hidden; }
.chip[data-href] { cursor: pointer; }
