/* ============================================================
   Ticketing System — 4D employee-portal theme.
   Navy sidebar + topbar + gradient banner + white cards,
   matching the Company 4D portal design.
   ============================================================ */

/* ---- Brand fonts (self-hosted, bilingual Latin + Arabic) ----
   Vazirmatn  → body / UI text (variable weight, built for on-screen reading).
   TheSans    → headings & brand tags (corporate humanist sans).
   Files live in fonts/ and ship with the app. */
@font-face {
    font-family: "Vazirmatn";
    src: url("fonts/ArbFONTS-Vazirmatn-VariableFont_wght.ttf") format("truetype");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "TheSans";
    src: url("fonts/ArbFONTS-The-Sans-Plain-alinma.ttf") format("truetype");
    font-weight: 400 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "TheSans";
    src: url("fonts/ArbFONTS-TheSans-Bold-alinma.ttf") format("truetype");
    font-weight: 700 900;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Brand blue: Dark Cornflower Blue #193F92. The primary buttons and brand
       sit at --navy-700/--logo-navy; --navy-800/900 are darker (hovers,
       gradient depth) and --navy-600/500 are lighter accents. */
    --logo-navy: #193F92;
    --navy-900: #0f2657;
    --navy-800: #14316f;
    --navy-700: #193F92;
    --navy-600: #2551b0;
    --navy-500: #4e7ada;
    --accent:   #22c55e;
    --ink:      #1f2a44;
    --muted:    #64748b;
    --border:   #e3e8f0;
    --bg:       #eef1f6;
    --white:    #ffffff;
    --red:      #dc2626;
    --red-bg:   #fef1f1;
    --radius:   14px;
    --shadow:   0 4px 18px rgba(16, 29, 78, .08);
    /* Type stacks — Vazirmatn for text, TheSans for headings; both cover
       Latin + Arabic, so one stack serves LTR and RTL. */
    --font-body: "Vazirmatn", system-ui, -apple-system, "Segoe UI", "Noto Naskh Arabic", sans-serif;
    --font-head: "TheSans", "Vazirmatn", system-ui, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over class rules that set a
   display (e.g. .ticket-stage { display: flex }). */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    margin: 0;
    color: var(--ink);
    line-height: 1.5;
}

/* Headings and brand tags carry the corporate face. */
h1, h2, h3, h4,
.section-title,
.brand-tag,
.login-tag {
    font-family: var(--font-head);
}

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Layout: fixed sidebar + fluid main column --- */
.layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: 295px;
    flex-shrink: 0;
    background: var(--logo-navy);
    color: var(--white);
    padding: 28px 16px;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.brand {
    padding: 0 0 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, .16);   /* thin divider under the logo */
}

/* "Support" wordmark under the logo. */
.brand-tag {
    margin-top: 6px;   /* small gap under the (now cropped) logo */
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: .34em;
    text-indent: .34em;   /* balance the trailing letter-spacing */
    text-transform: uppercase;
    color: rgba(255, 255, 255, .82);
}

/* Full "Company 4D" lockup at its fixed design size;
   object-fit keeps the artwork undistorted inside the box. */
.brand-logo {
    width: 290px;
    height: 290px;
    object-fit: contain;
    display: block;
    /* The PNG has ~35% transparent bands top & bottom; crop them so the mark
       sits at the very top and the divider tucks right under it. */
    margin: -95px 0;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border-radius: 10px;
    color: var(--white);
    text-decoration: none;
    font-size: .95rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: background .15s;
}

.nav-item:hover { background: rgba(255, 255, 255, .08); }

.nav-item.active {
    background: rgba(255, 255, 255, .10);
    border-color: rgba(255, 255, 255, .18);
    box-shadow: inset 3px 0 0 var(--accent);
}

[dir="rtl"] .nav-item.active { box-shadow: inset -3px 0 0 var(--accent); }

/* --- Main column --- */
.main {
    flex: 1;
    min-width: 0;
    padding: 20px 24px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: pagein .3s ease both;
}

/* Gentle fade-in for page content (dashboard, queue, etc.). */
@keyframes pagein {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .main { animation: none; }
}

/* --- Topbar --- */
.topbar {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ink);
    background: #f1f4f9;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 18px;
    transition: background .15s;
}

.lang-toggle:hover { background: #e6ebf3; }

.logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 700;
    color: var(--red);
    background: var(--red-bg);
    border: 1px solid #f5c6c6;
    border-radius: 999px;
    padding: 8px 18px;
    transition: background .15s;
}

.logout:hover { background: #fde3e3; }

/* Logged-in user's name in the topbar. */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Topbar controls turn red on hover; icons follow via currentColor. */
.topbar a,
a.user-chip { text-decoration: none; }

.topbar a:hover,
.topbar a:hover .icon {
    color: var(--red);
    stroke: var(--red);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ink);
    background: #f1f4f9;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 18px;
}

/* --- Home dashboard --- */
.home-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}

/* Right column: Team on top, "Assigned to Me" stacked beneath it. */
.home-side {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

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

/* Compact list of your own tickets (fits the narrow column). */
.assigned-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.assigned-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--ink);
}

.assigned-list li:last-child .assigned-item { border-bottom: none; }

.assigned-item:hover .assigned-title { color: var(--navy-600); }

.assigned-no {
    font-size: .82rem;
    font-weight: 700;
    color: var(--muted);
    flex-shrink: 0;
}

