/* Detaljhuvudets överkant (Personal, Kontor, ärendevyerna): temat (nordic-dawn.css:208 m.fl.) tvingar border-color till grå
   med !important, så agent-/ärendefärgens 3px-kant (inline) blev en hård grå linje (Patrik: "hård kant mer än färg").
   Nu: kanten i egen färg, nedtonad; underkanten svagare. */
@media (min-width: 769px) {
  html body .detail-header-top.detail-header-top {
    border-top-color: color-mix(in srgb, var(--agent-color, var(--detail-accent, var(--accent-primary))) 50%, transparent) !important;
    border-bottom-color: color-mix(in srgb, var(--border-color) 30%, transparent) !important;
  }
}
/* Färgväljarens ruta (agent/kontor/profil): rund och mjuk som paletten i stället för en hård fyrkant. */
@media (min-width: 769px) {
  html body input[type="color"]#agent-color-picker, html body input[type="color"]#new-agent-color,
  html body input[type="color"]#no-color-picker, html body input[type="color"]#inp-office-color-inline,
  html body input[type="color"]#pref-color {
    width: 26px !important; height: 26px !important; padding: 0 !important; border: none !important;
    border-radius: 50% !important; overflow: hidden; background: transparent !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-primary) 8%, transparent) !important;
  }
  html body input[type="color"]#agent-color-picker::-webkit-color-swatch-wrapper, html body input[type="color"]#new-agent-color::-webkit-color-swatch-wrapper,
  html body input[type="color"]#no-color-picker::-webkit-color-swatch-wrapper, html body input[type="color"]#inp-office-color-inline::-webkit-color-swatch-wrapper,
  html body input[type="color"]#pref-color::-webkit-color-swatch-wrapper { padding: 0; }
  html body input[type="color"]#agent-color-picker::-webkit-color-swatch, html body input[type="color"]#new-agent-color::-webkit-color-swatch,
  html body input[type="color"]#no-color-picker::-webkit-color-swatch, html body input[type="color"]#inp-office-color-inline::-webkit-color-swatch,
  html body input[type="color"]#pref-color::-webkit-color-swatch { border: none; border-radius: 50%; }
}
/* Huvudets pills (AGENT, @användare, kontorets id-pills) var bara text + kant, utan fyllning
   (Patrik: "ingen färg alls på pills där … samma färg som aktiv och arkiverad") ⇒ samma platta som räknarpillsen. */
@media (min-width: 769px) {
  /* AT-242: märken och kontroller hålls ihop. ID-texten får radbrytas utan avkortning. */
  html body #view-admin #admin-detail-content .detail-header-top .header-pills-row { flex-wrap: nowrap !important; row-gap: 6px; }
  html body #view-admin #admin-detail-content .header-pills-row > .pill,
  html body #view-admin #admin-detail-content .header-pills-row > :is(button, input[type="color"], .office-color-tip) { flex-shrink: 0 !important; }
  html body #view-admin #admin-detail-content .header-pills-row > #office-id-pill,
  html body #view-admin #admin-detail-content .admin-user-detail .header-pills-row > .pill:nth-child(2) { flex: 0 1 auto !important; min-width: 0 !important; white-space: normal !important; overflow-wrap: anywhere; }
  html body #view-admin .detail-header-top .header-pills-row .pill.pill[style] {
    background: var(--pill-state-active-bg) !important;
    color: var(--pill-state-active-text) !important;
    border-color: color-mix(in srgb, var(--accent-primary) 14%, transparent) !important;
    opacity: 1 !important;
  }
}
/* Kontorets räknare (#office-ticket-counter-cell, inline-spans utan klass i admin-office-detail-view.js) = agentens räknarpills. */
@media (min-width: 769px) {
  html body #view-admin #office-ticket-counter-cell span[style*="border-radius:24px"] {
    background: var(--pill-state-active-bg) !important;
    color: var(--pill-state-active-text) !important;
    border-color: color-mix(in srgb, var(--accent-primary) 14%, transparent) !important;
    border-radius: 999px !important;
    box-shadow: none !important;
  }
}
/* Kontorets och agentens detaljpaneler: temats mörka panelkant (nordic-dawn.css:3300 m.fl.) ⇒ mjuk kant. */
@media (min-width: 769px) {
  html body #view-admin #admin-detail-content .detail-body .glass-panel.glass-panel {
    border-color: color-mix(in srgb, var(--border-color) 45%, transparent) !important;
  }
}

