/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * Copyright © 2026 Marcel Rymenhout and IniqDash contributors */
/* IniqHA binding wrapper: the widget fills it exactly as it fills a grid cell. */
.iqha { position: relative; display: flex; flex: 1 1 auto; min-width: 0; min-height: 0; width: 100%; height: 100%; }
.iqha > :first-child { flex: 1 1 auto; min-width: 0; min-height: 0; }
.iqha__badge {
  position: absolute; z-index: 3; left: 50%; bottom: 10px; transform: translateX(-50%);
  max-width: calc(100% - 20px); padding: 4px 10px; border-radius: 999px;
  font: 600 11px/1.3 var(--font, system-ui); color: #ffd0d0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(20, 21, 26, .92); box-shadow: 0 0 0 1px rgba(255, 100, 100, .35);
  pointer-events: none;
}
.iqha__badge[hidden] { display: none; }
/* no live data / entity unavailable: the widget is dimmed and does not take input (it would only fail) */
.iqha[data-ha="lost"] > :first-child, .iqha[data-ha="unavailable"] > :first-child, .iqha[data-ha="missing"] > :first-child { filter: saturate(.35) brightness(.7); pointer-events: none; }
.iqha[data-ha="unavailable"] .iqha__badge { color: var(--text-secondary, #b7bbc5); box-shadow: 0 0 0 1px rgba(255, 255, 255, .12); }
/* waiting for Home Assistant's first answer for a linked entity: a neutral card (its configured name only) — never demo values */
.iqha__wait { display: flex; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-device, 22px); background: var(--surface-primary, #1c1d22); box-shadow: 0 0 0 1px var(--border-primary, rgba(255, 255, 255, .08)) inset; }
.iqha__wait-n { font: 600 13px/1.3 var(--font, system-ui); color: var(--text-secondary, #b7bbc5); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iqha[data-ha="loading"] .iqha__badge { color: var(--text-secondary, #b7bbc5); box-shadow: 0 0 0 1px rgba(255, 255, 255, .12); }
/* an unlinked widget on the live server: its demo values carry a small, quiet "Demo" tag */
.iqdemo { position: relative; display: flex; flex: 1 1 auto; min-width: 0; min-height: 0; width: 100%; height: 100%; }
.iqdemo > :first-child { flex: 1 1 auto; min-width: 0; min-height: 0; }
.iqdemo__tag {
  /* top CENTRE: titles sit on the left and controls (power, mode pills) on the right of most cards — the centre is free */
  position: absolute; z-index: 3; top: 4px; left: 50%; transform: translateX(-50%); padding: 0 6px; border-radius: 999px; pointer-events: none; opacity: .85;
  font: 600 8.5px/1.6 var(--font, system-ui); letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted, #8b8f99); background: rgba(20, 21, 26, .72); box-shadow: 0 0 0 1px var(--border-primary, rgba(255, 255, 255, .1)) inset;
}
/* an action Home Assistant refused: a short red edge */
.iqha[data-error] { border-radius: var(--radius-device, 22px); box-shadow: 0 0 0 2px var(--danger, #ff6464); }

/* ---- entity picker (schema form field type 'entity') ---- */
.iqp { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.iqp__row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.iqp__cur { flex: 1 1 180px; min-width: 0; }
.iqp__sel { display: flex; flex-direction: column; min-width: 0; }
.iqp__sel b { font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iqp__sel small, .iqp__none { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the chosen entity: its HA name, then its entity id (monospace) — never mistaken for an area of the same name */
.iqp__sel > small:first-of-type { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.iqp__btn { height: 34px; padding: 0 14px; border: 0; border-radius: 999px; cursor: pointer; font: 600 12.5px var(--font); color: var(--text-primary); background: var(--surface-tertiary); }
.iqp__btn--quiet { color: var(--text-secondary); background: transparent; box-shadow: 0 0 0 1px var(--border-primary) inset; }
.iqp__btn[hidden] { display: none; }
.iqp__btn:focus-visible, .iqp__item:focus-visible, .iqp__chip:focus-visible, .iqp__search:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.iqp__panel { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; background: var(--surface-secondary); box-shadow: 0 0 0 1px var(--border-primary) inset; }
.iqp__panel[hidden] { display: none; }
.iqp__search { height: 38px; padding: 0 12px; border: 0; border-radius: 10px; font: 500 14px var(--font); color: var(--text-primary); background: var(--page-bg); box-shadow: 0 0 0 1px var(--border-primary) inset; }
.iqp__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.iqp__chips:empty { display: none; }
.iqp__chips[hidden] { display: none; }
/* the area context (where the list is looking) and the secondary type filter */
.iqp__tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.iqp__tools:not(:has(> :not([hidden]))) { display: none; }
.iqp__scope { display: flex; align-items: center; gap: 8px; min-width: 0; margin-right: auto; }
.iqp__scope[hidden] { display: none; }
.iqp__scope-t { font-size: 12px; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.iqp__link { border: 0; padding: 4px 2px; background: none; cursor: pointer; font: 600 12px var(--font); color: var(--ed-primary, var(--accent)); }
.iqp__link[hidden] { display: none; }
.iqp__link:focus-visible { outline: var(--focus-ring); outline-offset: 2px; border-radius: 6px; }
.iqp__chip { height: 28px; padding: 0 11px; border: 0; border-radius: 999px; cursor: pointer; font: 600 12px var(--font); color: var(--text-secondary); background: var(--surface-tertiary); }
.iqp__chip[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent-line) inset; }
.iqp__info { margin: 0; font-size: 12px; color: var(--text-muted); }
.iqp__list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.iqp__item { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 7px 10px; border: 0; border-radius: 10px; cursor: pointer; text-align: left; font: 500 13px var(--font); color: var(--text-primary); background: transparent; }
.iqp__item:hover { background: var(--surface-tertiary); }
[aria-selected="true"] > .iqp__item { background: var(--accent-soft); }
.iqp__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iqp__state { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.iqp__meta { grid-column: 1 / -1; font: 500 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iqp__does { color: var(--accent) !important; font-weight: 600; }
.iqp__group { padding: 8px 10px 3px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.iqp__note { grid-column: 1 / -1; font-size: 11.5px; font-weight: 600; color: var(--warning, #f0b45a) !important; }

/* ---- code keypad (lock / alarm): one code for one action, never stored ---- */
.iqcode { padding: 0; border: 0; border-radius: 22px; color: var(--text-primary); background: var(--surface-primary); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .8), 0 0 0 1px var(--border-primary); font-family: var(--font); }
.iqcode::backdrop { background: rgba(5, 6, 8, .6); }
.iqcode__f { display: flex; flex-direction: column; gap: 12px; padding: 20px; width: min(86vw, 300px); }
.iqcode__t { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.iqcode__in { height: 46px; padding: 0 14px; border: 0; border-radius: 14px; font: 600 20px var(--font); letter-spacing: .3em; text-align: center; color: var(--text-primary); background: var(--surface-secondary); box-shadow: 0 0 0 1px var(--border-primary) inset; }
.iqcode__pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.iqcode__k, .iqcode__b { height: 48px; border: 0; border-radius: 14px; cursor: pointer; font: 600 17px var(--font); color: var(--text-primary); background: var(--control-raised); box-shadow: 0 2px 5px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .07); }
.iqcode__row { display: flex; gap: 8px; }
.iqcode__b { flex: 1; font-size: 14px; }
.iqcode__b--ok { color: #2a1a03; background: var(--accent); }
.iqcode__k:focus-visible, .iqcode__b:focus-visible, .iqcode__in:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

/* ---- Entity Details (components/ha/details.js) — system surface inside the shared popup host */
.mpop[data-popup="iq-details"] .mpop__body { padding: 4px 18px 20px; overflow-x: hidden; }
.iqd { display: flex; flex-direction: column; gap: 16px; min-width: 0; font-family: var(--font, system-ui); color: var(--text-primary); }
.iqd__banner { margin: 0; padding: 8px 12px; border-radius: 12px; font-size: 12.5px; color: #ffd0d0; background: rgba(255, 100, 100, .1); box-shadow: inset 0 0 0 1px rgba(255, 100, 100, .3); }
.iqd__banner[hidden], .iqd__sec[hidden], .iqd__media[hidden] { display: none; }
.iqd__head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.iqd__pic { flex: none; width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--surface-tertiary); }
.iqd__who { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.iqd__value { font-size: clamp(22px, 5vw, 30px); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.iqd__when { margin: 0; font-size: 13px; color: var(--text-secondary); }
.iqd__when:empty { display: none; }
.iqd__id { margin: 0; font: 500 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-muted); overflow-wrap: anywhere; }
.iqd__media { border-radius: 16px; overflow: hidden; background: var(--surface-tertiary); }
.iqd__img { display: block; width: 100%; max-height: 320px; object-fit: contain; }
.iqd__sec { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.iqd__h { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.iqd__dl { margin: 0; display: grid; grid-template-columns: minmax(90px, max-content) minmax(0, 1fr); gap: 6px 14px; font-size: 13.5px; }
.iqd__dl dt { color: var(--text-secondary); overflow-wrap: anywhere; }
.iqd__dl dd { margin: 0; min-width: 0; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; font-weight: 600; }
.iqd__dl dd[data-state="unavailable"], .iqd__dl dd[data-state="missing"], .iqd__dl dd[data-state="absent"] { color: var(--text-muted); font-weight: 500; }
.iqd__swatch { flex: none; width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.iqd__derived { font-weight: 400; color: var(--text-muted); }
.iqd__hrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.iqd__ranges { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.iqd__range { height: 28px; padding: 0 10px; border: 0; border-radius: 999px; cursor: pointer; font: 600 12px var(--font); color: var(--text-secondary); background: var(--surface-tertiary); }
.iqd__range[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft, rgba(240, 166, 75, .15)); box-shadow: inset 0 0 0 1px var(--accent-line, rgba(240, 166, 75, .4)); }
.iqd__range:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.iqd__graph { position: relative; height: 150px; border-radius: 12px; overflow: hidden; background: var(--surface-secondary); box-shadow: inset 0 0 0 1px var(--border-primary); }
.iqd__graph--states { height: 30px; }
.iqd__graph .iq-hist__line { opacity: .95; stroke-width: 2; }
.iqd__graph .iq-hist__area { opacity: .22; }
.iqd__graph .iq-hist__seg { opacity: .85; }
.iqd__graph .iq-hist__seg--off { opacity: .3; }
.iqd__sum { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--text-secondary); }
.iqd__key { display: inline-flex; align-items: center; gap: 5px; }
.iqd__dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: currentColor; color: var(--accent); }
.iqd__dot.iq-hist__seg--off { background: var(--text-muted); opacity: .6; }
.iqd__dot.iq-hist__seg--warning { background: var(--danger, #ff6464); }
.iqd__dot.iq-hist__seg--state { background: var(--text-secondary); }
.iqd__dot.iq-hist__seg--alt1 { background: var(--info); }
.iqd__dot.iq-hist__seg--alt2 { background: #5fd3a5; }
.iqd__dot.iq-hist__seg--alt3 { background: #c690ff; }
.iqd__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.iqd__list:empty { display: none; }
.iqd__entry { display: grid; grid-template-columns: minmax(64px, max-content) minmax(0, 1fr); gap: 0 12px; padding: 6px 0; border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, .06)); font-size: 13.5px; }
.iqd__t { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.iqd__what { font-weight: 600; overflow-wrap: anywhere; }
.iqd__cause { grid-column: 2; font-size: 12px; color: var(--text-secondary); overflow-wrap: anywhere; }
.iqd__quiet { margin: 0; font-size: 13px; color: var(--text-muted); }
.iqd__quiet[hidden] { display: none; }
/* Entity Details: calendar agenda (day headings) and weather forecast rows — the activity list's look */
.iqd__day { padding: 10px 0 2px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.iqd__day:first-child { padding-top: 0; }
