/* common/css/customer_service.css */

.main_content:has(.customer-service) {
    align-items: stretch;
    justify-content: flex-start;
    min-height: 0;
    overflow: hidden;
    padding: var(--base_pad_sm, 4px);
}

.customer-service,
.customer-service * {
    box-sizing: border-box;
}

.customer-service {
    --cs-bg: #f8fafc;
    --cs-panel: #ffffff;
    --cs-line: #dbe3ee;
    --cs-muted: #64748b;
    --cs-text: #0f172a;
    --cs-primary: #2563eb;
    --cs-agent: #059669;
    --cs-danger: #dc2626;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    color: var(--cs-text);
}

.main_content:has(.customer-service.is-guest) {
    overflow-y: auto;
}

.customer-service.is-guest {
    height: auto;
    min-height: 100%;
}


.cs-page-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.cs-page-head.compact {
    margin: 0;
    padding: 12px;
    border-bottom: 1px solid var(--cs-line);
}

.cs-page-head .material-symbols-outlined {
    color: var(--cs-primary);
    font-size: 28px;
}

.cs-page-head h1,
.cs-detail-head h2 {
    margin: 0;
    font-size: 1.25rem;
    letter-spacing: 0;
}

.cs-page-head p,
.cs-detail-head p {
    margin: 3px 0 0;
    color: var(--cs-muted);
    font-size: 13px;
}

.cs-honeypot { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }
.cs-captcha-row { display: flex; align-items: center; gap: 8px; }
.cs-captcha-row img { width: 190px; max-width: calc(100% - 48px); height: 64px; object-fit: contain; border: 1px solid var(--cs-line); border-radius: 7px; background: #fff; }
.cs-captcha-row button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; }

.cs-guest-panel {
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 18px;
    background: var(--cs-panel);
    border: 1px solid var(--cs-line);
    border-radius: 8px;
}

.cs-shell {
    display: grid;
    grid-template-columns: clamp(270px, 24vw, 360px) minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    border: 1px solid var(--cs-line);
    border-radius: 8px;
    background: var(--cs-panel);
    overflow: hidden;
}

.cs-sidebar {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    border-right: 1px solid var(--cs-line);
    background: #fbfdff;
}

.cs-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 10px;
    border-bottom: 1px solid var(--cs-line);
}

.cs-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--cs-muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.cs-tab.active {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: var(--cs-text);
}

.cs-tab .material-symbols-outlined,
.cs-form .material-symbols-outlined,
.cs-category-row .material-symbols-outlined {
    font-size: 18px;
}

.cs-list-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid var(--cs-line);
}

#cs-search { grid-column: 1 / -1; }

.cs-list-tools input,
.cs-list-tools select,
.cs-form input,
.cs-form select,
.cs-form textarea,
.cs-ticket-controls select,
.cs-reply-form textarea,
.cs-category-row input {
    width: 100%;
    border: 1px solid var(--cs-line);
    border-radius: 7px;
    background: #fff;
    color: var(--cs-text);
    font: inherit;
    font-size: 14px;
    padding: 8px 9px;
}

.cs-check {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--cs-muted);
    font-size: 12px;
}

.cs-check input { width: auto; }


.cs-list-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--cs-line);
    background: #f8fafc;
}

.cs-stat {
    display: grid;
    gap: 1px;
    min-width: 0;
    padding: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    text-align: center;
}

.cs-stat b { font-size: 14px; }
.cs-stat small { color: var(--cs-muted); font-size: 10px; text-transform: uppercase; }
.cs-pagination {
    flex: 0 0 auto;
    max-height: 138px;
    overflow: auto;
    padding: 0 8px 8px;
    border-top: 1px solid var(--cs-line);
    background: #fff;
}

.cs-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 8px;
}

