/*
 * CCloud look for osTicket pages.
 *
 * Loaded last, from ajax.php/ceritek/theme.css, so these rules win over
 * theme.css (customer portal) and scp.css (staff panel). The HTML stays
 * osTicket's: this file only changes type, colour, and the shape of the
 * pieces that are already there.
 *
 * Tokens match CCloud admin (ctk-display apps/admin/src/styles.css).
 */

:root {
  --bg: #ffffff;
  --muted-bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #151e2e;
  --body: #475569;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warning: #d97706;
  --radius: 12px;
  --radius-btn: 8px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 1px 2px rgba(21, 30, 46, 0.04), 0 1px 3px rgba(21, 30, 46, 0.06);
  --shadow-pop: 0 8px 24px rgba(21, 30, 46, 0.12);
}

/* --- Page -------------------------------------------------------------- */

html,
body {
  background: var(--bg);
  color: var(--body);
  font-family: "Satoshi", system-ui, sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

/* The fading grid under the top of a CCloud page. Behind the content. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  height: 520px;
  pointer-events: none;
  z-index: -1;
  background-image:
    linear-gradient(to right, rgba(226, 232, 240, 0.6) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(226, 232, 240, 0.6) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent);
}

/* The page surface. Width is set in ccloud-layout.css. */
#container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

/* --- Type -------------------------------------------------------------- */

body,
input,
select,
textarea,
button {
  font-family: "Satoshi", system-ui, sans-serif;
}

h1,
h2,
h3,
h4,
h2.subject,
.subject {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
}

a,
.link {
  color: var(--primary);
  text-decoration: none;
}

a:hover,
.link:hover {
  border-bottom: none;
  margin-bottom: 0;
  text-decoration: underline;
}

/* Nav and tabs keep a quiet hover: no underline on the bar itself. */
#nav a:hover,
#sub_nav a:hover,
#header a:hover {
  text-decoration: none;
}

.Icon {
  color: var(--primary);
}

#footer,
#footer a,
.faded {
  color: var(--muted);
}

/* --- Header and navigation --------------------------------------------- */

#header {
  height: auto;
  min-height: 64px;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: none;
}

/* Staff welcome line is a grey box in scp.css. Flatten it. */
#header p {
  background: transparent;
  border: none;
  color: var(--muted);
  box-shadow: none;
}

/* Staff welcome links are orange in scp.css (div#header a). */
div#header a {
  color: var(--primary);
}

/*
 * Customer portal: #nav.flush-left. Quiet pills. The icon stays; only the
 * chip around it changes. The current page is a light blue chip.
 */
#nav.flush-left {
  height: auto;
  margin: 0 20px;
  padding: 10px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}

#nav.flush-left li a {
  height: auto;
  line-height: 1.4;
  padding: 6px 12px 6px 32px;
  border-radius: 999px;
  color: var(--body);
  background-color: transparent;
}

#nav.flush-left li a.active,
#nav.flush-left li a:hover {
  background-color: color-mix(in srgb, var(--primary) 8%, white);
  color: var(--primary);
  border-bottom: none;
}

/* Staff panel tabs and the bar under them: see ccloud-staff-bars.css. */

/*
 * Buttons, fields, lists, alerts and the staff sign-in card.
 * Sent together with ccloud-theme.css as ajax.php/ceritek/theme.css.
 * Kept in its own file so each stylesheet stays short enough to read.
 */

/* --- Buttons ----------------------------------------------------------- */

/*
 * Secondary: white, hairline border. Primary (a submit, or the green
 * "add" button) is CCloud blue. The customer portal paints every .button
 * green; submits there become blue, resets stay white.
 */
body input[type="button"],
body input[type="reset"],
body .action-button,
body .button,
body .btn {
  box-sizing: border-box;
  height: auto;
  line-height: 1.4;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  background-image: none;
  box-shadow: none;
  text-shadow: none;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  /* osTicket sets .action-button colour with !important. */
  color: var(--text) !important;
}

body input[type="button"]:hover,
body input[type="reset"]:hover,
body .action-button:hover,
body .button:hover,
body .btn:hover {
  background: var(--muted-bg);
  background-image: none;
  border-color: #cbd5e1;
  color: var(--text);
  box-shadow: none;
}