@media (min-width: 769px) {
  /* Detaljhuvudet (personal + enhet, Patrik 10-15): räknarna uppe till höger på namnradens nivå, inte egen rad. */
  html body #view-admin #admin-detail-content .detail-header-top:has(> .agent-desktop-counter-wrap),
  html body #view-admin #admin-detail-content .detail-header-top:has(> #office-ticket-counter-cell) {
    flex-wrap: nowrap !important; align-items: flex-start !important; gap: 16px !important;
  }
  html body #view-admin #admin-detail-content .detail-header-top > :first-child { flex: 1 1 auto !important; min-width: 0 !important; }
  html body #view-admin #admin-detail-content .detail-header-top > .agent-desktop-counter-wrap.agent-desktop-counter-wrap,
  html body #view-admin #admin-detail-content .detail-header-top > #office-ticket-counter-cell {
    flex: 0 0 auto !important; width: auto !important; align-self: flex-start !important; align-items: flex-end !important;
    margin: 4px 0 0 auto !important; justify-content: flex-end !important;
  }
  html body #view-admin .agent-desktop-counter-wrap .agent-counter-pills.agent-counter-pills { justify-content: flex-end !important; flex-wrap: nowrap !important; }
}
@media (min-width: 769px) {
  /* Subtil fade i agentens/enhetens färg över huvudet (Patrik 10-15); ligger under innehållet. */
  html body #view-admin #admin-detail-content .admin-user-detail > .detail-header-top,
  html body #view-admin #admin-detail-content .admin-office-detail > .detail-header-top { position: relative !important; isolation: isolate; }
  html body #view-admin #admin-detail-content .admin-user-detail > .detail-header-top::before,
  html body #view-admin #admin-detail-content .admin-office-detail > .detail-header-top::before {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
    background: linear-gradient(105deg,
      color-mix(in srgb, var(--unit-color, var(--agent-color, var(--accent-primary))) 16%, transparent) 0%,
      color-mix(in srgb, var(--unit-color, var(--agent-color, var(--accent-primary))) 7%, transparent) 45%,
      transparent 90%);
  }
}
/* AT-224 (Patrik 11-08, zoom 110–150 %): huvudet följer DETALJPANELENS bredd (containerfråga), inte fönstrets — zoom, smalt
   fönster och surfplatta smalnar av panelen. Smal panel: Arkiverade/Aktiva på egen rad under namnet, namnraden och märkesraden
   radbryts som grupper, namnet trycks aldrig bort. (container-type inline-size: position:fixed-menyer påverkas inte, mätt.) */
@media (min-width: 769px) {
  html body #view-admin #admin-detail-content :is(.admin-office-detail, .admin-user-detail) { container: atlas-admin-detail / inline-size; }
}
@container atlas-admin-detail (max-width: 720px) {
  html body #view-admin #admin-detail-content .detail-header-top:has(> .agent-desktop-counter-wrap),
  html body #view-admin #admin-detail-content .detail-header-top:has(> #office-ticket-counter-cell) { flex-wrap: wrap !important; row-gap: 10px !important; }
  html body #view-admin #admin-detail-content .detail-header-top > :first-child { flex: 1 1 100% !important; }
  html body #view-admin #admin-detail-content .detail-header-top > :first-child > :last-child { flex: 1 1 auto; min-width: 0; }
  html body #view-admin #admin-detail-content .detail-header-top > :first-child > :last-child > :first-child { flex-wrap: wrap; row-gap: 4px; }
  html body #view-admin #admin-detail-content .detail-header-top .detail-subject { min-width: 0; overflow-wrap: anywhere; }
  html body #view-admin #admin-detail-content .detail-header-top > .agent-desktop-counter-wrap.agent-desktop-counter-wrap,
  html body #view-admin #admin-detail-content .detail-header-top > #office-ticket-counter-cell {
    flex: 1 1 100% !important; margin: 0 !important; justify-content: flex-start !important; align-items: flex-start !important;
  }
  html body #view-admin .agent-desktop-counter-wrap .agent-counter-pills.agent-counter-pills { justify-content: flex-start !important; }
}
@container atlas-admin-detail (max-width: 480px) {
  /* Mycket smal panel (t.ex. 1366 px vid 150 %): avataren över namnet så att märken och ikoner får hela bredden och håller ihop. */
  html body #view-admin #admin-detail-content .detail-header-top > :first-child { flex-wrap: wrap !important; row-gap: 10px; }
  html body #view-admin #admin-detail-content .detail-header-top > :first-child > :last-child { flex: 1 1 100%; }
}
/* AT-229 (1366×768 i 150 %, mätt: rutnätet 651 px, listan 300 px + avstånd, detaljen tvingad till min-width 400 px ⇒ 73 px utanför
   fönstret; rutnätet har overflow:hidden, så den avsedda horisontella scrollen i reply-editor-actions.css blev en klippning).
   Rutnätets EGEN bredd styr: räcker den inte till lista + 400 px släpps detaljens minbredd och detaljen tar resten. */
@media (min-width: 769px) {
  html body #view-admin .admin-grid-container { container: atlas-admin-grid / inline-size; }
}
@container atlas-admin-grid (max-width: 760px) {
  html body #view-admin .admin-grid-container .template-editor-container { min-width: 0 !important; }
}
/* AT-229 (mätt 125 % och 150 %): kontorsdetaljens rutnät (.admin-office-detail-grid, en kolumn `1fr` på desktop) kan inte bli
   smalare än sitt innehåll — Identitet m.fl. blev 498 px i en 264 px bred kolumn och klipptes vid kortets kant. Samma regel som
   mobilen redan har (mobile-soft-office-detail.css:8-9): kolumnen och rutorna får krympa. */
@media (min-width: 769px) {
  html body #view-admin #admin-detail-content .admin-office-detail-grid { grid-template-columns: minmax(0, 1fr) !important; }
  html body #view-admin #admin-detail-content .admin-office-detail-grid > * { min-width: 0 !important; max-width: 100%; }
  /* Öppettiderna (456 px rader vid 150 %): samma som mobile-soft-admin-detail.css:932-935. */
  html body #view-admin #admin-detail-content #opening-hours-grid { grid-template-columns: minmax(0, 1fr) !important; }
  html body #view-admin #admin-detail-content .hours-row { max-width: 100%; box-sizing: border-box; }
  html body #view-admin #admin-detail-content .hours-row > input { min-width: 0 !important; }
  html body #view-admin #admin-detail-content #box-contact > div:not(.admin-config-section-heading) { grid-template-columns: minmax(0, 1fr); min-width: 0; }
  html body #view-admin #admin-detail-content .office-contact-row { max-width: 100%; box-sizing: border-box; }
  html body #view-admin #admin-detail-content .office-contact-row > input { min-width: 0 !important; }
}
