/* ── Icon Box (sensor icons — no MudBlazor equivalent for rounded-square icon containers) ── */
.icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    width: 30px;
    height: 30px;
    min-width: 30px;
    flex-shrink: 0;
}
.icon-box--lg {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 12px;
}
.icon-box--accent { background: var(--accent-bg); color: var(--primary); }
.icon-box--dry { background: var(--warning-bg); color: var(--warning); }
.icon-box--water { background: var(--info-bg); color: var(--info); }
.icon-box--gray { background: var(--background); color: var(--text-muted); }

/* Sensor variants share the same color as the matching chart line via --chart-*. */
.icon-box--temperature   { background: color-mix(in srgb, var(--chart-temperature) 14%, transparent); color: var(--chart-temperature); }
.icon-box--humidity      { background: color-mix(in srgb, var(--chart-humidity) 14%, transparent); color: var(--chart-humidity); }
.icon-box--pressure      { background: color-mix(in srgb, var(--chart-pressure) 18%, transparent); color: var(--chart-pressure); }
.icon-box--water-level   { background: color-mix(in srgb, var(--chart-water-level) 14%, transparent); color: var(--chart-water-level); }

/* With valve monitoring on, the pressure tile reports the monitoring's verdict rather than the
   kind of sensor: grey while the circuit rests, green while it waters and the pressure agrees,
   red when the two disagree. Without monitoring it keeps .icon-box--pressure — a reading nobody
   cross-checks must not look like a passed check. */
.icon-box--pressure-idle  { background: var(--background); color: var(--text-muted); }
.icon-box--pressure-ok    { background: var(--accent-bg); color: var(--primary); }
.icon-box--pressure-fault { background: var(--error-bg); color: var(--error); }
.icon-box--water-flow    { background: color-mix(in srgb, var(--chart-water-flow) 14%, transparent); color: var(--chart-water-flow); }
.icon-box .mud-icon-root { font-size: 18px; }
.icon-box--lg .mud-icon-root { font-size: 22px; }

/* ── Status pills ── */
.status-pill           { font-weight: 600; }
/* Chain `.mud-chip` so the fill out-specifies MudBlazor's default
   `.mud-chip-filled` gray (same single-class specificity, but MudBlazor.min.css
   is loaded after this file, so a bare `.status-pill--x` would lose the tie). */
.mud-chip.status-pill--ok       { background-color: var(--accent-bg); color: var(--primary); }
.mud-chip.status-pill--warning  { background-color: var(--warning-bg); color: var(--warning); }
/* Solid red fill + white text so a fault is unmistakable at a glance. */
.mud-chip.status-pill--error    { background-color: var(--error); color: var(--surface); }
.mud-chip.status-pill--info     { background-color: var(--info-bg); color: var(--info); }
.mud-chip.status-pill--neutral  { background-color: var(--neutral-bg); color: var(--neutral-text); }
/* outline (not box-shadow) so the selection ring composes with the fault pulse. */
.status-pill--selected { outline: 1.5px solid currentColor; outline-offset: -1.5px; }
.filter-pill           { cursor: pointer; }

/* Fault pills (card + filter) pulse a red "ping" so a circuit in fault state
   can't be overlooked. */
.status-pill--error {
    animation: status-pill-fault 1.6s ease-in-out infinite;
}
@keyframes status-pill-fault {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--error) 55%, transparent); }
    100% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--error) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
    .status-pill--error { animation: none; }
}

/* ── Sensor metric ── */
.sensor-value          { font-size: calc(15px * var(--font-scale)); font-weight: 700; font-variant-numeric: tabular-nums; }
.sensor-value--lg      { font-size: calc(18px * var(--font-scale)); }
.sensor-value--detail  { font-size: calc(17px * var(--font-scale)); }
.sensor-unit           { font-size: calc(11px * var(--font-scale)); font-weight: 500; color: var(--text-muted); }
.sensor-metrics-row > * { flex: 1 1 0; min-width: 0; }

/* ── Live Values (sensor readings at top of area detail) ── */
.live-values {
    display: grid;
    grid-template-columns: auto auto;
    row-gap: 12px;
    column-gap: 32px;
    justify-content: center;
    padding: 4px 0 12px;
}
.live-values > * {
    justify-content: flex-start;
}

/* ── Watering tile ── */
.watering-tile         { flex: 1; background: var(--background); border-radius: 14px; padding: 10px 12px; }
.watering-tile__label  { text-transform: uppercase; letter-spacing: 0.5px; }
.watering-active       { background: var(--info-bg); border-radius: 14px; padding: 12px 14px; }

/* ── Watering runs (border separator between items) ── */
.watering-runs .watering-run-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
}
.watering-runs > .watering-run-row:first-child { border-top: none; }
.watering-run-row--toggle { cursor: pointer; }
.watering-run-row__badge {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
    background: var(--background);
    border-radius: 8px;
    padding: 1px 7px;
    white-space: nowrap;
}
.watering-run-row__icon--skipped { opacity: 0.45; }