body input[type="submit"],
body button[type="submit"],
body .primary.button,
body .green.button,
body .green.button:visited,
body .blue.button,
body .blue.button:visited {
  box-sizing: border-box;
  height: auto;
  line-height: 1.4;
  padding: 8px 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-btn);
  background: var(--primary);
  background-image: none;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
  text-shadow: none;
  font-family: inherit;
  font-weight: 500;
  color: #fff !important;
}

body input[type="submit"]:hover,
body button[type="submit"]:hover,
body .primary.button:hover,
body .green.button:hover,
body .blue.button:hover {
  background: var(--primary-hover);
  background-image: none;
  border-color: var(--primary-hover);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

/* Remove stays red, so it is not mistaken for the blue action. */
body .red.button,
body .red.button:visited,
body .red.button span {
  background: var(--surface);
  background-image: none;
  border-color: var(--danger);
  color: var(--danger) !important;
  box-shadow: none;
}

body .red.button:hover {
  background: #fef2f2;
  background-image: none;
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: none;
}

body .link.button,
body .link.button:hover,
body .link.button:active {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--primary) !important;
  padding: 0;
}

body .button:disabled,
body .action-button:disabled,
body button[type="submit"]:disabled,
body input[type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

/* A button glued to a search box keeps the flat right-hand end. */
body .button.attached,
body .action-button.attached {
  padding: 0 9px;
  border-radius: 0 var(--radius-btn) var(--radius-btn) 0;
}

/*
 * Icon buttons (.action-button), mostly on a staff ticket. Every one has
 * the same 34px height and the icon sits in the middle. Some hold a
 * second part: the icon inside a span or link, and a small arrow that
 * opens a menu. Those inner parts get no border of their own, so the
 * button reads as one box with a thin line before the arrow.
 */
body .action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  vertical-align: middle;
}

body .action-button span,
body .action-button a {
  float: none;
  display: inline-flex;
  align-items: center;
  /* Space between an icon and its word ("Sort"), lost in a flex box. */
  gap: 6px;
  height: auto;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  color: inherit !important;
}

/* osTicket draws an inner line on quiet buttons (Filter, Sort). */
body .action-button.muted {
  box-shadow: none;
}

body .action-button i {
  margin: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--text);
}

/* The arrow goes after the icon, behind a thin divider. */
body .action-button i.icon-caret-down {
  order: 2;
  float: none;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  height: auto;
  margin: 0 -2px 0 2px;
  padding: 0 0 0 8px;
  border-left: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

body .action-button:hover i.icon-caret-down {
  border-color: #cbd5e1;
  color: var(--text);
}

/* --- Fields ------------------------------------------------------------ */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="number"],
textarea,
select {
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

/* Text boxes only: a button inside these forms keeps its own colours. */
#ticketForm div input:not([type="submit"]):not([type="button"]):not([type="reset"]),
#clientLogin div input:not([type="submit"]):not([type="button"]):not([type="reset"]),
#ticketForm div textarea,
#clientLogin div textarea,
#ticketForm td textarea,
#clientLogin td textarea,
#reply input[type="text"],
#reply textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
}

#clientLogin input[type="text"],
#clientLogin input[type="password"] {
  padding: 8px 10px;
}

/*
 * osTicket paints every input in these forms white
 * (theme.css: "#clientLogin div input { background: #fff }"), which is
 * stronger than the button rule above. Put the blue button back.
 */
#clientLogin div input[type="submit"],
#ticketForm div input[type="submit"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff !important;
}

#clientLogin div input[type="submit"]:hover,
#ticketForm div input[type="submit"]:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* The sign-in card on the customer portal. The lock picture goes away. */
#clientLogin {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

#reply {
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#reply h2 {
  border-bottom: 1px solid var(--border);
}

/* --- Lists ------------------------------------------------------------- */

table.list,
#ticketTable {
  background: var(--surface);
  border-color: var(--border);
}

table.list caption,
#ticketTable caption {
  background: var(--muted-bg);
  color: var(--text);
  border-color: var(--border);
  font-weight: 600;
}

