/*
 * modern.css — Tangaza theme for the osTicket client portal
 * ---------------------------------------------------------------------------
 * Local customisation layered on top of the stock theme.css. It turns the
 * portal into an "app shell": left sidebar menu, top bar, card-based content.
 *
 * Markup it relies on lives in include/client/header.inc.php,
 * include/client/footer.inc.php, index.php and include/client/tickets.inc.php
 * (all marked "Local customisation"). Keep this file when upgrading osTicket.
 *
 * Tangaza brand palette (contrast measured against white):
 *   Red     #c52127  white text on it 5.8:1  -> primary actions, links
 *   Purple  #51506E  white text on it 7.7:1  -> headings, accent card
 *   Black   #444444  on white          9.7:1 -> body text
 *   Gold    #d19c2c  white text on it  2.5:1 -> DECORATION ONLY (tiles,
 *           underlines); never as a background behind text.
 */

:root {
  --red: #c52127;
  --red-dark: #9e1a1f;
  --red-tint: #fbeced;
  --purple: #51506E;
  --purple-dark: #3d3c55;
  --purple-tint: #ecebf3;
  --gold: #d19c2c;
  --gold-deep: #9a6d12;      /* darker gold for icons on light tint */
  --gold-tint: #faf1dc;
  --ink: #444444;
  --muted: #6e6d80;
  --bg: #f5f4f8;
  --surface: #ffffff;
  --border: #e4e3ea;
  --radius: 22px;           /* cards, panels      */
  --radius-sm: 14px;        /* inputs, small boxes */
  --shadow: 0 1px 2px rgba(40,30,60,.05), 0 6px 20px rgba(40,30,60,.06);
  --shadow-hover: 0 2px 4px rgba(40,30,60,.06), 0 12px 28px rgba(40,30,60,.10);
  --focus: 0 0 0 3px rgba(197,33,39,.28);
  --sidebar-w: 250px;
}

/* ===== Base ============================================================= */
html { overflow-y: auto; }
body {
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
/* Inter everywhere (self-hosted: css/fonts/inter/inter.css), including
   widgets that set their own font (jQuery UI, Select2, Redactor editor). */
body, input, select, textarea, button,
.ui-widget, .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button,
.select2-container, .select2-dropdown, .redactor-box, .redactor-styles,
.thread-body, .button, #footer {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}
body, input, select, textarea, button { color: var(--ink); }
body { font-feature-settings: "cv11", "ss01"; }  /* Inter's clearer 1 / a / l */
a, .link { color: var(--red); }
a:hover, .link:hover { border-bottom: 0; text-decoration: underline; }
h1 { color: var(--purple); font-weight: 700; font-size: 1.6rem; line-height: 1.25; }
h2, .subject { color: var(--purple); font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
hr { border-top-color: var(--border); }
.error { color: #b42318; }

a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
main:focus { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 1000;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--red); color: #fff !important; transition: top .15s;
}
.skip-link:focus { top: 8px; text-decoration: none; }

/* ===== App shell ======================================================== */
#container.app-shell {
  display: flex;
  align-items: stretch;
  width: auto;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}
.app-shell, .app-shell * { box-sizing: border-box; }
/* legacy widgets expect content-box */
.app-shell .redactor-box, .app-shell .redactor-box *,
.app-shell .select2-container, .app-shell .select2-container *,
.app-shell .ui-widget, .app-shell .ui-widget *,
.app-shell .filedrop, .app-shell .filedrop * { box-sizing: content-box; }

/* --- Sidebar --- */
.app-sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
}
/* theme.css gives #logo height:100%, which stretched it over the whole
   sidebar and pushed the menu to the bottom */
.app-sidebar #logo, .app-logo { display: block; height: auto; padding: 4px 8px 10px; border: 0 !important; }

/* ---- Lucide line icons (inline SVG, see include/class.icons.php) ---- */
svg.lucide {
  width: 1.25em; height: 1.25em;
  flex: none;
  stroke-width: 1.8;
  vertical-align: -0.22em;
}
.app-logo img { display: block; max-width: 100%; max-height: 56px; height: auto; }

