/* HiTechCloud portal — support pages (tickets, knowledge base, announcements, downloads, network status).
   Uses the tokens and components of portal.css; page-specific rules only. */

/* ---- Status filter: main.js [data-sorter] toggles .active on the <li>, so the pill lives on the li ---- */
.cm-seg.cm-seg--li { margin: 0; list-style: none; }
.cm-seg.cm-seg--li > li { display: flex; border-radius: 8px; }
.cm-seg.cm-seg--li > li.active { background: var(--surface); box-shadow: 0 0 0 1px rgb(0 0 0 / 0.04), 0 1px 2px rgb(0 0 0 / 0.06); }
.cm-seg.cm-seg--li > li.active > a { color: var(--foreground) !important; }
html.darkmode .cm-seg.cm-seg--li > li.active { background: var(--secondary-hover); box-shadow: none; }

/* Sortable column headers */
.cm-sort { display: inline-flex; align-items: center; gap: 4px; color: var(--muted) !important; text-decoration: none !important; white-space: nowrap; }
.cm-sort:hover { color: var(--foreground) !important; }
.cm-sort .cm-i { width: 14px; height: 14px; opacity: .7; }

/* Ticket list rows */
.cm-tickets .cm-td-main a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52ch; }
.cm-tickets td { white-space: nowrap; }
.cm-tickets td:first-child { white-space: normal; width: 100%; min-width: 0; }
.cm-tickets .cm-td-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52ch; }
@media (max-width: 575.98px) {
  .cm-tickets .cm-td-main a, .cm-tickets .cm-td-sub { max-width: none; white-space: normal; overflow-wrap: anywhere; }
  .cm-tickets td { white-space: normal; }
  .cm-tickets tr { display: flex !important; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
  .cm-app .cm-tickets.cm-stack-sm td { width: auto; }
  .cm-app .cm-tickets.cm-stack-sm tbody tr + tr { border-top: 1px solid var(--border); }
  .cm-app .cm-tickets.cm-stack-sm td:first-child { flex: 1 1 100%; width: 100%; }
  .cm-app .cm-tickets td.cm-ticket-date { margin-left: auto; text-align: right !important; color: var(--muted); font-size: 13px; }
  .cm-app .cm-tickets td.cm-ticket-date::before { content: none !important; }
  .cm-app .cm-tickets td[data-label]::before { content: none; }
}

/* Pagination inside a table footer (components/pagination.tpl markup) */
.cm-table-foot .d-flex.mt-4 { margin: 0 !important; }
.cm-table-foot .pagination .page-item-left .page-link,
.cm-table-foot .pagination .page-item-right .page-link { gap: 4px; padding: 0 10px; }
.cm-table-foot .pagination .material-icons { font-size: 16px; }

/* ---- Ticket view ---- */
.cm-ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; font-size: 14px; color: var(--muted); }
.cm-ticket-meta .cm-sep { width: 3px; height: 3px; border-radius: 9999px; background: currentColor; opacity: .6; }
.cm-ticket-actions form { display: inline-flex; margin: 0; }