table.list thead th,
#ticketTable th {
  height: auto;
  line-height: 1.4;
  background: var(--muted-bg);
  color: var(--body);
  font-weight: 600;
  border-color: var(--border);
}

table.list th a,
#ticketTable th a,
table.list thead th a {
  color: var(--body);
}

table.list thead th a.asc,
table.list thead th a.desc {
  background-color: color-mix(in srgb, var(--primary) 10%, white);
  color: var(--primary);
}

table.list tbody td,
#ticketTable td {
  background: var(--surface);
  border-color: var(--border);
  padding: 10px 12px;
}

table.list tbody tr:nth-child(2n+1) td,
#ticketTable tr.alt td {
  background: var(--surface);
}

table.list tbody tr:hover td,
table.list tbody tr:nth-child(2n+1):hover td,
table.list tbody tr.highlight td,
#ticketTable tr:hover td {
  background: color-mix(in srgb, var(--primary) 4%, white);
}

.infoTable {
  background: var(--muted-bg);
}

/* --- Alerts ------------------------------------------------------------ */

/*
 * background-color only: the small icon from osTicket's own stylesheet
 * stays. The loud green, orange and red fills become the soft CCloud ones.
 */
#msg_notice,
.notice_bar,
#notice_bar,
.success-banner,
.notice-banner {
  height: auto;
  line-height: 1.4;
  border-color: #bbf7d0;
  border-radius: var(--radius-btn);
  background-color: #f0fdf4;
  color: #166534;
}

#msg_warning,
.warning_bar,
#warning_bar,
.warning-banner {
  height: auto;
  line-height: 1.4;
  border-color: #fde68a;
  border-radius: var(--radius-btn);
  background-color: #fffbeb;
  color: #92400e;
}

#msg_error,
.error_bar,
#error_bar,
.error-banner {
  height: auto;
  line-height: 1.4;
  border-color: #fecaca;
  border-radius: var(--radius-btn);
  background-color: #fef2f2;
  color: #991b1b;
}

#msg_info,
.info-banner {
  border-color: #bfdbfe;
  border-radius: var(--radius-btn);
  background-color: #eff6ff;
  color: #1e40af;
}

/* --- Staff sign-in ----------------------------------------------------- */

/*
 * The photo behind the staff sign-in (#brickwall, and the blurred copy
 * inside the box) gives way to the same white grid as the other pages.
 * The box itself becomes a CCloud card.
 */
#brickwall,
#background {
  background-image: none;
  background-color: transparent;
}

#loginBox {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}

#loginBox:after {
  display: none;
}

#loginBox h3,
#login-message {
  color: var(--muted);
  font-weight: 500;
}

#loginBox fieldset input {
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  padding: 8px 10px;
}

#poweredBy {
  color: var(--muted);
}

/*
 * The bigger page pieces: settings forms, the ticket summary, the
 * conversation, tabs, popups and the bar that sticks to the top.
 * Sent together with the other ccloud-*.css files as
 * ajax.php/ceritek/theme.css (see lib/Theme.php).
 *
 * Only colours, borders and corners change here. Widths live in
 * ccloud-layout.css.
 */

/* --- Settings and edit forms (staff) ----------------------------------- */

/* The outer lines of a form were grey; they become the CCloud hairline. */
.form_table {
  border-left-color: var(--border);
  border-right-color: var(--border);
}

.form_table td {
  border-bottom-color: var(--border);
}

/* A section title row: was a grey bar with white text, now a soft band. */
.form_table th,
div.section-break {
  background: var(--muted-bg);
  border-color: var(--border);
  color: var(--text);
}

.form_table th h4 {
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

/* The help line under a section title. */
.form_table th em {
  color: var(--muted);
}

.table tr.header td,
.table tr.header th {
  background: var(--muted-bg);
  color: var(--text);
  border-color: var(--border);
}

/* --- Ticket summary (the two boxes above the conversation) -------------- */

.ticket_info,
#ticketInfo .infoTable {
  background: var(--muted-bg);
  border-radius: var(--radius-btn);
}

.ticket_info th,
#ticketInfo .infoTable th {
  color: var(--muted);
  font-weight: 500;
}