/* ── Weather strip (per area group) ── */
.weather-strip {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.weather-strip__day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    border-radius: 12px;
    background: var(--surface);
    min-width: 52px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.weather-strip__day:active { opacity: 0.7; }
.weather-strip__day--today { background: var(--accent-bg); }
.weather-strip__day .mud-icon-root { font-size: 18px; color: var(--text-secondary); }
.weather-strip__day--today .mud-icon-root { color: var(--primary); }
.weather-strip__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}
.weather-strip__temp { font-size: 12px; font-weight: 600; }
.weather-strip__rain {
    font-size: 10px;
    color: var(--info);
    white-space: nowrap;
}

/* ── Area card (overview) ── */
.content-card,
.area-card             { border-radius: 20px; padding: 18px; box-shadow: 0 1px 0 rgba(15,30,25,0.04), 0 8px 24px -16px rgba(15,30,25,0.08); }
.area-card             { cursor: pointer; }
.area-card__factor {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--background);
    border-radius: 8px;
    padding: 3px 8px;
    white-space: nowrap;
}
.area-card__factor .mud-icon-root { font-size: 14px; }

/* ── Schedule Row (border separator between items) ── */
.schedule-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}
.schedule-row--paused .schedule-info,
.schedule-row--paused .schedule-time { opacity: 0.45; }
.schedule-row + .schedule-row {
    border-top: 1px solid var(--border);
}
.schedule-row .icon-box .mud-icon-root,
.device-row .icon-box .mud-icon-root { font-size: 20px; }
.schedule-info {
    flex: 1;
    min-width: 0;
}
.schedule-time         { font-size: calc(18px * var(--font-scale)); font-weight: 700; font-variant-numeric: tabular-nums; }
.duration-planned      { text-decoration: line-through; }
.duration-adjusted     { color: var(--info); font-weight: 600; margin: 0 4px; }

/* ── Adaptive Factor Explanation ── */
.factor-reason {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Device Row (border separator between items) ── */
.device-row {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    cursor: pointer;
}
.device-row + .device-row {
    border-top: 1px solid var(--border);
}
.device-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.device-stat .mud-icon-root { font-size: 14px; }
.device-stat .mud-typography { color: inherit; font-weight: inherit; }
.device-stat--warning  { color: var(--warning); font-weight: 700; }
.device-stat--muted    { color: var(--text-muted); }
.device-stat--info     { color: var(--info); font-weight: 600; }

/* ── Signal bars ── */
.signal-bars           { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 11px; color: var(--text-muted); }
.signal-bars--warning  { color: var(--warning); }
.signal-bars__bar      { width: 2px; border-radius: 1px; background: currentColor; opacity: 0.25; }
.signal-bars__bar--on  { opacity: 1; }
.signal-bars__bar:nth-child(1) { height: 30%; }
.signal-bars__bar:nth-child(2) { height: 47%; }
.signal-bars__bar:nth-child(3) { height: 64%; }
.signal-bars__bar:nth-child(4) { height: 82%; }
.signal-bars__bar:nth-child(5) { height: 100%; }

/* ── CTA buttons ── */
.btn-cta               { border-radius: 16px !important; padding: 15px !important; font-size: calc(15px * var(--font-scale)); font-weight: 700; text-transform: none !important; }
.btn-cta--primary      { box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 50%, transparent); }
.btn-cta--danger       { background: var(--warning) !important; color: var(--surface) !important; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--warning) 50%, transparent); }
.btn-cta--sm           { border-radius: 14px !important; padding: 13px !important; font-size: calc(13px * var(--font-scale)); }

/* ── Small accent pill button ── */
.btn-pill              { border-radius: 99px !important; text-transform: none !important; font-size: calc(11px * var(--font-scale)); font-weight: 600; }
.btn-accent            { background: var(--accent-bg) !important; color: var(--primary) !important; }

/* ── Header icon buttons ── */
.btn-header-icon       { background: var(--surface) !important; box-shadow: 0 1px 2px rgba(0,0,0,0.04); border-radius: 99px !important; }
.alarms-muted-icon     { color: var(--info); }

/* ── Alert with a trailing action button (paused schedule, muted alarms) ── */
/* MudAlert sizes its message box to the content, so a long text pushes the button out of the
   alert. Let the message fill the row and the text wrap instead. */
.action-alert .mud-alert-position,
.action-alert .mud-alert-message { flex: 1; min-width: 0; }
.action-alert__text            { flex: 1; min-width: 0; }
.action-alert__action          { flex-shrink: 0; white-space: nowrap; }

/* ── Alarm history (area alarms dialog) ── */
.alarm-history__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    border-top: 1px solid var(--border);
}
.alarm-history__row:first-child { border-top: none; }
.alarm-history__icon--error     { color: var(--error); }
.alarm-history__icon--warning   { color: var(--warning); }
.alarm-history__icon--info      { color: var(--info); }
.alarm-history__icon--resolved  { color: var(--primary); }

/* ── Chart ── */
.chart-container       { position: relative; width: 100%; height: clamp(220px, 32vh, 340px); margin-top: 12px; }

