/* ==========================================================================
   infact.ticket — mobile layer.

   EVERY rule in this file lives inside the single media query below. A
   browser rendering at >= 768px viewport width never evaluates any of it,
   so desktop rendering is unaffected by construction. Do not add a rule
   outside this block, and do not change the breakpoint.

   Loaded last in Components/App.razor, after css/app.css (generated
   Tailwind) and css/ticket-shared.css (the hand-written desktop styles),
   so on equal-specificity ties with either of those files, this file wins.
   Some declarations still need !important — only where they must beat an
   *inline* style attribute in the markup, which no amount of source order
   or specificity can otherwise overcome.
   ========================================================================== */

@media (max-width: 767.98px) {

/* --------------------------------------------------------------------------
   0. Global safety net — applies to every page, including Settings and
      Users, which get no page-specific treatment below.
   -------------------------------------------------------------------------- */

/* `clip`, not `hidden`: overflow-x:hidden on html/body would coerce
   overflow-y to `auto`, making <body> the scroll container and breaking the
   `sticky top-0` AppHeader. `clip` does not establish a scroll container. */
html, body { overflow-x: clip; }
body { overflow-wrap: break-word; }

/* Kills iOS Safari's zoom-on-focus for every text input on every page (it
   triggers whenever a focused field computes to < 16px font-size). */
input, select, textarea { font-size: 16px; }

/* Guarantee every existing overflow-x-auto wrapper (Settings' and Users'
   tables, Statistics' tables, ChartCard's data tables, HeatmapGrid) can
   actually shrink and that a table inside one scrolls instead of squeezing
   down to unreadable column widths. */
.overflow-x-auto { min-width: 0; -webkit-overflow-scrolling: touch; }
.overflow-x-auto table { min-width: 640px; }

/* vh -> dvh. Mobile Safari resolves vh against the *large* viewport (URL bar
   hidden); with the URL bar visible a vh-sized element is taller than the
   visible area and its bottom (often a save/submit button) is unreachable.
   The vh value is kept first as the fallback for browsers without dvh. */
.min-h-screen   { min-height: 100vh; min-height: 100dvh; }
.h-screen       { height: 100vh; height: 100dvh; }
.h-\[90vh\]     { height: 90vh; height: 90dvh; }
.max-h-\[90vh\] { max-height: 90vh; max-height: 90dvh; }

/* Every modal overlay in the app uses this exact idiom (~15 dialogs). Center
   vertically only when the dialog is short; long ones anchor to the top
   instead of wasting space above/below while clipping their own content. */
.fixed.inset-0.bg-black.bg-opacity-50.flex.items-center.justify-center {
    align-items: flex-start;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    overflow-y: auto;
}

/* Named min-w-[] offenders. Deliberately enumerated, not a [class*="min-w-["]
   wildcard — that would also defeat HeatmapGrid's intentional min-w-[680px]
   (the scroll width inside its own overflow-x-auto) and HeaderIconButton's
   min-w-[18px] notification badge. */
.min-w-\[210px\] { min-width: 0; width: 100%; }   /* Tickets.razor — "Neues Ticket" button */
.min-w-\[220px\] { min-width: 100%; }             /* MyWork.razor — filter inputs */
.min-w-\[160px\] { min-width: 100%; }             /* Tickets.razor / TicketDetailDialog — reminder note field */
.min-w-\[18rem\] { min-width: 0; }                /* TicketAssignment.razor — KPI grid */
.min-w-\[10rem\] { min-width: 0; flex: 1; }       /* ReminderCalendar.razor — month label */

/* Larger, padding-based (non-distorting) tap target for the "×" dialog close
   buttons. Padding + matching negative margin grows the hit box without
   moving the glyph or changing its visual size. */
button[aria-label="Schließen"] {
    padding: 0.75rem;
    margin: -0.75rem;
}

/* --------------------------------------------------------------------------
   1. Padding-chain collapse. The standard shell nests py-8 / max-w-*.px-4 /
      p-6 / p-4 several levels deep; each level costs the same fraction of a
      much smaller screen. Recovers ~90px of usable width on Dashboard,
      MyWork, Tickets, Statistics and the ticket dialogs simultaneously.
   -------------------------------------------------------------------------- */

.ticket-overview-shell { padding: 0.5rem; }
.saas-panel.p-6 { padding: 0.75rem; }
.saas-panel.p-4 { padding: 0.625rem; }

.max-w-7xl.px-4,
.max-w-6xl.px-4,
.max-w-2xl.px-4,
.max-w-xl.px-4,
.max-w-\[100rem\].px-4 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* --------------------------------------------------------------------------
   2. Ticket list: compact table -> card stack.
      Rendered by both Tickets.razor and MyWork.razor via TicketListView.
      Selectors key off [data-label], never :nth-child — the Flag column is
      conditional on flagsEnabled, so positional selectors would silently
      mislabel every cell on lists with flags turned off.
   -------------------------------------------------------------------------- */

/* The wrapper is overflow:hidden on desktop; cards need room for their
   shadow and don't need the horizontal clip any more. */
.compact-table-wrap {
    overflow: visible;
    padding: 0.5rem;
}

/* display:block dissolves the table formatting context, which makes
   table-layout:fixed inert (nothing to fix the layout of) and makes the
   hidden <thead>'s inline width:N% unreachable. */
.compact-table {
    display: block;
    width: 100%;
    font-size: 0.875rem;
    border-collapse: separate;
    border-spacing: 0;
}

.compact-table thead { display: none; }
.compact-table tbody { display: block; }

/* ---- row -> card ---- */
.compact-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    position: relative;               /* containing block for the flag dot */
    min-height: 44px;
    margin: 0 0 0.625rem;
    padding: 0.625rem 0.75rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;        /* replaces .saas-table's border-bottom row rule */
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    -webkit-tap-highlight-color: transparent;
}