.ticket_info.custom-data thead th {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

/* --- Conversation ------------------------------------------------------ */

/*
 * Each message is a small card: a tinted top line and a white body.
 *   customer message  -> light blue
 *   staff reply       -> light grey
 *   internal note     -> light amber
 *   system event      -> light grey
 * The little arrow beside an avatar takes the same colours. Its outline
 * is :before and its fill is :after. Staff and customer pages put the
 * arrow on different sides, so both side colours are set: the side that
 * has no border simply ignores it.
 */
.thread-entry .header {
  border-radius: var(--radius-btn) var(--radius-btn) 0 0;
  color: var(--body);
}

.thread-entry .thread-body {
  border-color: var(--border);
  border-bottom-width: 1px;
  border-radius: 0 0 var(--radius-btn) var(--radius-btn);
  background: var(--surface);
}

.thread-entry.message .header {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.thread-entry.response .header,
.thread-entry.system .header {
  background: var(--muted-bg);
  border-color: var(--border);
}

.thread-entry.note .header {
  background: #fffbeb;
  border-color: #fde68a;
}

.thread-entry.avatar.message .header:before {
  border-left-color: #bfdbfe;
  border-right-color: #bfdbfe;
}

.thread-entry.avatar.message .header:after {
  border-left-color: #eff6ff;
  border-right-color: #eff6ff;
}

.thread-entry.avatar.response .header:before {
  border-left-color: var(--border);
  border-right-color: var(--border);
}

.thread-entry.avatar.response .header:after {
  border-left-color: var(--muted-bg);
  border-right-color: var(--muted-bg);
}

.thread-entry.avatar.note .header:before {
  border-left-color: #fde68a;
  border-right-color: #fde68a;
}

.thread-entry.avatar.note .header:after {
  border-left-color: #fffbeb;
  border-right-color: #fffbeb;
}

/* The file list under a message. */
.thread-body .attachments {
  background-color: var(--muted-bg);
  border-top: 1px solid var(--border);
}

/* --- Tabs (ticket reply / note, user and settings pages) --------------- */

/*
 * Old look: raised grey folder tabs. New look: plain words on a line,
 * the open tab in blue with a short blue line under it (like CCloud).
 */
ul.tabs {
  height: auto;
  padding: 0;
  background: transparent;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}

ul.tabs li,
ul.tabs li:not(.active),
ul.tabs li.active,
ul.tabs.clean li.active {
  height: auto;
  min-width: 0;
  bottom: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

ul.tabs li a {
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 500;
}

ul.tabs li.active {
  box-shadow: inset 0 -2px 0 var(--primary);
}

ul.tabs li.active a {
  color: var(--primary);
  font-weight: 600;
}

/* --- Popups ------------------------------------------------------------ */

.dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(21, 30, 46, 0.25);
}

/* Inside a popup the filled table cells were grey; keep them light. */
.dialog .table td:not(:empty) {
  background-color: var(--muted-bg) !important;
}

/* The dark layer behind a popup. osTicket sets how see-through it is. */
#overlay {
  background: var(--text);
}

/* --- Bar that sticks to the top while scrolling a ticket -------------- */

.sticky.bar.fixed {
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.scroll-up {
  background-color: var(--muted-bg);
  border: 1px solid var(--border);
  border-top: none;
}

/*
 * Staff panel bars: the tabs along the top (Dashboard, Users, Tickets…),
 * the bar of links under them (Open, My Tickets, Closed…), the title bar
 * of a page with its buttons, and the search bar above a ticket list.
 * Sent together with the other ccloud-*.css files as
 * ajax.php/ceritek/theme.css (see lib/Theme.php).
 *
 * osTicket locks both bars at 26px tall. Here they size to their
 * content, like the CCloud admin header.
 *
 * The customer portal also has a #nav, but with the class .flush-left.
 * It is styled in ccloud-theme.css, so every #nav rule here skips it.
 */

/* --- Top tabs ---------------------------------------------------------- */

/* One row of tabs; they wrap onto a second row on a narrow window. */
#nav:not(.flush-left) {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 4px;
  height: auto;
  margin: 0;
  padding: 0 24px;
  line-height: 1.4;
  white-space: normal;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border);
}