.assigned-title {
    flex: 1;
    min-width: 0;
    font-size: .9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Who resolved it, under the title in the review list. */
.assigned-by {
    display: block;
    font-size: .76rem;
    font-weight: 600;
    color: var(--muted);
}

.online-list {
    list-style: none;
    /* Pulled out and padded back in by the same amount, so rows stay exactly
       where they were while the scroll box gains side room for the dot's glow
       ring. overflow-y below makes overflow-x compute to auto as well (a
       non-visible value on one axis does that to the other), so anything
       painted outside the padding box is clipped — which was shaving the left
       edge off the first pixel column of the ring. */
    margin: 0 -4px;
    padding: 0 4px;
    /* Keep the panel a fixed size: about six rows fit, longer teams scroll
       inside the box instead of stretching the card. */
    max-height: 288px;
    overflow-y: auto;
}

/* Discord-style role group header. Sticks to the top of the (scrolling) list
   so the current group stays labelled. Background matches the card so rows
   scroll cleanly underneath it. */
.online-group {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--white);
    /* Spread back over the list's side padding, so the header's background
       covers the full scroll box. Without it, a row scrolling underneath shows
       the outer edge of its glow ring in the gutter beside the label. */
    margin: 0 -4px;
    padding: 12px 4px 6px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.online-group:first-child { padding-top: 2px; }

.online-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.online-item:last-child { border-bottom: none; }

.online-name {
    font-weight: 600;
    flex: 1;
    min-width: 0;
}

.online-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
    flex-shrink: 0;
}

/* Offline: muted grey dot and dimmed name. */
.dot-offline {
    background: #cbd5e1;
    box-shadow: none;
}

.is-offline .online-name { color: var(--muted); }

/* Small "N online" count next to the Team heading. */
.online-count {
    font-size: .78rem;
    font-weight: 700;
    color: var(--accent);
    background: #eafaf1;
    border-radius: 999px;
    padding: 3px 12px;
}

.section-title:has(.online-count) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* --- Ticket actions --- */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.action-btn {
    width: auto;
    padding: 10px 22px;
    font-size: .92rem;
}

/* An <a> carrying .action-btn (e.g. Save as PDF) doesn't match the base button
   rule, so give it the same navy fill, radius and centering here. */
a.action-btn {
    display: inline-block;
    text-align: center;
    text-decoration: none;
    background: var(--navy-700);
    color: var(--white);
    border-radius: 10px;
    font-weight: 700;
    transition: background .15s;
}
a.action-btn:hover { background: var(--navy-800); }

.action-btn.action-close { background: #166534; }
.action-btn.action-close:hover { background: #14532d; }

.action-btn.action-resolve { background: var(--navy-600); }
.action-btn.action-resolve:hover { background: var(--navy-700); }

/* Escalate: an amber "hand it up" action, distinct from the flow buttons. */
.action-btn.action-escalate { background: #b45309; }
.action-btn.action-escalate:hover { background: #92400e; }

/* Muted one-liner sitting next to the escalate button. */
.action-hint {
    align-self: center;
    font-size: .84rem;
    color: var(--muted);
}

/* "Ticket resolved by …" state line on the actions card. */
.resolved-note {
    margin: 0 0 4px;
    font-weight: 600;
    color: var(--accent);
}

/* Project-scope checkboxes on the supervisor account form. */
.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 12px;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    cursor: pointer;
}
.checkbox-item input { width: auto; margin: 0; }

/* Resolution report rows wrap long text under the label. */
.report-row { align-items: flex-start; }
.report-row span:last-child { text-align: end; max-width: 70%; }

/* Prominent banner button that opens the resolution report. */
.report-banner {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: start;
    padding: 16px 20px;
    border: 1px solid #cfe0ff;
    border-radius: var(--radius);
    background: #eef4ff;
    color: var(--navy-700);
    font-size: .98rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: background .15s;
}

.report-banner:hover { background: #e2ecff; }

.report-banner .banner-arrow { margin-inline-start: auto; }

[dir="rtl"] .report-banner .banner-arrow { transform: scaleX(-1); }

.action-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 24px;
}

.action-field { min-width: 240px; }

.action-field select { margin-bottom: 10px; }

/* --- Ticket history timeline --- */
.event-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.event-item {
    display: flex;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

.event-item:last-child { border-bottom: none; }

.event-time {
    flex-shrink: 0;
    color: var(--muted);
    font-size: .82rem;
    min-width: 118px;
    padding-top: 1px;
}

.event-actor { color: var(--muted); }

/* Marks a supervisor/manager action in the history as a follow-up. */
.event-followup { color: var(--navy-600); }

/* --- Staff reply thread (ticket page) --- */
.reply-list {
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
}

.reply-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.reply-item:last-child { border-bottom: none; }

.reply-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.reply-time {
    color: var(--muted);
    font-size: .82rem;
    margin-inline-start: auto;
}

.reply-body {
    margin: 0;
    font-size: .92rem;
    line-height: 1.55;
}

/* --- Popup dialogs --- */
dialog.modal {
    border: none;
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;              /* keeps the header inside the rounded corners */
    width: calc(100% - 32px);
    max-width: 480px;
    color: var(--ink);
    box-shadow: 0 24px 64px rgba(16, 29, 78, .28);
}

/* Column layout only while open (a closed dialog must stay display:none).
   This gives .modal-body a bounded height so it can scroll instead of
   being clipped by the dialog's overflow:hidden. */
dialog.modal[open] {
    display: flex;
    flex-direction: column;
}

dialog.modal::backdrop { background: rgba(16, 29, 78, .45); }

/* Branded header bar: 4D logo, title, close. */
.modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: linear-gradient(120deg, var(--navy-800), var(--navy-500));
    color: var(--white);
}

/* The white 4D mark, added here so every popup gets it without markup. */
.modal-head::before {
    content: '';
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
    /* The PNG has ~31% transparent padding; zoom past the box to crop it so the
       mark reads at the same size as the title text beside it. */
    background: url('logos-02.png') no-repeat center;
    background-size: 210%;
}

.modal-head h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--white);
}

.modal-close {
    width: auto;
    margin-inline-start: auto;     /* pushed to the far end of the bar */
    padding: 2px 6px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, .8);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover { background: none; color: var(--white); }

.modal-body { padding: 22px 24px 26px; }

.modal-body .alert { margin-bottom: 18px; box-shadow: none; }

/* Small inline button (e.g. "Change Password"), not full-width. */
.btn-sm {
    width: auto;
    padding: 10px 22px;
    font-size: .92rem;
}

/* Title on the left, action button on the right. */
.card-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
}