.compact-table tbody tr:last-child { margin-bottom: 0; }

/* Prevent a sticky :hover state (iOS keeps :hover active after a tap). */
.compact-table tbody tr:hover { background: #ffffff; }
.compact-table tbody tr:active { background: #f1f5f9; }

/* Selection-mode highlight. Tailwind's .bg-blue-50 is (0,1,0); the card's own
   background above is also (0,1,0) but on the same element — restore the
   highlight at higher specificity so it isn't lost when both apply. */
.compact-table tbody tr.bg-blue-50 {
    background: #eff6ff;
    border-color: #bfdbfe;
}

/* ---- cell -> label / value row ---- */
/* The two !important declarations are the only ones needed in this whole
   file to beat an inline style: every <td> carries inline
   white-space:nowrap and a per-column inline padding (both legitimate on
   desktop — the padding overrides the 1280/1024px shrink queries in
   ticket-shared.css, so it can't just be deleted from the markup). */
.compact-table tbody td {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    width: auto;
    min-width: 0;
    border: 0;
    box-sizing: border-box;
    padding: 2px 0 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-height: 1.4;
}

/* Kunde / Verfasser / Programm / Modul carry Tailwind's .truncate on the <td>
   itself — undo the single-line ellipsis so wrapped text is fully visible. */
.compact-table tbody td.truncate {
    overflow: visible;
    text-overflow: clip;
}

/* ---- data-label gutter ---- */
.compact-table tbody td::before {
    content: attr(data-label);
    flex: 0 0 5rem;
    color: #6b7280;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.5;
}

/* --- Flag: small dot pinned to the card corner, out of flow --- */
.compact-table tbody td[data-label="Flag"] {
    position: absolute;
    top: 0.5rem;
    right: 0.625rem;
    padding: 0 !important;
    min-height: 0;
}
.compact-table tbody td[data-label="Flag"]::before { content: none; }

/* --- Titel: full-width wrapping headline, no label --- */
.compact-table tbody td[data-label="Titel"] {
    order: 1;
    flex: 0 0 100%;
    display: block;
    padding: 0 1.25rem 0.125rem 0 !important;   /* right gap clears the flag dot */
    font-size: 0.9375rem;
}
.compact-table tbody td[data-label="Titel"]::before { content: none; }
.compact-table tbody td[data-label="Titel"] .truncate {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: break-word;
}
.compact-table tbody td[data-label="Titel"] .flex-wrap { margin-top: 0.3rem; }

/* --- meta line: #ID · Erstellt · Kommentare --- */
.compact-table tbody td[data-label="ID"],
.compact-table tbody td[data-label="Erstellt"],
.compact-table tbody td[data-label="Kommentare"] {
    flex: 0 0 auto;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
}
.compact-table tbody td[data-label="ID"]          { order: 2; }
.compact-table tbody td[data-label="Erstellt"]    { order: 3; }
.compact-table tbody td[data-label="Kommentare"]  { order: 4; }
.compact-table tbody td[data-label="ID"]::before,
.compact-table tbody td[data-label="Erstellt"]::before,
.compact-table tbody td[data-label="Kommentare"]::before { content: none; }
.compact-table tbody td[data-label="Erstellt"] > div { display: inline; }

.compact-table tbody td[data-label="ID"]::after,
.compact-table tbody td[data-label="Erstellt"]::after {
    content: "";
    width: 3px; height: 3px;
    margin-left: 0.4rem;
    border-radius: 999px;
    background: #cbd5e1;
    align-self: center;
}

/* --- Kunde: un-hidden on mobile (hidden only for horizontal scarcity on
       desktop, which doesn't apply to a vertical card). (0,3,2) beats
       .compact-hide-md's (0,1,0) display:none regardless of source order. --- */
.compact-table tbody td.compact-hide-md[data-label="Kunde"] {
    display: flex;
    order: 5;
    flex: 0 0 100%;
    padding-top: 0.25rem !important;
    color: #334155;
}

/* --- chip line: Prio | Status | Abn. --- */
.compact-table tbody td[data-label="Prio"],
.compact-table tbody td[data-label="Status"],
.compact-table tbody td[data-label="Abn."] {
    flex: 0 0 auto;
    align-items: center;
    margin-top: 0.25rem;
}
.compact-table tbody td[data-label="Prio"]   { order: 6; }
.compact-table tbody td[data-label="Status"] { order: 7; }
.compact-table tbody td[data-label="Abn."]   { order: 8; }
.compact-table tbody td[data-label="Prio"]::before,
.compact-table tbody td[data-label="Status"]::before { content: none; }

/* The Abn. cell is empty unless the ticket is resolved and acceptance can be
   set — only show its label when a checkbox actually renders. */
.compact-table tbody td[data-label="Abn."]::before { content: none; }
.compact-table tbody td[data-label="Abn."]:has(input)::before {
    content: attr(data-label);
    flex: 0 0 auto;
    margin-right: 0.15rem;
}
.compact-table tbody td[data-label="Abn."] {
    min-height: 44px;
    padding: 0 0.5rem 0 0 !important;
}
.compact-table tbody td[data-label="Abn."] input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin: 0;
}

/* Ticket toolbar (sort / view-mode / page size) and pagination — none of
   these wrap on desktop because they never need to; give them room here. */
.list-toolbar-actions { flex-wrap: wrap; row-gap: 0.5rem; }
.pagination-row { flex-direction: column; align-items: stretch; gap: 0.75rem; }
.pagination-controls { flex-wrap: wrap; justify-content: center; }

/* Detailed-view (non-compact) cards: header row and action buttons. */
.card-header-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.card-header-actions { margin-left: 0; flex-wrap: wrap; }
.card-action-row { flex-wrap: wrap; }
.card-action-row > button { flex: 1 1 auto; }

/* --------------------------------------------------------------------------
   3. Dialogs.
   -------------------------------------------------------------------------- */

/* TicketDetailDialog's 5-tab bar: 873px of whitespace-nowrap tabs in a 343px
   shell, clipped by the shell's own overflow-hidden. Let it scroll instead —
   this alone makes 3 of the 5 tabs reachable for the first time on a phone.
   whitespace-nowrap is kept: wrapping 5 tabs would produce a ~200px bar. */
nav.flex.-mb-px.px-6 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
nav.flex.-mb-px.px-6::-webkit-scrollbar { display: none; }
nav.flex.-mb-px.px-6 button { flex: 0 0 auto; }

/* The one dialog with a fixed (not max) height — give it breathing room now
   that the overlay no longer force-centers it. */
.h-\[90vh\] { margin: 0.5rem; }

/* Nested max-h-[50vh] inside the merge dialog's own max-h-[90vh] — a
   scroll-trap on touch (a swipe scrolls the inner list, not the dialog). */
.max-h-\[50vh\] { max-height: none; }

/* TicketInfoForm: halve the forced minimum heights (780px combined on
   desktop) — inside a ~480px-tall mobile dialog that meant three full
   screens of scrolling before reaching the attachments section. */
.min-h-\[320px\] { min-height: 160px; }
.min-h-\[240px\] { min-height: 140px; }
.min-h-\[220px\] { min-height: 140px; }

/* .resizable-contenteditable's own max-height:70vh (ticket-shared.css) is a
   second nested scroll-trap inside the dialog's overflow-y-auto. */
.resizable-contenteditable { max-height: none; }

/* Sticky action bar: tighter padding on a narrow screen. */
.ticket-modal-actionbar { padding: 0.625rem 0.75rem; gap: 0.5rem; }

/* Attachment rows: filename + actions no longer fit on one line. */
.flex.items-center.justify-between.bg-gray-50.px-3.py-2.rounded.border {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

/* "(Bilder können ... Strg+V)" hints are meaningless without a keyboard. */
.text-gray-500.text-xs.ml-2.font-normal { display: none; }

/* --------------------------------------------------------------------------
   4. Dashboard.
   -------------------------------------------------------------------------- */

.dash-time-row { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
.dash-user-info { min-width: 0; overflow-wrap: anywhere; }
.dash-ticket-desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   5. MyWork ("Meine Arbeit").
   -------------------------------------------------------------------------- */

.mw-dev-picker-row { flex-direction: column; align-items: stretch; gap: 0.75rem; }
.mw-time-row { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
.mw-active-actions { flex-direction: column; align-items: stretch; }
.mw-paused-row { flex-direction: column; align-items: stretch; gap: 0.75rem; }
.mw-paused-actions { margin-left: 0; text-align: left; }
.mw-diary-filters { flex-direction: column; align-items: stretch; gap: 0.75rem; }
.mw-diary-entry-actions { flex-direction: column; align-items: flex-start; text-align: left; gap: 0.375rem; }
.mw-worklog-grid { grid-template-columns: 1fr; }

/* --------------------------------------------------------------------------
   6. ReminderCalendar — the one page that needs a layout change, not just
      CSS tweaks: a 7-column month grid has no room to show anything at
      375px, so it becomes a vertical agenda list of the days that matter.
   -------------------------------------------------------------------------- */

.cal-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
.cal-header-nav { flex-wrap: wrap; }

.cal-weekdays { display: none; }
.cal-grid { display: block; }

.cal-day {
    display: block;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.625rem 0.75rem;
}
/* Prev/next-month filler cells carry no information in a list view. */
.cal-day.cal-outside { display: none; }

.cal-day::before {
    content: attr(data-date);
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #64748b;
    margin-bottom: 0.375rem;
}

.cal-chip {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    min-height: 32px;
    display: flex;
    align-items: center;
}

/* --------------------------------------------------------------------------
   7. NotificationSettings.
   -------------------------------------------------------------------------- */

.ns-heading { overflow-wrap: break-word; font-size: 1.5rem; }
.toggle-row { padding-left: 1rem; padding-right: 1rem; }
.toggle-label { padding: 0.5rem 0; }

/* --------------------------------------------------------------------------
   8. Login.
   -------------------------------------------------------------------------- */

/* Unique to Login among the app's min-h-screen/flex/items-center/justify-
   center shells (the loading spinners on every other page use the same
   three classes without px-4). Anchor to the top instead of centering, so
   the on-screen keyboard doesn't push the card off-screen. */
.min-h-screen.flex.items-center.justify-center.px-4 {
    align-items: flex-start;
    padding-top: 3rem;
}
.login-submit-btn { padding-top: 0.75rem; padding-bottom: 0.75rem; }

/* --------------------------------------------------------------------------
   9. MainLayout / AppHeader.
   -------------------------------------------------------------------------- */

/* The reminder dropdown is absolutely positioned ~88px in from the header's
   right edge; w-80 (320px) is already narrower than max-w-[90vw] (337px at
   375px), so the clamp never binds and ~33px of the panel — including the
   left edge of every ticket title — renders off-screen to the left. */
.reminder-dropdown-panel {
    position: fixed;
    top: 4rem;
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    max-width: none;
    margin-top: 0;
}

.activity-drawer-header { flex-wrap: wrap; gap: 0.5rem; }
.activity-drawer-header-actions { flex-wrap: wrap; }

#blazor-error-ui .flex.items-center.justify-between { flex-wrap: wrap; gap: 0.5rem; }

/* Header: a little tighter so a 99+ badge doesn't tip the icon cluster into
   overflow (it fits today with only ~13px of slack). */
.grid-cols-\[auto_1fr_auto\] { gap: 0.5rem; }
.px-4.lg\:px-6 { padding-left: 0.75rem; padding-right: 0.75rem; }

/* --------------------------------------------------------------------------
   10. TicketAssignment (Dispatch Center).
   -------------------------------------------------------------------------- */

/* Two sibling max-h-[68vh] panes stack (grid-cols-1 base) into nested
   scroll-traps: a swipe scrolls whichever pane is under the finger instead
   of the page, so the Inspector below is unreachable. */
.max-h-\[68vh\] { max-height: none; }

/* --------------------------------------------------------------------------
   11. Statistics + charts.
   -------------------------------------------------------------------------- */

/* Time-range segmented control: 356px of min-content in 343px, clipped by
   the group's own overflow-hidden. It's the page's primary control. */
div[role="group"][aria-label="Zeitraum"] {
    flex-wrap: wrap;
    overflow: visible;
    border-radius: 0.5rem;
}
div[role="group"][aria-label="Zeitraum"] button {
    border-radius: 0.375rem;
}

/* ChartCard header: Actions (the dimension-tab group) is flex-shrink-0 while
   the title has min-w-0, so the tabs squash the title to one character per
   line. Stack them instead. */
.chartcard-header { flex-direction: column; align-items: stretch; gap: 0.5rem; }
.chartcard-actions { flex-shrink: 1; flex-wrap: wrap; }

/* StatTile: keep the 2-column grid (right call for scanning 8 KPIs) but
   shrink the chrome so labels don't wrap to 3 lines each. */
.stattile-label { letter-spacing: normal; font-size: 0.6875rem; }
.stattile-delta-label { display: none; }

/* Chart.js needs maintainAspectRatio:false + an explicit pixel height on its
   wrapper (see ChartCanvas.razor) — do not remove that inline height, it
   prevents the canvas from growing unboundedly on resize. Just guarantee the
   canvas itself never exceeds its wrapper's width. */
.relative.w-full > canvas { max-width: 100%; }

} /* end @media (max-width: 767.98px) */
