/* Shared building blocks of the console: page header, section card, stat, status "since", empty, error and quiet
   states, the message icon and the side drawer. Each block is built by the script of the same name in this folder, which documents
   how to use it. Colours, radii and control sizes come from the variables in style.css.
   The public Application Hub does not load this file. */

/* ── Tones shared by every block: warning is amber, clearly apart from the brand orange (hue about 44°, not 25°) ── */
:root { --warn-text: #7A5900; --warn-bg: #FFFBEB; --warn-border: #FDE68A; --warn-icon: #A16207; }

/* ── The design scale: every size in the console comes from these ──
   Spacing   4 8 12 16 24 32 (48 for page level breathing room)
   Type      12/16 13/20 14/20 16/24 18/26 20/28 24/32, 40/48 for the one figure on Costs; weights 400 500 600
             Entity names (an environment, a person, an application) are 14/600; pills 12/16/500; section labels
             13/600 in sentence case. Monospace values 13/20.
   Radii     4 small marks, 8 controls, 12 cards, lists and menus, 999 pills
   Controls  44px, or 36px compact
   Current   where you are (top bar, environment tabs, Troubleshoot list, page views): deeper orange text at 600 and
             a 2px indicator attached to the item; a vertical list adds the pale fill.
   Selected  what you picked (environment list, choice cards, filter chips, the hub's chooser): pale orange fill and a
             1px deeper orange border, nothing else. */
:root {
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px;
  --text-xs: 12px; --text-sm: 13px; --text-base: 14px; --text-md: 16px; --text-lg: 18px; --text-xl: 20px; --text-2xl: 24px; --text-display: 40px;
  --lh-xs: 16px; --lh-sm: 20px; --lh-base: 20px; --lh-md: 24px; --lh-lg: 26px; --lh-xl: 28px; --lh-2xl: 32px; --lh-display: 48px;
  --radius-mark: 4px; --radius-pill: 999px;
  --current-text: #B4500A; --current-bar: #B4500A; --current-bg: #FFF8F2;
  --selected-bg: #FFF8F2; --selected-border: #B4500A;
}

/* ── Strip above the page header: same width and right edge as the page that follows ── */
.workspace-strip { max-width: 1600px; margin: 8px auto 0; }

/* ── Page header: icon, title, one line of context, actions on the right ── */
.page-header { display: flex; align-items: flex-start; gap: 16px; min-height: 48px; margin: 8px 0 16px; }
.page-header > .page-icon { margin-top: 8px; }
.page-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid #F5C9A8; background: var(--active); color: var(--action); }
.page-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.page-header-text { flex: 1 1 auto; min-width: 0; }
.page-header h1 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.3px; overflow-wrap: anywhere; }
.page-header-context { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin: 2px 0 0; font-size: 14px; line-height: 20px; color: var(--muted); }
.page-header-context strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.page-header-part:not(:last-child)::after { content: "·" / ""; margin-left: 8px; color: #A8A29E; }
.page-header-note { display: flex; align-items: flex-start; gap: 8px; width: fit-content; max-width: 640px; margin: 8px 0 0; padding: 8px 12px; border: 1px solid var(--warn-border, #FDE68A); border-radius: 8px; background: var(--warn-bg, #FFFBEB); color: var(--warn-text, #7A5900); font-size: 13px; font-weight: 500; line-height: 20px; }
.page-header-note::before { content: ""; flex: none; width: 16px; height: 16px; margin-top: 1px; background: var(--warn-icon, #A16207); -webkit-mask: var(--info-icon) center / contain no-repeat; mask: var(--info-icon) center / contain no-repeat; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex: none; margin: 4px 0 0 auto; }
.page-header-actions > button { min-height: var(--control-h); height: var(--control-h); padding: 0 24px; font-size: 14px; }
/* Slots in the Environments header: a small meter, the count, and what it counts. */
.slot-context { cursor: help; }
.slot-context .slots-detail { flex: 1 1 0; min-width: 140px; white-space: normal; }
.slot-context .slot-meter { display: inline-flex; flex: none; width: 72px; gap: 2px; margin: 0; }
.slot-context .slot-meter > * { flex: 1 1 0; min-width: 1px; max-width: none; height: 6px; border-radius: 3px; }
.slot-context .slot-meter:has(> :nth-child(9)) { gap: 1px; }
.slot-context .slot-meter:has(> :nth-child(9)) > * { border-radius: 1px; }
.slot-context .slot-meter:has(> :nth-child(25)) { gap: 0; border-radius: 3px; overflow: hidden; }
.slot-context .slot-meter:has(> :nth-child(25)) > * { border-radius: 0; }
.is-loading .slot-context > * { visibility: hidden; }
@media (max-width: 600px) { .slot-context { flex-wrap: wrap; } .slot-context .slots-detail { flex: 0 1 auto; min-width: 0; white-space: nowrap; } }
@media (max-width: 900px) {
  .workspace-strip { margin: 12px 0 0; }
  .page-header { margin: 16px 0 24px; }
}
@media (max-width: 700px) {
  .page-header { flex-wrap: wrap; align-items: flex-start; gap: 12px; }
  .page-header-text { flex: 1 1 0; }
  .page-header > .page-icon { margin-top: 2px; }
  .page-header-actions { flex: 1 1 100%; margin: 0; }
  .page-header-actions > button { flex: 1 1 auto; }
  .page-header-note { width: auto; }
}

/* ── Buttons that lead the eye ──
   .primary (style.css): filled in the deeper orange, white text and icon. The main action of a page or of a row.
   .accent: brand outline. The one main action of a card. Text, icon and border are the deeper orange on the card
   colour (4.96:1); on the pale orange hover and focus fill they go one step darker to keep 4.5:1 (5.64:1). */
.accent { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 24px; border: 1px solid var(--action); background: var(--card); color: var(--action); font-weight: 600; white-space: nowrap; box-shadow: none; }
.accent svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.accent:hover, .accent:focus-visible { border-color: var(--action-hover); background: var(--active); color: var(--action-hover); }
.accent:disabled, .accent:disabled:hover { border-color: var(--border); background: var(--subtle); color: var(--muted); }
.ui-icon-button.accent { padding: 0; }

/* ── Section card: bordered block with a heading row. No drop shadow. ── */
.ui-card { min-width: 0; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--card); box-shadow: none; }
.ui-card-plain { padding: 0; border: 0; border-radius: 0; background: transparent; }
.ui-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; min-height: 32px; margin-bottom: 16px; }
.ui-card-titles { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.ui-card-icon { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--subtle); color: var(--secondary); }
.ui-card-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: 0; color: var(--text); }
.ui-card-hint { font-size: 13px; line-height: 20px; color: var(--muted); }
.ui-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ui-card-actions .text-button { min-height: 32px; padding: 0; }
.ui-card-body { min-width: 0; }
.ui-card-body > p { margin: 0; }
@media (max-width: 600px) { .ui-card { padding: 16px; } .ui-card.ui-card-plain { padding: 0; } }

/* ── Stat: a label over one figure ── */
.ui-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 16px 24px; margin: 0; }
.ui-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ui-stat-label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--muted); }
.ui-stat-label svg { flex: none; }
.ui-stat-value { margin: 0; font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.3px; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ui-stat-note { margin: 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.ui-stat.tone-good .ui-stat-value { color: #166534; }
.ui-stat.tone-warn .ui-stat-value { color: var(--text); }
.ui-stat.tone-bad .ui-stat-value { color: #B91C1C; }

/* ── Status pill "since": the duration follows the state name ── */
.badge-since { font-weight: 500; font-variant-numeric: tabular-nums; }
.badge-since::before { content: "·" / ""; margin-right: 8px; }

/* ── Empty, error and quiet states ── */
.ui-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 24px; border: 1px dashed var(--border-strong); border-radius: var(--radius-card); background: var(--card); text-align: center; }
.ui-state-icon { display: grid; place-items: center; flex: none; width: 56px; height: 56px; margin-bottom: 4px; border: 1px solid #F5C9A8; border-radius: 12px; background: var(--active); color: var(--action); }
.ui-state-title { margin: 0; font-size: 18px; line-height: 26px; font-weight: 600; color: var(--text); }
.ui-state-text { max-width: 520px; margin: 0; font-size: 14px; line-height: 20px; color: var(--muted); }
.ui-state > button { margin-top: 8px; }
.ui-state.compact { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-style: solid; border-color: var(--border); border-radius: 8px; background: var(--page); text-align: left; }
.ui-state.compact .ui-state-icon { width: 32px; height: 32px; margin: 0; border-radius: 8px; }
.ui-state.compact .ui-state-title { font-size: 14px; }
.ui-state.compact .ui-state-text { flex: 1 1 220px; max-width: none; font-size: 13px; }
.ui-state.compact > button { min-height: var(--control-h-compact); height: var(--control-h-compact); margin: 0 0 0 auto; padding: 0 12px; font-size: 13px; }
.ui-error, .ui-state.compact.ui-error { border-color: #FECACA; background: #FEF2F2; }
.ui-error .ui-state-icon { border-color: #FECACA; background: #fff; color: #B91C1C; }
.ui-error .ui-state-title { color: #991B1B; }
.ui-error .ui-state-text { color: #7F1D1D; }
.ui-quiet { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; line-height: 20px; color: var(--secondary); }
.ui-quiet svg { flex: none; color: #15803D; }

/* ── Message strip: state icon before the text ── */
.notice-icon { display: inline-grid; flex: none; }
.notice-icon:empty { display: none; }

/* ── Skeleton shapes for the blocks above ── */
.skeleton-card { display: flex; flex-direction: column; gap: 16px; }
.skeleton-stats .ui-stat { gap: 8px; }

/* ── Drawer: a side panel for create and edit flows (drawer.js) ──
   Slides in from the right, full height. The title stays at the top, the body scrolls, the actions stay at the
   bottom. It is an overlay, so it has a border and a dimmed page behind it, not a drop shadow. */
dialog.ui-drawer { position: fixed; inset: 0 0 0 auto; display: none; flex-direction: column; width: min(720px, 100vw); max-width: none; height: 100vh; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; border-left: 1px solid var(--border); border-radius: 0; background: var(--card); color: var(--text); box-shadow: none; overflow: hidden; }
dialog.ui-drawer.wide { width: min(920px, 100vw); }
dialog.ui-drawer[open] { display: flex; animation: ui-drawer-in 240ms cubic-bezier(.2, .8, .2, 1); }
dialog.ui-drawer::backdrop { background: rgb(17 24 39 / 45%); animation: ui-drawer-dim 240ms ease-out; }
@keyframes ui-drawer-in { from { transform: translateX(100%); } }
@keyframes ui-drawer-dim { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.ui-drawer[open], dialog.ui-drawer::backdrop { animation: none; } }
.ui-drawer-head { display: flex; align-items: flex-start; gap: 16px; flex: none; padding: 24px 24px; border-bottom: 1px solid var(--border); }
.ui-drawer-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border: 1px solid #F5C9A8; border-radius: 12px; background: var(--active); color: var(--action); }
.ui-drawer-titles { flex: 1 1 auto; min-width: 0; }
dialog.ui-drawer .ui-drawer-title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -.2px; overflow-wrap: anywhere; }
dialog.ui-drawer .ui-drawer-subtitle { margin: 2px 0 0; font-size: 14px; line-height: 20px; color: var(--muted); overflow-wrap: anywhere; }
.ui-drawer-close { flex: none; width: var(--control-h-compact); height: var(--control-h-compact); margin: 2px -8px 0 0; color: var(--secondary); }
.ui-drawer-banner { flex: none; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--page); }
.ui-drawer-banner:empty { display: none; }
.ui-drawer-body { flex: 1 1 auto; min-height: 0; padding: 24px; overflow-y: auto; overscroll-behavior: contain; outline: none; }
.ui-drawer-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; flex: none; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--card); }
.ui-drawer-foot:empty { display: none; }
.ui-drawer-foot .ui-drawer-foot-start { margin-right: auto; }
.ui-drawer-foot > .error { flex: 1 1 100%; margin: 0; }
.ui-drawer-foot > .error:empty { display: none; }
/* Short or zoomed screens: the whole drawer scrolls, so the body never shrinks to a sliver and the actions stay
   reachable at the end. */
@media (max-height: 560px) {
  dialog.ui-drawer[open] { overflow-y: auto; }
  dialog.ui-drawer .ui-drawer-body { flex: none; overflow: visible; }
  dialog.ui-drawer .ui-drawer-head, dialog.ui-drawer .ui-drawer-banner, dialog.ui-drawer .ui-drawer-foot { flex: none; }
}
@media (max-width: 400px) {
  .ui-drawer-foot { gap: 8px; }
  .ui-drawer-foot > button, .ui-drawer-foot .ui-drawer-foot-start { flex: 1 1 0; min-width: 0; padding: 0 8px; }
}
@media (max-width: 600px) {
  dialog.ui-drawer, dialog.ui-drawer.wide { width: 100vw; border-left: 0; }
  .ui-drawer-head { padding: 16px; }
  .ui-drawer-banner { padding: 12px 16px; }
  .ui-drawer-body { padding: 16px; }
  .ui-drawer-foot { padding: 12px 16px; }
  .ui-drawer-foot > button { flex: 1 1 auto; }
  .ui-drawer-foot .ui-drawer-foot-start { flex: 0 0 auto; margin-right: 0; }
}

/* ── Actions menu: a button that opens a short list (menu.js) ── */
.ui-menu-wrap { position: relative; display: inline-flex; flex: none; }
.ui-menu-button { width: var(--control-h); height: var(--control-h); min-height: var(--control-h); border: 1px solid var(--field-border); background: var(--card); color: var(--secondary); }
.ui-menu-button:hover, .ui-menu-button[aria-expanded="true"] { background: var(--subtle); color: var(--text); }
.ui-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: flex; flex-direction: column; min-width: 232px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); box-shadow: 0 8px 20px rgb(0 0 0 / 15%); }
.ui-menu-item { display: flex; align-items: center; gap: 12px; min-height: 40px; height: 40px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 14px; font-weight: 400; text-align: left; white-space: nowrap; }
.ui-menu-item svg { flex: none; color: var(--secondary); }
.ui-menu-item:hover, .ui-menu-item:focus-visible { background: var(--subtle); }
.ui-menu-item:focus-visible { outline-offset: -2px; }
.ui-menu-item.danger, .ui-menu-item.danger svg { color: var(--danger-hover); }
.ui-menu-item.danger:hover, .ui-menu-item.danger:focus-visible { background: #FEF2F2; }
.ui-menu-item:disabled, .ui-menu-item:disabled svg { color: var(--muted); background: transparent; }
.ui-menu-separator { height: 1px; margin: 8px 0; background: var(--border); }

/* ── Choice cards (choice.js): compact lays them out two by two on a wide screen ── */
.env-choice-list.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 600px) { .env-choice-list.compact { grid-template-columns: minmax(0, 1fr); } }
.env-choice-list.compact .env-choice { gap: 12px; padding: 12px 16px; }
.env-choice-list.compact .env-choice-icon { width: 36px; height: 36px; border-radius: 12px; }
.env-choice-list.compact .env-choice-title { font-size: 14px; }
.env-choice-list.compact .env-choice-desc { font-size: 13px; }
.env-choice.disabled { cursor: default; }
.env-choice.disabled:hover { border-color: var(--field-border); background: var(--card); }
/* Segmented control (segmented.js): views of one page under its header */
.ui-segmented { display: flex; flex-wrap: wrap; gap: 24px; max-width: 100%; border-bottom: 1px solid var(--border); }
.ui-segment { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0; border: 0; border-radius: 0; color: var(--secondary); font-size: 14px; font-weight: 500; text-decoration: none; }
.ui-segment::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: transparent; }
.ui-segment svg { flex: none; }
.ui-segment:hover { color: var(--text); text-decoration: none; }
.ui-segment.selected { color: var(--current-text); font-weight: 600; }
.ui-segment.selected::after { background: var(--current-bar); }
.ui-segment.selected svg { color: var(--current-text); }
.ui-segment:focus-visible { outline: 2px solid #B4500A; outline-offset: 1px; }
@media (max-width: 600px) { .ui-segmented { display: flex; } .ui-segment { flex: 1 1 0; justify-content: center; padding: 0 8px; } }
/* Disclosures ("More", "How these figures are worked out", "How to call it"): one look everywhere, a chevron that
   turns when open, then the words in the link colour. */
:root { --chevron-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E"); }
.env-more > summary, .costs-more > summary { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; list-style: none; border-radius: 4px; color: var(--active-text); font-size: 13px; font-weight: 500; cursor: pointer; }
.env-more > summary::-webkit-details-marker, .costs-more > summary::-webkit-details-marker { display: none; }
.env-create-advanced > summary::before, .env-create-access > summary::before, .provisioning-access details > summary::before, .ui-drawer details:not(.env-more):not(.costs-more) > summary::before,
.env-more > summary::before, .costs-more > summary::before { content: ""; flex: none; width: 14px; height: 14px; background: currentColor; transition: transform 150ms; -webkit-mask: var(--chevron-icon) center / contain no-repeat; mask: var(--chevron-icon) center / contain no-repeat; }
.env-create-advanced[open] > summary::before, .env-create-access[open] > summary::before, .provisioning-access details[open] > summary::before, .ui-drawer details:not(.env-more):not(.costs-more)[open] > summary::before,
.env-more[open] > summary::before, .costs-more[open] > summary::before { transform: rotate(90deg); }
.env-more > summary:focus-visible, .costs-more > summary:focus-visible { outline: 2px solid var(--focus, var(--action)); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .env-create-advanced > summary::before, .env-create-access > summary::before, .provisioning-access details > summary::before, .ui-drawer details:not(.env-more):not(.costs-more) > summary::before,
.env-more > summary::before, .costs-more > summary::before { transition: none; } }
/* Actions under the words of a state, in a row of their own. */
.ui-state-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 100%; }
.ui-state-actions > button { min-height: var(--control-h-compact); height: var(--control-h-compact); padding: 0 12px; font-size: 13px; }

/* Every other disclosure in a drawer uses the same chevron in place of the browser's triangle. */
.ui-drawer details > summary, .provisioning-access details > summary { list-style: none; cursor: pointer; }
.ui-drawer details > summary::-webkit-details-marker, .provisioning-access details > summary::-webkit-details-marker { display: none; }
.provisioning-access details > summary, .ui-drawer details:not(.env-more):not(.costs-more) > summary { display: flex; align-items: center; gap: 8px; }

/* Breathing room between the refresh strip and the page header with its main action */
.workspace-strip { margin-top: 12px; }
.workspace-strip + * .page-header, .workspace-strip ~ .page-header, .page-header { margin-top: 20px; }

/* Button sizes: the page header's actions are full size (44px, 14px); every action inside a card is compact
   (36px, 13px), on the Dashboard and in an environment alike. */
.env-state-actions > button, .env-glance-row > button.secondary, .env-progress-detail > button { min-height: var(--control-h-compact); height: var(--control-h-compact); padding: 0 12px; font-size: 13px; }
.env-head-actions > button { padding: 0 16px; }