/* Account tabs (Active / Deactivated). */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* The queue's status tabs sit above the filter bar. */
.queue-tabs {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.tab {
    text-decoration: none;
    font-size: .9rem;
    font-weight: 700;
    color: var(--muted);
    padding: 8px 16px;
    border-radius: 999px;
}

.tab:hover { background: #f1f4f9; }

.tab.active {
    color: var(--navy-700);
    background: #e8eefc;
}

/* Deactivate / reactivate area inside the edit modal. */
.danger-zone {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.btn-danger-solid { background: var(--red); }
.btn-danger-solid:hover { background: #b91c1c; }

.btn-reactivate { background: #166534; }
.btn-reactivate:hover { background: #14532d; }

.section-title.flush {
    margin: 0;
    padding: 0;
    border: none;
}

/* --- Collapsible card sections --- */
.collapse summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.collapse summary::-webkit-details-marker { display: none; }

.collapse .chevron {
    stroke: var(--muted);
    transition: transform .15s;
    flex-shrink: 0;
}

.collapse[open] .chevron { transform: rotate(180deg); }

/* Closed sections show only their title row, without the divider. */
.collapse:not([open]) summary.section-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* --- Standalone login page --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    position: relative;
    overflow: hidden;
}

/* Branded 4D-pattern drawing on the login page — same footprint as the old
   circuit art: pinned left in both directions, 55% wide, full height, faded
   toward the centre. Tiled at native size so it stays crisp; `multiply` drops
   the PNG's white ground into the page bg and the low opacity lands it on the
   same pale periwinkle (~#d3ddf0) the circuit used. */
.login-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    width: 55%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    /* Fade out toward the centre, exactly like the old circuit art. */
    -webkit-mask-image: linear-gradient(to right, #000 55%, transparent);
    mask-image: linear-gradient(to right, #000 55%, transparent);
}

/* One large 4D-mark grid (login-bg.png), pre-rendered high-res from the 4500px
   mark so a single non-repeating copy stays crisp — no tiling, no upscaling of a
   small source. The transparent PNG shows only navy marks; `opacity` fades them
   to the old circuit's faint periwinkle. The parent's gradient mask fades them
   toward the centre. One dial: `opacity` = faintness. */
.login-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('login-bg.png') top left / cover no-repeat;
    opacity: .22;
}

/* Top-right controls (account button + language toggle).
   direction: ltr pins the visual order in BOTH languages — without it RTL
   reverses the row and the account icon jumps to the other side. */
.login-topcontrols {
    position: fixed;
    top: 26px;
    right: 26px;
    z-index: 2;
    display: flex;
    direction: ltr;
    gap: 10px;
}

.login-lang {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 700;
    color: var(--white);
    background: var(--navy-800);
    border-radius: 999px;
    padding: 9px 20px;
    box-shadow: var(--shadow);
    transition: background .15s;
}

.login-lang:hover { background: var(--navy-900); }

.login-logout { box-shadow: var(--shadow); }

/* Loading bar shown while the card expands into the form. */
.login-loader {
    width: 100%;
    max-width: 260px;
    height: 4px;
    border-radius: 999px;
    background: #dbe3f2;
    overflow: hidden;
}

.login-loader-bar {
    display: block;
    height: 100%;
    width: 40%;
    border-radius: 999px;
    background: var(--navy-600);
    animation: loaderslide 1s ease-in-out infinite;
}

@keyframes loaderslide {
    0%   { margin-inline-start: -40%; }
    100% { margin-inline-start: 100%; }
}

/* "Logging Out" transition (logout_anim.js): the same login screen, shown
   as a full-screen overlay that fades in, then navigates to logout.php.
   Layout/background/brand all come from the reused .login-* classes; this
   only adds the fixed overlay framing + fade and the status line. */
.logout-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg);
    opacity: 0;
    transition: opacity .25s ease;
}

.logout-overlay.is-on { opacity: 1; }

.logout-msg {
    font-family: var(--font-head);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .12em;
    color: var(--navy-700);
}

/* Login card collapse + ticket form entrance. */
.login-card {
    transition: opacity .28s ease, transform .28s ease;
}

.login-card.is-collapsing {
    opacity: 0;
    transform: scale(.96) translateY(-8px);
}

.ticket-stage {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ticket-stage.is-entering {
    animation: stagein .4s ease both;
}

@keyframes stagein {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

/* Round account button, sits beside the language pill (top-right). */
.account-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    color: var(--navy-700);
    border: 1px solid var(--border);
    border-radius: 50%;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: background .15s, color .15s;
}

.account-btn:hover { background: #f1f4f9; color: var(--navy-900); }

/* "Welcome <name>, how can we help you?" above the tiles. */
.stage-welcome {
    margin: 0 0 20px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    text-align: center;
}

.stage-welcome:empty { display: none; }

/* Two big action tiles on the employee home. */
.tile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    width: 100%;
}

.tile {
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 150px;
    padding: 30px 18px;
    background: var(--white);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s, box-shadow .15s;
}

.tile:hover {
    background: var(--white);
    transform: translateY(-3px);
    box-shadow: 0 14px 34px rgba(16, 29, 78, .16);
}

.tile-icon {
    width: 46px;
    height: 46px;
    stroke: var(--navy-600);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stage-logout {
    display: inline-flex;
    margin-top: 22px;
}

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

/* Large, scrollable modal (holds the full ticket form). */
.modal-lg { max-width: 700px; }

dialog.modal { max-height: 92vh; }

/* Scrolls within the popup; min-height:0 lets a flex child actually shrink. */
.modal-body {
    overflow-y: auto;
    min-height: 0;
}

/* The header stays put while the body scrolls under it. */
.modal-head { flex-shrink: 0; }

/* The form partial keeps its card look on its own page, but inside a modal
   it should sit flush. */
.modal-body .card {
    background: none;
    box-shadow: none;
    padding: 0;
}

/* Form -> success crossfade inside the submit popup. */
.modal-swap { transition: opacity .24s ease; }
.modal-swap.swap-out { opacity: 0; }

.submit-success {
    opacity: 0;
    text-align: center;
    padding: 20px 4px 8px;
}

.submit-success.swap-in { opacity: 1; }

.submit-success-check {
    width: 66px;
    height: 66px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: #dcfce7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.submit-success-check svg {
    stroke: #166534;
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.submit-success.swap-in .submit-success-check { animation: pop .32s ease both; }

@keyframes pop {
    from { transform: scale(.6); opacity: 0; }
    to   { transform: scale(1);  opacity: 1; }
}

.submit-success-msg {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.6;
    margin: 0 0 22px;
}

.submit-success-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-ghost {
    background: #f1f4f9;
    color: var(--ink);
}

.btn-ghost:hover { background: #e6ebf3; }

.login-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.login-logo {
    width: 380px;
    max-width: 90%;
    height: auto;
    display: block;
    animation: logofade .45s ease both;
}

/* Gentle fade so switching EN/AR eases the new logo in (page reloads on toggle). */
@keyframes logofade {
    from { opacity: 0; transform: scale(.97); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .login-logo { animation: none; }
}

/* "Support" wordmark under the login logo. */
.login-tag {
    margin-top: -7rem;   /* pull up into the horizontal lockup's bottom padding */
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: .34em;
    text-indent: .34em;
    text-transform: uppercase;
    color: var(--navy-700);
}

.login-card {
    width: 100%;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(16, 29, 78, .10);
    padding: 28px 30px 30px;
}

.login-card h1 {
    margin: 0 0 22px;
    font-size: 1.2rem;
    font-weight: 800;
    text-align: center;
}

.login-card .alert { margin-bottom: 18px; box-shadow: none; }

.req { color: var(--red); }

.login-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0 20px;
}

.login-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.forgot-link {
    color: var(--navy-600);
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
}

.forgot-link:hover { text-decoration: underline; }

/* A <button> that has to sit beside .forgot-link and look like it. Needed
   because the action it triggers is a POST (it re-sends a code), and that must
   not be a link — the base button rule below is full-width and navy, which
   would read as a second primary action. */
.btn-link {
    width: auto;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--navy-600);
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-link:hover {
    background: none;
    text-decoration: underline;
}

/* Counting down. Muted and unclickable, but still readable — the number is the
   whole point of leaving it on screen. */
.btn-link:disabled {
    color: var(--muted);
    cursor: default;
}

.btn-link:disabled:hover { text-decoration: none; }

/* Rounded pill submit button (overrides the default full-width button). */
.btn-pill {
    width: auto;
    padding: 11px 30px;
    border-radius: 999px;
}

/* Revealed only when "Forgot password" is clicked (#forgot in the URL). */
.forgot-hint {
    display: none;
    margin: 16px 0 0;
    font-size: .84rem;
    color: var(--muted);
    text-align: center;
}

.forgot-hint:target { display: block; }

/* Helper text on a sign-in card that is meant to be READ, not revealed. Same
   look as .forgot-hint without the display:none — that one stays hidden until
   "Forgot password" targets it, which silently swallows anything else given
   the class. */
.login-note {
    margin: 16px 0 0;
    font-size: .84rem;
    color: var(--muted);
    text-align: center;
}

/* Secondary action on a sign-in card — an outlined pill, so the filled navy
   "Login" button stays the obvious primary. Written for <a> as well as
   <button>, since the OTP route is a link to another page. */
.btn-outline {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 12px;
    box-sizing: border-box;
    background: none;
    color: var(--navy-700);
    border: 1px solid var(--navy-600);
    border-radius: 999px;
    font-size: .95rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.btn-outline:hover {
    background: var(--navy-700);
    color: var(--white);
}

/* --- One-time code entry (otp_login.php) --- */
/* Way back out, above the heading. Quiet on purpose: it's an escape hatch, not
   somewhere we want people to go. */
.otp-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    /* Padded so the whole chip is the target — the words are as clickable as
       the chevron. The negative inline-start cancels the padding so the text
       still lines up with the card's edge. */
    padding: 6px 8px;
    margin: 0 0 14px -8px;
    color: var(--muted);
    font-size: .88rem;
    font-weight: 600;
    white-space: nowrap;       /* chevron and label never split across lines */
    text-decoration: none;
    border-radius: 8px;
    transition: background .15s, color .15s;
}

/* Both children are blocks of a known height, centred against each other —
   no baseline, no line-height slack, nothing left to drift. */
.otp-back .icon,
.otp-back span {
    display: block;
    line-height: 1;
}

[dir="rtl"] .otp-back { margin-left: 0; margin-right: -8px; }

.otp-back:hover {
    color: var(--navy-700);
    background: rgba(16, 29, 78, .06);
}

/* .icon defaults to 18px, which is taller than this label and rides above the
   text. Match the cap height instead. */
.otp-back .icon {
    width: 14px;
    height: 14px;
}

/* The chevron points "back", which is the other way round in Arabic. */
[dir="rtl"] .otp-back .icon { transform: scaleX(-1); }

/* Full-width primary action — the code screen has one thing to do, so the
   button says so rather than sharing a row with a secondary link. */
.btn-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 22px;
    border-radius: 999px;
    padding: 14px;
}

[dir="rtl"] .btn-block .icon { transform: scaleX(-1); }

/* "Didn't receive the code? Resend in 57s" — one sentence, so the button sits
   inline with the text rather than under it. */
.otp-resend-line {
    display: flex;
    justify-content: center;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

/* --- QR ticket form (qr_ticket.php) --- */

/* Final stage only. The first three are login-card sized and centre happily;
   the ticket form is much taller than the viewport and wants more width, so the
   page stops centring, starts from the top, and scrolls.

   overflow-x is pinned to hidden because the background art is deliberately
   wider than the page; naming overflow-y explicitly matters, since a `visible`
   alongside a `hidden` is computed to `auto` anyway. */
.qr-page-wide {
    align-items: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 100vh;
}

.qr-page-wide .login-wrap { max-width: 760px; }

/* "Log out" — the way to say "I'm done, forget me" without submitting
   anything. Present the whole time the person is verified, because the phone
   this runs on is often shared or borrowed. */
.qr-logout { align-self: center; }

.qr-done-foot {
    margin: 18px 0 0;
    text-align: center;
}

/* This page is reached by scanning a code, so most of its traffic is a phone
   held in one hand. The app's other pages are desktop-first and merely survive
   a small screen; here the small screen is the design target, so the padding is
   tightened to buy back horizontal room. */
@media (max-width: 560px) {
    .qr-page { padding: 16px 12px 28px; }
    .qr-page .login-wrap { gap: 18px; }
    .qr-page .login-card { padding: 24px 18px 26px; }
    .qr-page .card { padding: 20px 16px 26px; }

    /* iOS Safari zooms the whole page whenever a focused field is smaller than
       16px, and on a form this long that is a zoom-and-pan on every single
       field. The app's .96rem is kept everywhere else; only this page overrides
       it, because only this page is built to be filled in on a phone. */
    .qr-page input,
    .qr-page textarea,
    .qr-page select { font-size: 16px; }

    .qr-page textarea { min-height: 110px; }

    /* The language pill is fixed to the corner and would otherwise sit on top
       of the brand logo once the wrap starts at the top of a short screen. */
    .qr-page .login-brand { margin-top: 34px; }
}

/* Visually hidden, still read aloud. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Six single-character boxes rather than one field: it shows how many digits
   are expected, and each keystroke lands somewhere visibly its own. */
.otp-boxes {
    display: flex;
    justify-content: center;
    gap: 10px;
    direction: ltr;            /* a code reads left-to-right in both languages */
    margin-bottom: 4px;
}

.otp-box {
    width: 46px;
    height: 56px;
    padding: 0;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--white);
    color: var(--ink);
}

.otp-box:focus {
    outline: none;
    border-color: var(--navy-500);
    box-shadow: 0 0 0 3px rgba(16, 29, 78, .12);
}

@media (max-width: 420px) {
    .otp-boxes { gap: 6px; }
    .otp-box { width: 38px; height: 48px; font-size: 1.25rem; }
}

@media (max-width: 720px) {
    .login-topcontrols { top: 20px; right: 20px; }
    .login-bg { width: 100%; -webkit-mask-image: none; mask-image: none; }
}

/* --- Filter bar (staff queue) --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 22px;
}

.filter-field { min-width: 160px; }

.filter-field select,
.filter-field input { margin-bottom: 0; }

.filter-btn {
    width: auto;
    padding: 11px 26px;
}

/* --- Date-range calendar picker (dashboard filter) --- */
.daterange { position: relative; }

.daterange-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 210px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 14px;
    font: inherit;
    color: var(--ink);
    cursor: pointer;
}

.daterange-trigger:hover { border-color: var(--navy-500); }
.daterange-trigger .icon { color: var(--muted); }
.daterange-label { font-weight: 600; font-size: .9rem; white-space: nowrap; }

.daterange-pop {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-start: 0;
    z-index: 30;
    display: flex;
    gap: 14px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 14px;
}

.dr-presets {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 128px;
    border-inline-end: 1px solid var(--border);
    padding-inline-end: 12px;
}

.dr-preset {
    width: 100%;
    text-align: start;
    background: none;
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    font-size: .86rem;
    color: var(--ink);
    cursor: pointer;
}

.dr-preset:hover { background: #eef1f6; color: var(--navy-700); }

.dr-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.dr-title { font-weight: 700; font-size: .9rem; }

.dr-nav {
    display: inline-flex;
    padding: 4px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
}

.dr-nav:hover { background: #eef1f6; }
.dr-nav svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .dr-nav svg { transform: scaleX(-1); }

.dr-grid { display: grid; grid-template-columns: repeat(7, 34px); gap: 2px; }

.dr-dow {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    font-size: .72rem;
    font-weight: 700;
    color: var(--muted);
}

.dr-day {
    height: 34px;
    width: 34px;
    background: none;
    border: none;
    border-radius: 8px;
    font: inherit;
    font-size: .84rem;
    color: var(--ink);
    cursor: pointer;
}

.dr-day:hover:not(:disabled) { background: #eef1f6; }
.dr-day:disabled { color: #cbd3e0; cursor: default; }
.dr-day.is-today { font-weight: 800; color: var(--navy-700); }
.dr-day.in-range { background: #e8eefc; border-radius: 0; }
.dr-day.is-start,
.dr-day.is-end { background: var(--navy-600); color: #fff; font-weight: 700; }

@media (max-width: 560px) {
    .daterange-pop { flex-direction: column; gap: 10px; }
    .dr-presets {
        flex-direction: row;
        flex-wrap: wrap;
        min-width: 0;
        border-inline-end: none;
        border-bottom: 1px solid var(--border);
        padding-inline-end: 0;
        padding-bottom: 10px;
    }
    .dr-preset { width: auto; }
}

.form-hint {
    margin: 14px 0 0;
    font-size: .84rem;
    color: var(--muted);
    text-align: center;
}

/* --- Gradient banner --- */
.banner {
    background: linear-gradient(120deg, var(--navy-800), var(--navy-500));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--white);
    padding: 26px 28px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.banner-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .25);
}

.banner-icon .icon { width: 24px; height: 24px; }

.banner h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
}

.banner p {
    margin: 2px 0 0;
    font-size: .92rem;
    color: rgba(255, 255, 255, .78);
}

/* --- White card --- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 30px 32px;
}

.section-title {
    margin: 0 0 22px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
}

form .section-title + label { margin-top: 0; }

form .section-title:not(:first-child) { margin-top: 34px; }

/* --- Form controls --- */
label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: .86rem;
    color: var(--ink);
}

input, textarea, select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .96rem;
    margin-bottom: 18px;
    font-family: inherit;
    color: var(--ink);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
}

/* Custom caret so <select> matches the theme instead of the OS default. */
select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%231e3a8a' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    padding-right: 38px;
}

[dir="rtl"] select {
    background-position: left 14px center;
    padding-right: 13px;
    padding-left: 38px;
}

/* A <select>'s option list is drawn by the OS, which can't use our downloadable
   web font (Vazirmatn) and won't always fall through to the next family — so in
   Arabic the options render blank while page text is fine. Lead the select/
   option stack with fonts that are actually installed on the machine AND carry
   Arabic glyphs (Segoe UI / Tahoma on Windows), so the dropdown is never empty. */
select,
select option {
    font-family: "Segoe UI", Tahoma, "Vazirmatn", system-ui, "Noto Naskh Arabic", sans-serif;
}

/* LTR-content inputs (phone, email, device number) keep dir="ltr" so their
   text never scrambles — but in Arabic they should sit at the right edge like
   every other RTL field, not pinned to the left. Align them to the right in an
   RTL page; English (an LTR page) keeps its default left, untouched. */
[dir="rtl"] input[dir="ltr"],
[dir="rtl"] textarea[dir="ltr"] { text-align: right; }

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--navy-600);
    box-shadow: 0 0 0 3px rgba(43, 79, 184, .16);
}

textarea { resize: vertical; min-height: 130px; }

/* Live validation feedback (phone typed in real time). */
input.is-invalid { border-color: var(--red); }
input.is-invalid:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .15);
}

input.is-valid { border-color: var(--accent); }
input.is-valid:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
}