/* Each tab. osTicket drew a folder tab with a shadow; this is flat. */
#nav:not(.flush-left) > li,
#nav:not(.flush-left) > li.active,
#nav:not(.flush-left) > li.inactive,
#nav:not(.flush-left) > li.inactive:hover {
  display: block;
  height: auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#nav:not(.flush-left) > li > a {
  display: block;
  padding: 14px 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

#nav:not(.flush-left) > li.inactive:hover > a {
  color: var(--text);
}

/* The open tab: blue words with a blue line along its bottom edge. */
#nav:not(.flush-left) > li.active {
  box-shadow: inset 0 -2px 0 var(--primary);
}

#nav:not(.flush-left) > li.active > a {
  color: var(--primary);
  font-weight: 600;
}

/* The small menu that opens under a tab on hover. */
#nav:not(.flush-left) li.inactive > ul {
  top: 100%;
  left: 0;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-pop);
}

#nav:not(.flush-left) .inactive li a {
  border-radius: 6px;
  color: var(--body);
}

#nav:not(.flush-left) .inactive li a:hover {
  color: var(--primary);
  background-color: var(--muted-bg);
}

/* --- The bar under the tabs -------------------------------------------- */

/*
 * Most pages: a plain list of links (#sub_nav).
 * Tickets page: the same list sits inside #customQ_nav, where osTicket's
 * script moves the links that do not fit into a "more" menu on the
 * right. That script needs the bar to have a fixed height, so it gets
 * one (52px) instead of "auto".
 */
#sub_nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  height: auto;
  margin: 0;
  padding: 8px 24px;
  line-height: 20px;
  white-space: normal;
  background: var(--muted-bg);
  border: none;
  border-bottom: 1px solid var(--border);
}

#customQ_nav.jb-overflowmenu {
  height: 52px;
  background: var(--muted-bg);
  border-bottom: 1px solid var(--border);
}

/* Inside the tickets bar the list must stay on one line: the script hides what does not fit. */
#customQ_nav .jb-overflowmenu-menu-primary {
  flex-wrap: nowrap;
  height: 100% !important;
  margin: 0;
  border-bottom: none;
}

#sub_nav > li,
#customQ_nav .jb-overflowmenu-menu-primary li.item,
#customQ_nav .jb-overflowmenu-menu-primary li.item:hover {
  display: block;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

/*
 * Each link is a pill. osTicket puts a small picture on the left of it
 * (a background image), so the text starts after 32px.
 */
#sub_nav > li > a,
#customQ_nav .jb-overflowmenu-menu-primary li.item > a {
  display: inline-block;
  margin: 0;
  padding: 6px 12px 6px 32px;
  background-position: 10px 50%;
  border-radius: 999px;
  color: var(--body);
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}

#sub_nav > li > a:hover,
#customQ_nav .jb-overflowmenu-menu-primary li.item:hover > a {
  background-color: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

#sub_nav a.active,
#sub_nav li.active > a,
#customQ_nav .jb-overflowmenu-menu-primary li.item.active > a,
#customQ_nav .jb-overflowmenu-menu-primary li.item > a.active {
  background-color: color-mix(in srgb, var(--primary) 8%, white);
  color: var(--primary);
  font-weight: 600;
  box-shadow: none;
}

/* The little arrow after a queue name. */
#customQ_nav .jb-overflowmenu-menu-primary li.item a > i {
  margin: 0 0 0 6px;
  line-height: 20px;
}

/* The queue menu that opens under a pill. */
.jb-overflowmenu-menu-primary div.customQ-dropdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-pop);
}

/* The "more" button on the right that holds the links that did not fit. */
#customQ_nav .jb-overflowmenu-container {
  display: flex;
  align-items: center;
  background: var(--muted-bg);
  border: none;
  border-left: 1px solid var(--border);
}

#customQ_nav .jb-overflowmenu-container > a.jb-overflowmenu-menu-secondary-handle {
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--body);
}

#customQ_nav .jb-overflowmenu-container > a.jb-overflowmenu-menu-secondary-handle:hover {
  background: var(--surface);
  color: var(--text);
}

.jb-overflowmenu-menu-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-pop);
}

/* --- Page title bar (ticket, queue, user…) ------------------------------ */