.app-nav-label {
  padding: 0 12px 8px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.app-sidebar #nav {
  /* reset stock #nav bar */
  display: flex; flex-direction: column; gap: 4px;
  margin: 0; padding: 0; height: auto;
  background: none; border: 0; box-shadow: none; white-space: normal;
}
.app-sidebar #nav li { display: block; margin: 0; padding: 0; }
.app-sidebar #nav li a,
.rtl .app-sidebar #nav li a {
  display: flex; align-items: center; gap: 12px;
  height: auto; line-height: 1.3;
  margin: 0; padding: 11px 14px;
  border-radius: 16px;
  color: var(--ink);
  font-weight: 500;
  text-align: start;
  background-image: none !important;   /* drop stock PNG icons */
}
.app-sidebar #nav li a svg.lucide { width: 20px; height: 20px; color: var(--muted); }
.app-sidebar #nav li a:hover {
  background-color: var(--bg); color: var(--ink); text-decoration: none;
}
.app-sidebar #nav li a.active {
  background-color: var(--red-tint);
  color: var(--red-dark);
  font-weight: 650;
}
.app-sidebar #nav li a.active svg.lucide { color: var(--red); }

.app-sidebar-footer {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.app-sidebar-footer > a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 16px;
  color: var(--ink); font-weight: 500;
}
.app-sidebar-footer > a svg.lucide { width: 20px; height: 20px; color: var(--muted); }
.app-sidebar-footer > a:hover { background: var(--bg); text-decoration: none; }
.app-sidebar-footer > a.danger, .app-sidebar-footer > a.danger svg.lucide { color: var(--red); }
.app-langs { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; }

.app-backdrop { display: none; }
.app-menu-toggle { display: none; }

/* --- Main column --- */
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#header.app-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  height: auto; min-height: 72px;
  padding: 14px 32px;
  background: rgba(245,244,248,.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.app-title {
  font-size: 1.25rem; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-search {
  position: relative;
  flex: 0 1 340px;
  margin-inline-start: 8px;
}
.app-search svg.lucide {
  position: absolute; inset-inline-start: 14px; top: 50%;
  width: 18px; height: 18px;
  transform: translateY(-50%); color: var(--muted); pointer-events: none;
}
.app-search input[type="search"] {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: .95rem;
}
.rtl .app-search input[type="search"] { padding: 10px 38px 10px 14px; }
.app-search input:focus { border-color: var(--red); box-shadow: var(--focus); outline: none; }

.app-user { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.app-user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  color: var(--ink);
}
a.app-user-chip:hover { background: var(--surface); text-decoration: none; }
.app-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--purple); color: #fff;
  font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
.app-user-text { display: flex; flex-direction: column; line-height: 1.2; }
.app-user-text strong { font-size: .9rem; }
.app-user-text small { font-size: .75rem; color: var(--muted); }

/* System-wide bars (offline / warnings) */
.error_bar, .warning_bar, .notice_bar {
  margin: 0 32px 12px; padding: 10px 16px; border-radius: var(--radius-sm);
}

/* --- Content area: a white card by default --- */
#content {
  flex: 1 0 auto;
  margin: 0 32px;
  padding: 28px;
  min-height: 360px;
  height: auto !important;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* Landing page lays out its own cards on the grey background */
.page-index:not(.section-kb) #content {
  background: transparent; box-shadow: none; padding: 4px 0 0;
}

#footer {
  padding: 18px 32px 24px;
  text-align: start;
  font-size: .8rem;
  color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
#footer p { margin: 0; }
#footer a { color: var(--muted); }
#footer #poweredBy { margin: 0; opacity: .7; }