/* The chart handles horizontal gestures itself (pan and pinch on the time axis) and leaves the
   vertical ones to the page, so a swipe to scroll never drags the chart with it. */
.chart-container canvas { touch-action: pan-y; }

/* ── Chart readout ── */

.chart-readout {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--neutral-bg);
}

.chart-readout__time {
    font-size: calc(11px * var(--font-scale));
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.chart-readout__values {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

.chart-readout__item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: calc(12px * var(--font-scale));
}

.chart-readout__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
}

.chart-readout__dot--humidity     { background: var(--chart-humidity); }
.chart-readout__dot--temperature  { background: var(--chart-temperature); }
.chart-readout__dot--pressure     { background: var(--chart-pressure); }
.chart-readout__dot--water-level  { background: var(--chart-water-level); }
.chart-readout__dot--water-flow   { background: var(--chart-water-flow); }
.chart-readout__dot--watering     { background: var(--chart-watering); }

.chart-readout__label { color: var(--text-secondary); }

.chart-readout__value { font-weight: 600; }
.toggle-rounded        { border-radius: 12px; }
.hibernation-icon      { margin-bottom: -2px; opacity: 0.5; margin-left: 2px; }

/* ── Settings sections ── */
.settings-section {
    margin: 12px 0 0;
}
.settings-section-title {
    font-size: calc(11px * var(--font-scale));
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 0 16px 8px;
}
.settings-card {
    background: var(--surface);
    border-radius: 20px;
    overflow: hidden;
}
/* Only between cards that actually follow one another, and smaller than the gap between
   sections so a section still reads as one block. */
.settings-card + .settings-card {
    margin-top: 8px;
}
.settings-row {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.settings-row:last-child {
    border-bottom: none;
}
.settings-row-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}
.settings-row-info {
    flex: 1;
    min-width: 0;
}
.settings-row-label {
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
    color: var(--text-primary);
}
.settings-row-sub {
    font-size: calc(11px * var(--font-scale));
    color: var(--text-muted);
    margin-top: 2px;
}
.settings-row-icon .mud-icon-root { font-size: 15px; color: var(--text-secondary); }
.settings-card--clickable { cursor: pointer; }
.settings-row--danger  { justify-content: center; color: var(--warning); }
.settings-row--danger .mud-icon-root { font-size: 18px; margin-right: 8px; }
.settings-row--danger span { font-size: calc(14px * var(--font-scale)); font-weight: 600; }
.settings-row--no-border { border-bottom: none; }
.settings-card-pad     { padding: 0 16px 14px; }
.settings-card-fields  { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }

/* Font-size selector: stretch the toggle to fill the card with equal segments. */
.font-size-toggle      { width: 100%; }
.font-size-toggle .mud-toggle-item { flex: 1 1 0; }

/* ── Install prompt ── */
.install-prompt        { position: fixed; bottom: calc(80px + env(safe-area-inset-bottom, 0px) + 16px); left: 16px; right: 16px; z-index: 9999; }
.install-prompt__card  { background: var(--surface); border-radius: 20px; padding: 20px; box-shadow: 0 8px 32px -8px rgba(15,30,25,0.18); border: 1px solid var(--border); }
.install-prompt__step  { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.install-prompt__header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.install-prompt__title  { font-size: calc(14px * var(--font-scale)); font-weight: 700; color: var(--text-primary); }
.install-prompt__desc   { font-size: calc(13px * var(--font-scale)); color: var(--text-secondary); line-height: 1.6; }
.install-prompt__close  { margin: -8px -8px 0 0; }
.install-prompt__step-num { font-size: calc(11px * var(--font-scale)); font-weight: 700; color: var(--primary); }
.share-icon             { vertical-align: middle; color: var(--info); }

/* ── App logo ── */
.app-logo              { display: flex; align-items: center; gap: 10px; }
.app-logo__icon        { border-radius: 12px; background: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.app-logo__icon--sm    { width: 32px; height: 32px; border-radius: 9px; }
.app-logo__icon--md    { width: 36px; height: 36px; }
.app-logo__icon--lg    { width: 44px; height: 44px; }
.app-logo__name        { font-size: calc(18px * var(--font-scale)); font-weight: 800; letter-spacing: -0.6px; color: var(--text-primary); line-height: 1; }
.app-logo__name--lg    { font-size: calc(22px * var(--font-scale)); }
.app-logo__tld         { font-size: calc(13px * var(--font-scale)); font-weight: 500; letter-spacing: -0.4px; color: var(--primary); line-height: 1; }
.app-logo__tld--lg     { font-size: calc(15px * var(--font-scale)); }
.app-logo__tagline     { font-size: calc(9px * var(--font-scale)); font-weight: 500; letter-spacing: 0.7px; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }

.cmd-btn-icon          { margin-top: -0.15em; }

.plan-table            { font-size: calc(12px * var(--font-scale)); }
.plan-table tbody      { white-space: nowrap; }
.plan-table td.plan-table__grow { width: 100%; }

/* Stands in for a whole group in the grouped overview, so it reads as a way in
   rather than as a reading of its own. */
.group-card {
    cursor: pointer;
}