/*
 * The title sits on the left and the buttons on the right, on one row.
 * When the window is too narrow, the buttons wrap onto the next line
 * instead of running out of the window.
 */
.sticky.bar .content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.sticky.bar .content > .flush-left {
  min-width: 0;
}

.sticky.bar .content > .flush-left h2 {
  margin: 0;
}

.sticky.bar .content > .flush-left h2 a {
  color: var(--text);
}

.sticky.bar .content > .flush-left h2 a i {
  color: var(--muted);
  font-size: 0.7em;
}

/* The small cog beside a queue name (edit queue, add sub queue). */
.sticky.bar .content > .configureQ {
  float: none;
  margin: 0;
  color: var(--muted);
}

/*
 * The button group. margin-left: auto pushes it to the right end of the
 * row; the buttons keep the order they have in the HTML.
 */
.sticky.bar .content > .pull-right {
  float: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin-left: auto;
}

/* The hidden drop-down menus in the group keep their own position. */
.sticky.bar .content > .pull-right > *:not(.action-dropdown) {
  float: none;
  margin: 0;
}

/*
 * Ticket page only: there osTicket floats most buttons to the right, so
 * the first one in the HTML (the cog) ended up last on the right.
 * row-reverse keeps that same order without the floats. Three buttons
 * are not floated (reply, note, status) and sat on the left of the
 * group; a higher "order" puts them back there.
 */
.sticky.bar .content > .pull-right:has(> .action-button.pull-right) {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.sticky.bar .content > .pull-right:has(> .action-button.pull-right) > [data-dropdown="#action-dropdown-statuses"] {
  order: 1;
}

.sticky.bar .content > .pull-right:has(> .action-button.pull-right) > #post-note {
  order: 2;
}

.sticky.bar .content > .pull-right:has(> .action-button.pull-right) > [href="#post-reply"] {
  order: 3;
}

/* The PARENT / CHILD label, left of everything. */
.sticky.bar .content > .pull-right:has(> .action-button.pull-right) > span:not(.action-button) {
  order: 4;
}

/* Narrow window: the buttons go under the title, starting from the left. */
@media (max-width: 760px) {
  .sticky.bar .content > .pull-right {
    margin-left: 0;
    justify-content: flex-start;
  }

  .sticky.bar .content > .pull-right:has(> .action-button.pull-right) {
    justify-content: flex-end;
  }
}

/* --- Search bar above a ticket list ------------------------------------ */

/*
 * osTicket draws a grey strip with an inner shadow and a dotted line.
 * Here it is a plain toolbar: a rounded search field with its button
 * inside, the "advanced" link next to it, and Filter / Sort on the right.
 * On a narrow window Filter / Sort wrap under the search field.
 */
#basic_search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0 0 8px;
  padding: 16px 0 12px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

#basic_search > form {
  order: 1;
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
}

/* Filter and Sort. */
#basic_search > .pull-right {
  order: 2;
  float: none;
  display: flex;
  align-items: center;
  gap: 6px;
  height: auto !important;
  margin-left: auto;
}

#basic_search > .pull-right > .valign-helper {
  display: none;
}

/* The field and its button, drawn as one rounded box. */
#basic_search .input.attached {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  max-width: 480px;
  height: 38px;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  overflow: hidden;
}

/* Blue ring around the whole box while typing, like CCloud fields. */
#basic_search .input.attached:focus-within,
#basic_search .input.attached.focus {
  border-color: var(--primary);
  outline: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
  outline-offset: 0;
}

#basic_search .input.attached input.basic-search {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0 12px;
  border: none;
  border-radius: 0;
  background: transparent;
  outline: none;
  font-size: 14px;
}

/* The magnifier button: quiet, inside the box, blue on hover. */
body #basic_search .input.attached button.attached {
  height: 100%;
  margin: 0;
  padding: 0 14px;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: var(--muted-bg);
  box-shadow: none !important;
  color: var(--body) !important;
}

body #basic_search .input.attached button.attached:hover {
  background: color-mix(in srgb, var(--primary) 8%, white);
  color: var(--primary) !important;
  box-shadow: none;
}

/* "[advanced]" and its help icon. */
#basic_search > form > a {
  color: var(--primary);
  font-weight: 500;
  white-space: nowrap;
}