/* ===== Messages ========================================================= */
#msg_notice, #msg_warning, .warning-banner, #msg_error, #msg_info {
  height: auto; min-height: 16px; line-height: 1.45;
  padding: 12px 16px 12px 42px;
  border-radius: var(--radius-sm);
  background-position: 14px 14px;
  margin-bottom: 16px;
}
#msg_info { padding-left: 16px; }

/* ===== Buttons ========================================================== */
.app-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s, box-shadow .15s, transform .05s;
}
.app-btn:hover { text-decoration: none; box-shadow: var(--shadow); }
.app-btn:active { transform: translateY(1px); }
.app-btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.app-btn-primary:hover { background: var(--red-dark); color: #fff; }

.button, .button:visited, .green.button, .green.button:visited,
.blue.button, .blue.button:visited {
  border: 0; border-radius: 999px; box-shadow: none; text-shadow: none;
  font-family: inherit; font-weight: 600; padding: 10px 20px; max-width: none;
  transition: background-color .15s;
}
.button, .button:visited, .green.button, .green.button:visited { background-color: var(--purple); }
.button:hover, .green.button:hover { background-color: var(--purple-dark); text-decoration: none; }
.blue.button, .blue.button:visited { background-color: var(--red); }
.blue.button:hover { background-color: var(--red-dark); }
.button:active { top: 0; transform: translateY(1px); }

#content input[type="submit"],
#content input[type="button"],
#content input[type="reset"] {
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
#content input[type="button"]:hover,
#content input[type="reset"]:hover { background: var(--bg); }
#content input[type="submit"] { background: var(--red); border-color: var(--red); color: #fff; }
#content input[type="submit"]:hover { background: var(--red-dark); border-color: var(--red-dark); }
#content input[type="submit"]:disabled { opacity: .6; cursor: wait; }
#content input[type="submit"].unsaved { box-shadow: 0 0 0 3px rgba(209,156,44,.45); }

/* ===== Form fields ====================================================== */
#content input[type="text"], #content input[type="email"],
#content input[type="password"], #content input[type="search"],
#content input[type="tel"], #content input[type="number"],
#content input[type="date"], #content input:not([type]),
#content select, #content textarea {
  border: 1px solid #cfcdd9;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: #fff;
  max-width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
#content select { padding: 8px 10px; }
#content input:focus, #content select:focus, #content textarea:focus {
  border-color: var(--red); box-shadow: var(--focus); outline: none;
}
#ticketForm td textarea, #ticketForm div textarea { width: 100%; }
#ticketForm > table td { padding: 6px 0; }
label.required, span.required { font-weight: 650; }

/* ===== Cards & tiles (shared) ========================================== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 16px;
  font-size: 1.15rem;
}
.tile svg.lucide { width: 22px; height: 22px; vertical-align: 0; }
.app-btn svg.lucide { width: 18px; height: 18px; }
.app-menu-toggle svg.lucide { width: 20px; height: 20px; }
.app-avatar svg.lucide { width: 18px; height: 18px; }
.tile-red    { background: var(--red-tint);    color: var(--red); }
.tile-purple { background: var(--purple-tint); color: var(--purple); }
.tile-gold   { background: var(--gold-tint);   color: var(--gold-deep); }

/* ===== Landing page ===================================================== */
.hero {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  margin-bottom: 22px;
}
.hero h1 { margin: 0; font-size: 1.85rem; color: var(--ink); }
.hero-sub { margin: 4px 0 0; color: var(--muted); }

.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}
.action-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: box-shadow .2s, transform .2s;
}
.action-card .tile { margin-bottom: 10px; }
.action-card strong { font-size: 1.05rem; color: var(--ink); }
.action-card small { color: var(--muted); font-size: .88rem; }
.action-card:hover { text-decoration: none; box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}
.main-content { width: auto; }
.main-content.card { padding: 32px; }
.main-content.card .thread-body { border: 0; padding: 0; background: none; }
/* Landing-page text is admin-edited HTML that often carries inline fonts;
   keep it in the theme font */