.cm-thread { list-style: none; margin: 0; padding: 0; }
.cm-msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 20px; }
.cm-msg + .cm-msg { border-top: 1px solid var(--border); }
.cm-msg__avatar { width: 32px; height: 32px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; text-transform: uppercase; background: var(--neutral-bg); color: var(--neutral); overflow: hidden; }
.cm-msg__avatar img { width: 100%; height: 100%; object-fit: cover; }
.cm-msg--staff .cm-msg__avatar { background: var(--primary-light); color: var(--primary-strong); }
.cm-msg--staff { background: color-mix(in srgb, var(--primary) 3%, var(--surface)); }
.cm-msg__head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 32px; }
.cm-msg__name { font-size: 14px; font-weight: 500; }
.cm-msg__role { font-size: 12px; font-weight: 500; color: var(--primary); }
.cm-msg__time { font-size: 12px; color: var(--muted); }
.cm-msg__tools { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.cm-msg__body { margin: 4px 0 0; max-width: 75ch; font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; word-break: break-word; }
.cm-msg__body p { margin: 0 0 8px; }
.cm-msg__note { margin-top: 8px; font-size: 12px; color: var(--warning); }
.cm-msg__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 12px; font-size: 13px; color: var(--muted); }
@media (max-width: 575.98px) {
  .cm-msg { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .cm-msg__avatar { display: none; }
}

/* Attachments (hbfiles markup is enhanced by photoswipe.js) */
.cm-msg .hbfiles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cm-msg .hbfile { display: flex; align-items: center; gap: 8px; max-width: 280px; padding: 6px 8px 6px 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.cm-msg .hbfile-placeholder-box { width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--item-hover); overflow: hidden; }
.cm-msg .hbfile-placeholder-box img { max-width: 100%; max-height: 100%; }
.cm-msg .hbfile-control { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cm-msg .hbfile-title { min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-msg .hbfile-download { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-width: 32px; min-height: 32px; border-radius: var(--radius-sm); color: var(--muted); }
.cm-msg .hbfile-download:hover { background: var(--button-hover); color: var(--foreground); }

/* Rating stars rendered by the legacy rating plugin */
.cm-msg .rating-box { display: inline-flex; }

/* ---- Composer (reply / new ticket) ---- */
.cm-composer textarea.form-control { min-height: 140px; }
.cm-upload { border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.cm-upload #dropzone { display: none; }
.cm-upload .fileupload-buttonbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 16px; }
.cm-upload .fileinput-button { position: relative; display: inline-flex; align-items: center; gap: 8px; overflow: hidden; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--foreground); }
.cm-upload .fileinput-button input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 100px; }
.cm-upload__hint { font-size: 12px; color: var(--muted); }
.cm-upload .bordered-section { margin: 0 16px 12px !important; }
.cm-upload .table-files td { padding: 8px 12px; font-size: 13px; }
.cm-composer__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* New ticket form column */
.cm-form-narrow { max-width: none; }
.cm-dept-hint small { display: block; margin-top: 6px; font-size: 12px; color: var(--muted) !important; }
.cm-captcha { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.cm-captcha img { height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); }
.cm-captcha .form-control { max-width: 200px; }

/* KB hints shown under the message box (ajax.tickets.tpl action=kbhint) */
#hintarea:empty { display: none; }

/* ---- Rating page ---- */
.cm-rating-faces { display: flex; gap: 8px; }
.cm-rating-faces .rating-icon { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 13px; color: var(--foreground); }
.cm-rating-faces .rating-icon:hover { background: var(--button-hover); }
.cm-rating-faces .rating-icon .cm-i { width: 24px; height: 24px; }

/* ---- Knowledge base / announcements / downloads ---- */
.cm-kb-search { position: relative; max-width: 640px; }
.cm-kb-search .cm-i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); z-index: 1; color: var(--muted); pointer-events: none; }
.cm-app .cm-kb-search .form-control { padding-left: 40px !important; padding-right: 110px !important; height: 44px !important; }
.cm-kb-search .btn { position: absolute; right: 4px; top: 4px; min-height: 36px !important; }
.cm-cards-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
@media (min-width: 992px) { .cm-cards-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1600px) { .cm-cards-2--wide { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cm-row .cm-row__chev { color: var(--muted); flex-shrink: 0; }
.cm-row__thumb { width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--radius-sm); object-fit: cover; }

.cm-article { max-width: none; font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.cm-article h1, .cm-article h2, .cm-article h3, .cm-article h4 { margin: 1.4em 0 .5em; }
.cm-article h2 { font-size: 18px; } .cm-article h3 { font-size: 16px; }
.cm-article p, .cm-article ul, .cm-article ol { margin: 0 0 1em; }
.cm-article img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.cm-article pre, .cm-article code { font-size: 13px; background: var(--item-hover); border-radius: 6px; }
.cm-article pre { padding: 12px 14px; overflow-x: auto; }
.cm-article code { padding: 1px 5px; color: inherit; }
.cm-article table { width: 100%; display: block; overflow-x: auto; border-collapse: collapse; font-size: 14px; }
.cm-article table td, .cm-article table th { padding: 8px 10px; border: 1px solid var(--border); }
.cm-article a { text-decoration: underline; text-underline-offset: 2px; }
.cm-news-item { display: block; padding: 16px 20px; color: var(--foreground) !important; text-decoration: none !important; }
.cm-news-item + .cm-news-item { border-top: 1px solid var(--border); }
.cm-news-item:hover { background: var(--surface-hover); }
.cm-news-item__title { margin: 6px 0 4px; font-size: 15px; font-weight: 600; line-height: 1.45; }
.cm-news-item__text { margin: 0; max-width: 75ch; font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cm-news-item__meta { font-size: 13px; color: var(--muted); }
#knowledgebase_vote { margin-top: 24px; }

/* ---- Network status ---- */
.cm-netstat td, .cm-netstat th { text-align: center; }
.cm-netstat td:first-child, .cm-netstat th:first-child { text-align: left; }
.cm-netstat .cm-ok { color: var(--success); }
.cm-netstat .cm-down { color: var(--error-strong); }
.cm-netstat .loader-icon { background: none !important; display: inline-block; width: 14px; height: 14px; border-radius: 9999px; border: 2px solid var(--border-strong); border-top-color: var(--muted); animation: cm-spin .8s linear infinite; }
@keyframes cm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cm-netstat .loader-icon { animation: none; } }
.cm-composer__foot .btn { margin: 0 !important; }