#basic_search > form > .help-tip {
  color: var(--muted);
}

/*
 * Full width and a layout that fits a phone.
 *
 * Loaded last, after ccloud-theme.css, so these widths win over the
 * fixed 840px customer box (theme.css) and the fixed 960px staff box
 * (scp.css). The HTML stays osTicket's.
 *
 * Wide window: the page goes edge to edge, and the text column fills
 * the space beside the side column.
 * Narrow window (760px and under): the side column drops below the
 * text, the menu wraps, and a ticket list scrolls sideways.
 */

/* --- Full width -------------------------------------------------------- */

#container {
  width: auto;
  max-width: none;
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  box-shadow: none;
}

#header {
  border-radius: 0;
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: border-box;
}

/* The greeting was a fixed 400px box. Let it size to its words. */
#header p {
  width: auto;
  max-width: 100%;
}

#header::after {
  content: "";
  display: block;
  clear: both;
}

#nav,
#sub_nav {
  box-sizing: border-box;
}

#nav.flush-left {
  margin-left: 24px;
  margin-right: 24px;
}

#content {
  margin-left: 0;
  margin-right: 0;
  padding-left: 24px;
  padding-right: 24px;
  border-left: none;
  border-right: none;
  box-sizing: border-box;
}

/* The staff queue bar was locked to 960px, the same as the old box. */
.jb-overflowmenu {
  width: 100%;
  max-width: 100%;
}

/* Ticket queues and forms grow with the window. */
table.list,
#ticketTable,
table.dashboard-stats,
table.custom-data,
#ticketForm > table,
#reply > table {
  width: 100%;
}

/*
 * osTicket writes the old box width straight into the HTML:
 * width="940" on most staff tables (settings forms, ticket summary,
 * lists) and width="800" on customer tables (ticket, profile, sign-up).
 * A CSS width beats that attribute, so these tables fill the page too.
 */
#content table[width="940"],
#content table[width="920"],
#content table[width="830"],
#content table[width="800"],
#content table.form_table,
#content table.ticket_info {
  width: 100%;
}

/* A staff help article was a fixed 670px column. */
.faq-content {
  width: auto;
  max-width: 100%;
}

#ticketForm td textarea,
#clientLogin td textarea,
#ticketForm div textarea,
#clientLogin div textarea,
#reply textarea,
#response_options textarea:not(.richtext),
#ticketForm input[type="text"],
#ticketForm input[type="email"],
#ticketForm select,
#clientLogin input[type="text"],
#clientLogin input[type="password"],
#clientLogin input[type="email"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Search field takes the spare room; the button stays on the same line. */
.search-form form,
.searchbar form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-form .search,
.searchbar .search {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* theme.css sets the reply box to 628px with !important. */
#reply textarea {
  width: 100% !important;
}

.redactor-box,
.redactor-editor {
  max-width: 100%;
}

/*
 * The writing area of the reply and internal note editors.
 * osTicket gives every "fullscreen" editor a 950px column
 * (js/redactor-osticket.js: maxWidth '950px'), and the editor writes it
 * on the element itself: style="max-width: 950px; margin: auto".
 * On a wide page that centres the text, so it starts in the middle.
 * Only !important beats a style written on the element, so the text
 * now fills the editor box. The editor's own fullscreen mode keeps
 * its centred column.
 */
.redactor-box:not(.redactor-box-fullscreen) .redactor-in {
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/*
 * Home page: the side column is first in the HTML, and the text used to
 * be a fixed 565px. Flex puts the text on the left, filling the window,
 * and the side column on the right. The featured articles (the plain div
 * after those two) stay on their own row.
 */
#landing_page {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
}

#landing_page > .main-content {
  order: 1;
  flex: 1 1 0;
  min-width: 0;
  width: auto;
}

#landing_page > .sidebar {
  order: 2;
  flex: 0 0 240px;
  width: 240px;
  float: none;
  margin-left: 24px;
  margin-right: 0;
}

#landing_page > .clear {
  display: none;
}

#landing_page > div:not(.sidebar):not(.main-content) {
  order: 3;
  flex: 1 0 100%;
}

.main-content {
  width: auto;
}