#landing_page .thread-body, #landing_page .thread-body * {
  font-family: inherit !important;
}
#landing_page .thread-body h1, #landing_page .thread-body h2 {
  color: var(--purple); font-weight: 700; font-size: 1.5rem; margin: 0 0 12px;
}
#landing_page .thread-body p { line-height: 1.65; color: var(--ink); }

/* No featured FAQs / resources? Let the main card use the full width */
.dash-grid:not(:has(.sidebar .content > *)) { grid-template-columns: 1fr; }
.dash-grid .sidebar:not(:has(.content > *)) { display: none; }

.search-form { padding: 0; margin-bottom: 18px; }
.search-form form { display: flex; gap: 8px; }
.searchbar .search, .search-form .search {
  flex: 1; width: auto;
  border-radius: 999px !important;
  padding: 11px 18px !important;
  font-size: 1rem; box-shadow: none;
}

/* Featured questions box -> dark accent card (like a calendar widget) */
.dash-grid .sidebar,
.rtl .dash-grid .sidebar {
  float: none !important; width: auto; margin: 0;
}
.dash-grid .sidebar .content {
  background: var(--purple);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.dash-grid .sidebar .content a { color: #fff; }
.dash-grid .sidebar .content a:hover { text-decoration: underline; }
.dash-grid .sidebar section .header {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .08em;
  color: #f0dcb0; margin-bottom: 10px;
}
.dash-grid .sidebar section > div {
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.12);
}
.dash-grid .sidebar section > div:last-child { border-bottom: 0; }

#landing_page h1 { margin-bottom: 12px; }
.featured-category {
  width: calc(50% - 12px);
  margin: 10px 0;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.featured-category:nth-of-type(odd) { margin-inline-end: 14px; }
.featured-category i { color: var(--gold); text-shadow: none; }
.featured-category .category-name { color: var(--purple); font-weight: 650; }

/* Generic sidebar (KB pages etc.) */
.sidebar .content {
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
}

/* ===== Tickets list ===================================================== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: box-shadow .2s, border-color .2s;
}
.stat-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.stat-card.active { border-color: var(--red); box-shadow: var(--focus); }
.stat-card .tile { position: absolute; top: 16px; inset-inline-end: 16px; }
.stat-card small { color: var(--muted); font-weight: 600; font-size: .85rem; }
.stat-card strong { font-size: 2rem; line-height: 1.2; color: var(--ink); }
.stat-card strong.stat-cta { font-size: 1.1rem; color: var(--red); padding: 8px 0 6px; }
.stat-card em { font-style: normal; color: var(--muted); font-size: .82rem; }

.search.well {
  margin: 0 0 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 0;
  border-radius: var(--radius-sm);
}
.search.well .flush-left { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search.well form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
.search.well .pull-right { margin-inline-start: auto; float: none; }

#ticketTable {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-collapse: separate;
  overflow: hidden;
}
#ticketTable caption {
  background: transparent; border: 0; padding: 8px 0;
  font-weight: 600; color: var(--muted); text-align: start;
}
#ticketTable th {
  height: auto; line-height: 1.4;
  padding: 12px 14px;
  background: var(--bg);
  border: 0; border-bottom: 1px solid var(--border);
  font-weight: 650; font-size: .85rem;
}
#ticketTable th a { color: var(--muted); }
#ticketTable td {
  padding: 12px 14px;
  border: 0; border-bottom: 1px solid #efeef3;
  vertical-align: middle;
}
#ticketTable tbody tr:last-child td { border-bottom: 0; }
#ticketTable tbody tr:hover td { background: #fbfafd; }
#ticketTable .Icon { background-image: none; padding-left: 0; font-weight: 600; color: var(--purple); }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 650;
  background: #eeeef2;
  color: var(--ink);
  white-space: nowrap;
}
.status-pill.state-open   { background: var(--red-tint);    color: var(--red-dark); }
.status-pill.state-closed { background: var(--purple-tint); color: var(--purple); }

td.empty-state { text-align: center; padding: 48px 16px !important; color: var(--muted); }
td.empty-state svg.lucide { display: block; width: 44px; height: 44px; margin: 0 auto 12px; color: #cfcdd9; stroke-width: 1.4; }
td.empty-state strong { display: block; margin-bottom: 16px; color: var(--ink); }
td.empty-state .app-btn-primary { color: #fff; }

#pagination li a, #pagination .active { border-radius: 8px; padding: 5px 11px; font-size: .85rem; }
#pagination .active { background: var(--red); color: #fff; }

/* ===== Ticket view & thread ============================================ */
#ticketInfo h1 { border-bottom: 2px solid var(--gold); }
.infoTable { background: var(--bg); border-radius: var(--radius-sm); }
table.custom-data th { background: var(--bg); }
.thread-entry .header { border-radius: 18px 18px 0 0; }
.thread-entry .thread-body { border-radius: 0 0 18px 18px; border-bottom-width: 1px; }
.thread-entry > .avatar, .thread-entry > .avatar img { border-radius: 50%; }
.thread-entry.message .header { background: var(--purple-tint); }
.thread-entry.avatar.message .header:after { border-right-color: var(--purple-tint); }
.thread-entry.response .header { background: #f1f1f4; }
.thread-entry.avatar.response .header:after { border-left-color: #f1f1f4; }
#reply {
  background: var(--bg);
  border: 0;
  border-radius: var(--radius);
  padding: 20px;
}
#reply textarea { width: 100% !important; }

/* ===== Login ============================================================ */
#clientLogin {
  background: var(--bg);
  border: 0;
  border-radius: var(--radius);
  box-shadow: none;
  padding: 24px;
}
#clientLogin input[type=text], #clientLogin input[type=password] {
  width: 100%; max-width: 340px; margin-bottom: 12px;
}
#clientLogin strong { font-size: .85rem; color: #b42318; }
.login-box { box-shadow: none; }
.forgot-password { display: inline-block; margin-inline-start: 12px; padding-top: 6px; }
.forgot-password.highlight { font-weight: 650; }

/* ===== Responsive ======================================================= */
#content table[width] { width: 100%; max-width: 100%; }

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* Tablet & phone: sidebar becomes an off-canvas drawer */
@media (max-width: 900px) {
  .app-sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0;
    z-index: 300;
    height: auto;
    width: min(290px, 86vw); flex-basis: auto;
    border-radius: 0 22px 22px 0;
    box-shadow: var(--shadow-hover);
    transform: translateX(-105%);
    transition: transform .22s ease;
  }
  .rtl .app-sidebar { transform: translateX(105%); }
  body.sidebar-open .app-sidebar { transform: none; }
  body.sidebar-open .app-backdrop {
    display: block; position: fixed; inset: 0; z-index: 250;
    background: rgba(30,25,45,.35);
  }
  .app-menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex: 0 0 40px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--ink); cursor: pointer;
    font-size: 1.1rem;
  }
  #header.app-topbar { padding: 12px 16px; gap: 10px; }
  #content { margin: 0 16px; padding: 20px; }
  .error_bar, .warning_bar, .notice_bar { margin: 0 16px 12px; }
  #footer { padding: 16px; }
  .app-user-text { display: none; }
  .app-user-chip { padding: 0; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }          /* avoids iOS zoom on input focus */
  .app-search { display: none; }     /* KB search is still on the home page */
  .app-title { font-size: 1.05rem; }
  .page-index:not(.section-kb) #content { padding: 0; }
  .hero h1 { font-size: 1.5rem; }
  .hero .app-btn { width: 100%; justify-content: center; }
  .featured-category { width: 100%; margin-inline-end: 0 !important; }
  .search-form form { flex-wrap: wrap; }
  .search-form .button { width: 100%; }
  #kb-search #query, #kb-search #cid, #kb-search #topic-id {
    float: none; width: 100%; margin: 0 0 8px;
  }
  .span4, .span8 { display: block; width: auto; margin: 0 0 16px; }

  #ticketForm > table, #ticketForm > table tbody,
  #ticketForm > table tr, #ticketForm > table td,
  table.padded, table.padded tbody, table.padded tr, table.padded td {
    display: block; width: 100% !important;
  }
  #ticketForm > table { table-layout: auto; }

  /* Landing: action cards become a single list of rows (icon + text) */
  .action-cards { grid-template-columns: 1fr; gap: 10px; }
  .action-card {
    display: grid; grid-template-columns: 46px 1fr; column-gap: 14px; row-gap: 2px;
    align-items: center; padding: 14px 16px; border-radius: 18px;
  }
  .action-card .tile { grid-row: span 2; margin: 0; }
  .action-card:hover { transform: none; }
  .main-content.card { padding: 20px; }
  #landing_page .thread-body h1, #landing_page .thread-body h2 { font-size: 1.25rem; }

  /* Ticket summary: Open / Closed side by side, call-to-action full width */
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 16px; border-radius: 18px; }
  .stat-card .tile { width: 36px; height: 36px; border-radius: 12px; top: 12px; }
  .stat-card .tile svg.lucide { width: 18px; height: 18px; }
  .stat-card strong { font-size: 1.6rem; }
  .stat-card:nth-child(3) { grid-column: 1 / -1; }
  .stat-card strong.stat-cta { padding: 4px 0 2px; }

  /* Search row: field + button, topic filter full width below */
  .search.well { padding: 12px; }
  .search.well form input[type=search] { flex: 1 1 0; min-width: 0; width: auto; }
  .search.well .pull-right { margin-inline-start: 0; flex-basis: 100%; display: flex; align-items: center; gap: 8px; }
  .search.well .pull-right select { flex: 1; min-width: 0; }
  .states { float: none !important; margin-top: 6px; }

  /* Ticket list: one card per ticket
     [#number ............ status]
     [subject (wraps)           ]
     [date ............ department] */
  #ticketTable, #ticketTable tbody { display: block; border: 0; overflow: visible; }
  #ticketTable thead { display: none; }
  #ticketTable caption { display: block; padding: 0 2px 8px; }
  #ticketTable tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "num status" "subj subj" "date dept";
    gap: 6px 12px;
    margin: 0 0 10px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
  }
  #ticketTable tbody td { display: block; padding: 0; border: 0 !important; min-width: 0; background: none !important; }
  #ticketTable tbody td:nth-child(1) { grid-area: num; font-weight: 650; }
  #ticketTable tbody td:nth-child(2) { grid-area: date; color: var(--muted); font-size: .85rem; }
  #ticketTable tbody td:nth-child(3) { grid-area: status; }
  #ticketTable tbody td:nth-child(4) { grid-area: subj; font-size: 1.02rem; font-weight: 600; }
  #ticketTable tbody td:nth-child(5) { grid-area: dept; color: var(--muted); font-size: .85rem; text-align: end; }
  #ticketTable .truncate {
    max-width: none !important; max-height: none !important;
    white-space: normal; overflow: visible; display: inline;
  }
  #ticketTable tbody tr:has(td[colspan]) { display: block; }
  #ticketTable tbody td[colspan] { text-align: center; }

  #clientLogin { background-image: none; padding: 16px; }
  #clientLogin > div[style*="table-row"],
  .login-box, #clientLogin > div > div[style*="table-cell"] {
    display: block !important; width: auto; padding: 0 0 12px;
  }

  .thread-entry.avatar, .thread-entry.response.avatar { margin: 0; }
  .thread-entry > .avatar { display: none; }
  .thread-event { margin-left: 0; }
  #ticketThread::before { display: none; }
  .thread-body .attachment-info, .freetext-files .file { width: 100%; }
  .thread-entry .header .title { max-width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Printing: no chrome */
@media print {
  .app-sidebar, .app-topbar, .app-backdrop, #footer { display: none !important; }
  #content { margin: 0; box-shadow: none; }
}