.field-hint {
    margin: -13px 0 15px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--red);
}

/* Profile-sourced fields: visibly locked, skipped by the tab order feel. */
input[readonly] {
    background: #f1f4f9;
    color: var(--muted);
    cursor: default;
}

input[readonly]:focus {
    border-color: var(--border);
    box-shadow: none;
}

.locked-note {
    margin: -6px 0 18px;
    font-size: .8rem;
    color: var(--muted);
}

button {
    width: 100%;
    background: var(--navy-700);
    color: var(--white);
    border: none;
    padding: 13px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, transform .05s;
}

button:hover  { background: var(--navy-800); }
button:active { transform: translateY(1px); }

/* --- Ticket tables --- */
.table-wrap { overflow-x: auto; }

.ticket-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

.ticket-table th {
    text-align: start;
    font-size: .8rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.ticket-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.ticket-table tbody tr:hover { background: #f7f9fc; }

.cell-title {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-link {
    color: var(--navy-600);
    font-weight: 700;
    text-decoration: none;
}

.table-link:hover { text-decoration: underline; }

.empty-note {
    margin: 0;
    color: var(--muted);
}

/* --- Status / priority pills --- */
.pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-new         { background: #e8eefc; color: var(--navy-700); }
.status-assigned    { background: #ede9fe; color: #5b21b6; }
.status-in_progress { background: #fef3c7; color: #92400e; }
.status-on_hold     { background: #f1f4f9; color: var(--muted); }
.status-resolved    { background: #dcfce7; color: #166534; }
.status-closed      { background: #e5e7eb; color: #374151; }

.role-pill { background: #e8eefc; color: var(--navy-700); }

.row-inactive td { opacity: .55; }

.cell-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.inline-form { display: inline; }

/* Small text-style action buttons inside tables. */
.btn-table {
    width: auto;
    padding: 0;
    background: none;
    border: none;
    color: var(--navy-600);
    font-size: .92rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-table:hover { background: none; text-decoration: underline; }

.btn-table.btn-danger { color: var(--red); }

.form-cancel {
    display: block;
    margin-top: 14px;
    text-align: center;
}

.prio-low      { background: #f1f4f9; color: var(--muted); }
.prio-medium   { background: #e8eefc; color: var(--navy-700); }
.prio-high     { background: #ffedd5; color: #9a3412; }
.prio-critical { background: #fee2e2; color: #b91c1c; }

/* Past its SLA deadline and still not resolved — deliberately loud. */
.pill-late {
    background: var(--red);
    color: var(--white);
    margin-inline-start: 6px;
}

/* Account is locked out of sign-in (too many failed attempts). */
.pill-locked {
    background: var(--red-bg);
    color: var(--red);
    margin-inline-start: 6px;
}

/* Actions cell on the accounts table: Unlock (when locked) sits before Edit.
   This must stay a real table cell. `display: flex` on a <td> takes it out of
   table layout, so it no longer stretches to the row's height and draws its own
   border-bottom at a different offset from the other cells — the divider lines
   come out visibly staggered. The two controls are laid out inline instead, and
   the cell keeps the `vertical-align: middle` it inherits from .ticket-table td. */
.row-actions {
    white-space: nowrap;
}

/* Stands in for the old flex `gap`: spaces Edit away from Unlock when an
   account is locked, and adds nothing when Edit is on its own. */
.row-actions > * + * {
    margin-inline-start: 14px;
}

.inline-unlock {
    display: inline-block;
    vertical-align: middle;
}

.row-actions .table-link { vertical-align: middle; }

/* Unlock is a <button> wearing .table-link — strip the native chrome and tint
   it red so it reads as the recovery action next to the navy Edit link. */
.btn-unlock {
    padding: 0;
    background: none;
    border: none;
    font: inherit;
    font-weight: 700;
    color: var(--red);
    cursor: pointer;
}

.btn-unlock:hover { text-decoration: underline; }

/* --- Attachments --- */
input[type="file"] {
    padding: 9px 11px;
    background: #f7f9fc;
    cursor: pointer;
}

.attach-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 26px;
}

.attach-thumb {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: block;
    transition: transform .12s;
}

.attach-thumb:hover { transform: scale(1.03); }

/* --- Ticket detail --- */
.detail-grid { margin-bottom: 26px; }

.detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.detail-label {
    font-size: .86rem;
    font-weight: 700;
    color: var(--muted);
}

/* The reported issue, in the ticket popup. Free text, so it sits below the
   grid as a block instead of squeezing into a label/value row — and
   pre-wrap keeps the reporter's own line breaks, which are often the
   difference between a readable list of steps and one run-on sentence. */
.detail-desc {
    margin-bottom: 26px;
}

.detail-desc p {
    margin: 6px 0 0;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;   /* a pasted URL or log line can't widen the popup */
}

/* Read-only account details: greyed to signal they can't be edited here. */
.detail-readonly .detail-row span { color: var(--muted); }

.ticket-description {
    margin: 0 0 26px;
    line-height: 1.7;
}

.back-link {
    display: inline-block;
    color: var(--navy-600);
    font-weight: 700;
    text-decoration: none;
}

.back-link:hover { text-decoration: underline; }

/* Prominent back button at the top of the ticket detail. */
.back-link.back-top { margin-bottom: 16px; }

/* --- Queue preview popup --- */
.modal-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 0 24px 24px;
}

/* Assignment section, pinned to the top of the preview popup. */
.preview-assign {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}
.preview-assign .preview-note { margin-top: 0; }

/* Assign-to-me and the "Assign to…" picker share the row as equal, aligned
   halves (same width and height). */
.pv-assign-controls { display: flex; align-items: stretch; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.pv-assign-controls > form { flex: 1 1 150px; display: flex; }
.pv-assign-controls .pv-assign-btn { flex: 1; min-width: 0; text-align: center; }
.pv-assign-pick select {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    font-size: .92rem;
}

/* The [hidden] attribute must win over the flex/block display above. */
.pv-assign-controls[hidden], .pv-unassign[hidden] { display: none; }

/* "Unassign" — a red button under the "Assigned to…" note. */
.pv-unassign { display: block; margin-top: 12px; }
.action-btn.action-unassign { background: #b91c1c; }
.action-btn.action-unassign:hover { background: #7f1d1d; }

.preview-note {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

/* Highlighted when opening will claim the (unassigned) ticket. */
.preview-note.preview-note-claim {
    color: var(--navy-600);
    font-weight: 600;
}

/* --- Alerts --- */
.alert {
    padding: 13px 18px;
    border-radius: 10px;
    font-size: .9rem;
    border-inline-start: 4px solid transparent;
    box-shadow: var(--shadow);
}

.alert-success {
    background: #eefaf2;
    color: #14532d;
    border-inline-start-color: var(--accent);
}

.alert-error {
    background: var(--red-bg);
    color: #9b1c1c;
    border-inline-start-color: var(--red);
}

.alert-error ul { margin: 6px 0 0; padding-inline-start: 18px; }

/* --- RTL text direction --- */
[dir="rtl"] body,
body[dir="rtl"] { text-align: right; }

/* --- Small screens: sidebar becomes a top strip --- */
@media (max-width: 900px) {
    .layout { flex-direction: column; }

    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 14px 18px;
        gap: 16px;
    }

    .brand { padding: 0; border-bottom: none; }
    .brand-logo { width: auto; height: 44px; margin: 0; }

    .nav { flex-direction: row; }
    .nav-item { padding: 9px 14px; }
    .nav-item.active { box-shadow: none; }

    .main { padding: 16px 14px 32px; }
}

/* --- Performance dashboard --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-tile {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-num {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--navy-800);
    line-height: 1.1;
}

.stat-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--muted);
}

/* The Late tile leans on the alert red so a non-zero count reads at a glance. */
.stat-late .stat-num { color: var(--red); }

.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    margin-bottom: 20px;
}

.bar-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bar-row {
    display: grid;
    grid-template-columns: 130px 1fr 34px;
    align-items: center;
    gap: 12px;
}

.bar-label {
    font-size: .84rem;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-track {
    background: #eef1f6;
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
}

.bar-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--navy-600);
    min-width: 2px;
    transition: width .3s ease;
}

.bar-num {
    font-size: .84rem;
    font-weight: 700;
    color: var(--muted);
    text-align: end;
}

/* --- Dashboard charts: donuts, stacked SLA bars, daily-trend graph ---
   All hand-drawn (conic-gradient + inline SVG) — no chart library. */
.dash-wide { margin-bottom: 20px; }

.chart-row {
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
}

.donut {
    width: 190px;
    height: 190px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

/* The readable centre: a white disc over the middle of the pie. */
.donut::after {
    content: '';
    position: absolute;
    inset: 23%;
    background: var(--white);
    border-radius: 50%;
}

/* Confined to the white disc (same inset), so the label can never spill
   over the ring — it wraps inside the hole instead, in both languages. */
.donut-center {
    position: absolute;
    inset: 23%;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6px;
}

.donut-center strong {
    font-size: 1.45rem;
    line-height: 1.1;
    color: var(--ink);
}

.donut-center small {
    color: var(--muted);
    font-size: .7rem;
    line-height: 1.3;
    max-width: 100%;
    margin-top: 5px;
}

.chart-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
    font-size: .88rem;
    min-width: 0;
}

.chart-legend li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-num {
    color: var(--muted);
    font-weight: 600;
}

/* Horizontal variant under the trend graph / stacked bars. */
.legend-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 12px;
}

/* Stacked SLA bar: segments sit side by side inside the usual track. */
.bar-row-sla { grid-template-columns: 130px 1fr 120px; }
.bar-stack   { display: flex; }
.stack-seg   { height: 100%; }

/* Monthly trend graph. */
.trend-wrap {
    direction: ltr;
    position: relative;
}

.trend-svg {
    display: block;
    width: 100%;
    height: auto;
}

/* Floating hover tooltip that follows the cursor over the bars. */
.chart-tip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    background: var(--navy-900);
    color: #fff;
    font-size: .78rem;
    line-height: 1.3;
    padding: 6px 9px;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(16, 29, 78, .28);
}

.chart-tip strong { font-weight: 700; }
.chart-tip strong:first-child { display: block; opacity: .85; font-weight: 600; }

.trend-grid {
    stroke: var(--border);
    stroke-width: 1;
}

.trend-tick {
    fill: var(--muted);
    font-size: 11px;
}

/* Grouped bars (created vs closed per month). */
.gbar { transition: opacity .12s; cursor: pointer; }
.gbar:hover { opacity: .78; }
.gbar-created { fill: var(--navy-700); }
.gbar-closed  { fill: var(--accent); }

/* Bars pick up the same palette as the status / priority pills. */
.bar-status-new         { background: var(--navy-700); }
.bar-status-assigned    { background: #7c3aed; }
.bar-status-in_progress { background: #d97706; }
.bar-status-on_hold     { background: #94a3b8; }
.bar-status-resolved    { background: #16a34a; }
.bar-status-closed      { background: #6b7280; }

.bar-prio-low      { background: #94a3b8; }
.bar-prio-medium   { background: var(--navy-600); }
.bar-prio-high     { background: #ea580c; }
.bar-prio-critical { background: var(--red); }

.dash-tech { margin-bottom: 20px; }

@media (max-width: 900px) {
    .dash-grid { grid-template-columns: 1fr; }
    .bar-row { grid-template-columns: 110px 1fr 30px; }
    .bar-row-sla { grid-template-columns: 110px 1fr 96px; }
}