.thread-body img,
.faq-content img,
#landing_page img {
  max-width: 100%;
  height: auto;
}

.thread-body,
.faq-content {
  overflow-wrap: break-word;
}

/* Staff sign-in is a fixed card. Keep it centred, and never wider than the phone. */
#loginBox {
  width: min(400px, calc(100vw - 32px));
  margin-left: 0;
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
}

/* A popup must not be wider than the window. osTicket sizes some at 940px. */
.dialog,
.dialog.size-normal,
.dialog.size-large,
.dialog.size-xl,
.dialog#popup,
.dialog#advanced-search {
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
}

/* --- Narrow window ----------------------------------------------------- */

@media (max-width: 760px) {
  #header,
  #content {
    padding-left: 16px;
    padding-right: 16px;
  }

  #nav.flush-left {
    margin-left: 16px;
    margin-right: 16px;
  }

  /* Logo on the left, greeting under it, instead of beside it. */
  #header .pull-right,
  #header p#info {
    float: none;
    width: auto;
    max-width: 100%;
    margin: 8px 0 0;
    text-align: left;
  }

  #logo,
  #header #logo img {
    max-width: 70vw;
  }

  /*
   * Customer menu items wrap onto extra lines. (The staff bars already
   * wrap: see ccloud-staff-bars.css.)
   */
  #nav.flush-left {
    height: auto;
    white-space: normal;
    line-height: normal;
  }

  /* Side column under the text, full width. */
  .sidebar,
  .rtl .sidebar,
  .span8,
  .span4,
  #landing_page > .sidebar,
  #landing_page > .main-content {
    float: none;
    display: block;
    width: auto;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  #landing_page {
    flex-direction: column;
    align-items: stretch;
  }

  #landing_page > .main-content {
    order: 1;
    flex: 1 1 auto;
    width: 100%;
  }

  #landing_page > .sidebar {
    order: 2;
    flex: 1 1 auto;
    width: 100%;
  }

  .main-content {
    display: block;
  }

  .featured-category {
    width: 100%;
  }

  .login-box,
  .rtl .login-box {
    display: block;
    width: auto;
    box-shadow: none;
  }

  #clientLogin .instructions,
  .rtl #clientLogin .instructions {
    display: block;
    padding-left: 0;
    padding-right: 0;
  }

  /* Label above the field, instead of a 160px column beside it. */
  #ticketForm > table,
  #ticketForm > table tbody,
  #ticketForm > table tr,
  #ticketForm > table td,
  #ticketForm > table td + td {
    display: block;
    width: auto !important;
  }

  /*
   * Ticket summary: the two boxes side by side (50% each) go one under
   * the other. Staff pages call it .ticket_info, customer pages #ticketInfo.
   */
  table.ticket_info > tbody > tr > td,
  #ticketInfo > tbody > tr > td {
    display: block;
    width: auto;
  }

  /* Settings forms: label above the field, instead of beside it. */
  table.form_table > tbody > tr > td {
    display: block;
    width: auto !important;
  }

  /* Password reset pages put the text in a half-width box. */
  #content div[style*="width:50%"] {
    width: 100% !important;
  }

  /* Tabs that do not fit scroll sideways instead of wrapping. */
  ul.tabs {
    overflow-x: auto;
    white-space: nowrap;
  }

  #kb-search #query,
  #kb-search #cid,
  #kb-search #topic-id {
    float: none;
    display: block;
    width: 100%;
    margin: 0 0 8px;
    box-sizing: border-box;
  }

  /*
   * A ticket queue has more columns than a phone. The list scrolls
   * sideways inside the page; the header and the form stay put.
   * #content's height still grows with the page, so this does not
   * trap vertical scrolling.
   */
  #content {
    overflow-x: auto;
  }

  table.list,
  #ticketTable {
    width: max-content;
    min-width: 100%;
  }

  table.list th,
  table.list td,
  #ticketTable th,
  #ticketTable td {
    white-space: nowrap;
  }

  .dialog,
  .dialog.size-normal,
  .dialog.size-large,
  .dialog.size-xl,
  .dialog#popup,
  .dialog#advanced-search {
    width: calc(100vw - 16px) !important;
    left: 8px !important;
    margin-left: 0 !important;
  }
}