.cs-bulk-tools {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--cs-line);
    background: #f8fafc;
}
.cs-bulk-tools select { min-width: 0; padding: 7px 8px; border: 1px solid var(--cs-line); border-radius: 7px; background: #fff; }
.cs-bulk-tools button { justify-self: end; display: inline-flex; align-items: center; gap: 5px; }
#cs-bulk-count { color: var(--cs-muted); font-size: 12px; text-align: right; }

.cs-ticket-row {
    display: grid;
    width: 100%;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: stretch;
    margin-bottom: 7px;
    border: 1px solid var(--cs-line);
    border-radius: 7px;
    background: #fff;
    color: inherit;
    overflow: hidden;
}
.cs-ticket-row:hover { border-color: #93c5fd; }
.cs-ticket-row.active { border-color: #2563eb; background: #eff6ff; box-shadow: inset 3px 0 0 #2563eb; }
.cs-ticket-open {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    min-width: 0;
    padding: 10px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.cs-ticket-select { display: grid; place-items: center; border-right: 1px solid var(--cs-line); cursor: pointer; }
.cs-ticket-select input { position: absolute; opacity: 0; pointer-events: none; }
.cs-ticket-select .material-symbols-outlined { color: #cbd5e1; font-size: 18px; }
.cs-ticket-select input:checked + .material-symbols-outlined { color: #2563eb; font-variation-settings: 'FILL' 1; }
.cs-ticket-select:focus-within { outline: 2px solid #2563eb; outline-offset: -2px; }.cs-row-title { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.cs-row-meta,
.cs-row-date { color: var(--cs-muted); font-size: 12px; }
.cs-row-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.cs-row-tags:empty { display: none; }
.cs-row-tags b {
    padding: 2px 6px;
    border-radius: 999px;
    background: #eef2ff;
    color: #334155;
    font-size: 11px;
    font-weight: 700;
    text-transform: capitalize;
}
.cs-row-tags b.urgent { background: #fee2e2; color: #991b1b; }
.cs-row-tags b.high { background: #ffedd5; color: #9a3412; }
.cs-row-tags b.cs-age.ok { background: #dcfce7; color: #166534; }
.cs-row-tags b.cs-age.warn { background: #fef3c7; color: #92400e; }
.cs-row-tags b.cs-age.breach { background: #fee2e2; color: #991b1b; }
.cs-row-tags b.cs-age.done { background: #e2e8f0; color: #475569; }
.cs-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--cs-primary); }

.cs-workspace {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    background: var(--cs-bg);
    padding: 14px;
}

.cs-panel.hidden,
.hidden { display: none !important; }

.cs-card,
.cs-detail-card,
.cs-category-manager {
    max-width: 980px;
    background: #fff;
    border: 1px solid var(--cs-line);
    border-radius: 8px;
    padding: 14px;
}

.cs-form {
    display: grid;
    gap: 12px;
}

.cs-form label,
.cs-ticket-controls label {
    display: grid;
    gap: 5px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.cs-form button,
.cs-reply-form button {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.cs-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.cs-ticket-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    margin-bottom: 12px;
    border: 1px solid var(--cs-line);
    border-radius: 7px;
    background: #f8fafc;
}

.cs-ticket-controls label { min-width: 150px; }
.cs-ticket-controls .cs-assignee-control { min-width: 190px; }
.cs-ticket-controls .cs-assignee-control select { min-width: 190px; }
.cs-ticket-controls button { align-self: end; display: inline-flex; align-items: center; gap: 5px; min-height: 36px; }

.cs-guest-original {
    padding: 10px;
    margin-bottom: 12px;
    border: 1px solid #bfdbfe;
    border-radius: 7px;
    background: #eff6ff;
}

.cs-messages {
    display: grid;
    gap: 9px;
    margin: 12px 0;
}

.cs-message {
    max-width: 78ch;
    padding: 10px;
    border: 1px solid var(--cs-line);
    border-radius: 8px;
    background: #fff;
}

.cs-message.staff { border-color: #bbf7d0; background: #f0fdf4; }
.cs-message.user { border-color: #bfdbfe; background: #eff6ff; }
.cs-message.system { border-color: #e2e8f0; background: #f8fafc; color: var(--cs-muted); }
.cs-message.internal { border-color: #fde68a; background: #fffbeb; color: #713f12; }

.cs-internal-panel {
    display: grid;
    gap: 9px;
    margin: 12px 0;
    padding: 10px;
    border: 1px dashed #f59e0b;
    border-radius: 7px;
    background: #fffbeb;
}

.cs-internal-panel > header {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #92400e;
    font-size: 13px;
}

.cs-internal-notes {
    display: grid;
    gap: 8px;
}

.cs-internal-empty {
    color: #92400e;
    font-size: 12px;
}

.cs-internal-note-form {
    display: grid;
    gap: 8px;
}

.cs-insights-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--cs-line);
}
.cs-insights-head h2, .cs-insights-head p { margin: 0; }
.cs-insights-head p { margin-top: 3px; color: var(--cs-muted); font-size: 13px; }
.cs-insights-head select { padding: 8px 10px; border: 1px solid var(--cs-line); border-radius: 7px; background: #fff; }
.cs-insights { display: grid; gap: 20px; padding: 20px; }
.cs-insight-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.cs-insight-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.cs-insight-actions span { color: var(--cs-muted); font-size: 12px; }
.cs-insight-metrics article { display: grid; gap: 4px; min-width: 0; padding: 12px; border: 1px solid var(--cs-line); border-radius: 7px; background: #fff; }
.cs-insight-metrics small { color: var(--cs-muted); font-size: 11px; text-transform: uppercase; }
.cs-insight-metrics strong { font-size: 22px; line-height: 1.1; }
.cs-insight-metrics span { color: var(--cs-muted); font-size: 12px; }
.cs-insight-breakdown > header { margin-bottom: 9px; }
.cs-insight-breakdown h3 { margin: 0; font-size: 15px; }
.cs-insight-table { border-top: 1px solid var(--cs-line); }
.cs-insight-row { display: grid; grid-template-columns: minmax(140px, 1.4fr) minmax(100px, 2fr) 90px 75px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--cs-line); font-size: 12px; }
.cs-insight-row > div:first-child { display: grid; gap: 2px; }
.cs-insight-row > div:first-child span, .cs-insight-row > span { color: var(--cs-muted); }
.cs-insight-bar { height: 7px; overflow: hidden; border-radius: 4px; background: #e2e8f0; }
.cs-insight-bar i { display: block; height: 100%; border-radius: inherit; background: #0f766e; }
.cs-rating {
    display: grid;
    gap: 10px;
    margin: 12px 0;
    padding: 12px;
    border: 1px solid var(--cs-line);
    border-radius: 7px;
    background: #f8fafc;
}
.cs-rating fieldset { margin: 0; padding: 0; border: 0; }
.cs-rating legend, .cs-rating > header { margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.cs-rating > header { display: flex; align-items: center; gap: 6px; }
.cs-rating-stars, .cs-rating-display { display: flex; gap: 3px; }
.cs-rating-stars label { cursor: pointer; }
.cs-rating-stars input { position: absolute; opacity: 0; pointer-events: none; }
.cs-rating-stars .material-symbols-outlined, .cs-rating-display .material-symbols-outlined { color: #cbd5e1; font-size: 27px; }
.cs-rating-stars label:has(input:checked) .material-symbols-outlined, .cs-rating-display .material-symbols-outlined.filled { color: #eab308; font-variation-settings: 'FILL' 1; }
.cs-rating-stars label:focus-within { outline: 2px solid #2563eb; outline-offset: 2px; }
.cs-rating textarea { width: 100%; resize: vertical; }
.cs-rating button { justify-self: start; display: inline-flex; align-items: center; gap: 6px; }
.cs-rating-readonly p { margin: 0; color: var(--cs-text); }
.cs-activity {
    margin: 12px 0;
    padding-top: 12px;
    border-top: 1px solid var(--cs-border);
}

.cs-activity > header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: var(--cs-muted);
    font-size: 13px;
}

.cs-activity ol {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cs-activity li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--cs-border);
    font-size: 13px;
}

.cs-activity li div,
.cs-activity li span { display: flex; gap: 8px; align-items: baseline; }
.cs-activity li span,
.cs-activity li small { color: var(--cs-muted); }
.cs-activity li small { white-space: nowrap; }
.cs-internal-note-form button {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.cs-message header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; font-size: 12px; }
.cs-message time { color: var(--cs-muted); }
.cs-message p { margin: 0; line-height: 1.45; }

.cs-reply-form {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.cs-empty {
    padding: 16px;
    color: var(--cs-muted);
    text-align: center;
}
.cs-empty.compact {
    padding: 10px;
    border: 1px solid var(--cs-line);
    border-radius: 7px;
    background: #f8fafc;
}

.cs-detail-empty {
    display: grid;
    place-items: center;
    gap: 8px;
    min-height: 220px;
}

.cs-detail-empty .material-symbols-outlined {
    color: var(--cs-muted);
    font-size: 34px;
}

.cs-form.is-busy {
    opacity: .72;
}

.cs-form.is-busy button {
    cursor: wait;
}

.cs-category-list {
    display: grid;
    gap: 8px;
}

.cs-category-row {
    display: grid;
    grid-template-columns: 140px minmax(160px, 1fr) minmax(200px, 1.4fr) 72px auto auto auto auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--cs-line);
    border-radius: 7px;
    background: #fff;
}

.cs-category-row label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--cs-muted);
    font-size: 12px;
}

.cs-category-row input[type="checkbox"] { width: auto; }

@media (max-width: 760px) {
    .main_content:has(.customer-service) { overflow: auto; }
    .customer-service { height: auto; }
    .cs-shell { grid-template-columns: 1fr; height: auto; overflow: visible; }
    .cs-sidebar { border-right: 0; border-bottom: 1px solid var(--cs-line); }
    .cs-pagination {
    flex: 0 0 auto;
    max-height: 138px;
    overflow: auto;
    padding: 0 8px 8px;
    border-top: 1px solid var(--cs-line);
    background: #fff;
}

.cs-list { max-height: 45vh; }
    .cs-list-tools { grid-template-columns: 1fr; }
    #cs-search { grid-column: auto; }
    .cs-list-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cs-workspace { overflow: visible; }
    .cs-category-row { grid-template-columns: 1fr; }
}
.cs-template-manager {
    max-width: 980px;
    background: #fff;
    border: 1px solid var(--cs-line);
    border-radius: 8px;
    padding: 14px;
}

.cs-template-list {
    display: grid;
    gap: 8px;
}

.cs-template-row {
    display: grid;
    grid-template-columns: minmax(160px, .7fr) minmax(260px, 1.5fr) 72px auto auto;
    gap: 8px;
    align-items: start;
    padding: 8px;
    border: 1px solid var(--cs-line);
    border-radius: 7px;
    background: #fff;
}

.cs-template-row label,
.cs-template-picker label {
    display: grid;
    gap: 5px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.cs-template-row input[type="checkbox"] { width: auto; }
.cs-template-row textarea { min-height: 88px; }

@media (max-width: 760px) {
    .cs-template-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .cs-insight-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cs-insight-row { grid-template-columns: minmax(120px, 1fr) minmax(90px, 1fr); }
    .cs-insight-row > span { text-align: left; }
}
@media (max-width: 520px) {
    .cs-insights-head { align-items: flex-start; padding: 14px; }
    .cs-insights { padding: 14px; }
    .cs-insight-metrics { grid-template-columns: 1fr; }
}
