/* Airqoon Design System for the admin panel. Tokens mirror lens-ui src/theme/tokens.css;
   MudBlazor's palette (AirqoonTheme.cs) is built from the same numbers. */

@font-face { font-family: "Hurme Geometric Sans"; src: url("fonts/HurmeGeometricSans1-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Hurme Geometric Sans"; src: url("fonts/HurmeGeometricSans1-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Hurme Geometric Sans"; src: url("fonts/HurmeGeometricSans1-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
    --aq-blue-50: #eaf2ff; --aq-blue-100: #d2e4ff; --aq-blue-500: #086eff; --aq-blue-600: #0056d3; --aq-blue-700: #0043a6; --aq-blue-900: #001849;
    --aq-grey-25: #fafbfc; --aq-grey-50: #f4f7fa; --aq-grey-100: #ebeff4; --aq-grey-200: #dde3eb; --aq-grey-300: #c7cfd9;
    --aq-grey-400: #9aa5b2; --aq-grey-500: #6b7785; --aq-grey-600: #505059; --aq-grey-900: #141619;
    --aq-success: #3fb07a; --aq-success-soft: #e0f1e8; --aq-success-ink: #1f7a52;
    --aq-warning: #efbb0f; --aq-warning-soft: #fcf1cc; --aq-warning-ink: #8a6d08;
    --aq-danger: #e14b4b; --aq-danger-soft: #fadcdc; --aq-danger-ink: #b5302f;

    --surface-page: var(--aq-grey-50); --surface-card: #fff; --surface-sunken: var(--aq-grey-100);
    --text-primary: var(--aq-grey-900); --text-secondary: var(--aq-grey-600); --text-muted: var(--aq-grey-500);
    --border-subtle: var(--aq-grey-200); --border-default: var(--aq-grey-300);
    --brand: var(--aq-blue-500); --action: var(--aq-blue-600);

    --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(16, 27, 51, .08), 0 1px 3px rgba(16, 27, 51, .06);
    --shadow-lg: 0 8px 24px rgba(16, 27, 51, .10), 0 2px 6px rgba(16, 27, 51, .06);
    --ease: cubic-bezier(.2, 0, 0, 1); --dur: 200ms;
    --font-ui: "Inter", "Hurme Geometric Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: "Hurme Geometric Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ---- Browser surfaces ---- */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface-page); color: var(--text-primary); font-family: var(--font-ui); font-feature-settings: "cv11", "ss01"; }
::selection { background: var(--aq-blue-100); color: var(--aq-blue-900); }
input, textarea { caret-color: var(--action); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
a { color: var(--action); text-underline-offset: .2em; }
* { scrollbar-width: thin; scrollbar-color: var(--aq-grey-300) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--aq-grey-300); border: 3px solid transparent; background-clip: padding-box; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--aq-grey-400); }
.num, .mud-table-cell.num, td.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: .8125rem; letter-spacing: -.01em; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }

/* ---- Page frame ---- */
.aq-page { padding: 24px 28px 48px; max-width: 1440px; margin: 0 auto; }
.aq-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.aq-page-head h1 { margin: 0; }
.aq-page-head .aq-sub { margin-top: 6px; color: var(--text-secondary); }
.aq-section { margin-top: 32px; scroll-margin-top: 120px; }
.aq-section > h2 { margin: 0 0 12px; }
.aq-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.aq-section-head h2 { margin: 0; }
.aq-section-head .aq-hint { color: var(--text-muted); font-size: .8125rem; }
.aq-panel { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.aq-panel-pad { padding: 16px 20px; }
@media (max-width: 640px) { .aq-page { padding: 16px 14px 40px; } }

/* ---- Status ---- */
.aq-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--aq-grey-300); flex: none; }
.aq-dot.online { background: var(--aq-success); box-shadow: 0 0 0 3px var(--aq-success-soft); }
.aq-dot.offline { background: var(--aq-grey-400); }
.aq-dot.never { background: transparent; border: 1.5px dashed var(--aq-grey-400); width: 9px; height: 9px; }
.aq-dot.disabled { background: var(--aq-danger); }
.aq-status { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

.aq-aqi { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px 1px 6px; border-radius: 999px; font-size: .8125rem;
    font-variant-numeric: tabular-nums; font-weight: 600; line-height: 1.6; white-space: nowrap; color: var(--text-primary); }  /* band Ink is for text on Fill, not on Soft */
.aq-aqi i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.aq-tag { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.aq-tag.ok { background: var(--aq-success-soft); color: var(--aq-success-ink); }
.aq-tag.pending { background: var(--aq-warning-soft); color: var(--aq-warning-ink); }
.aq-tag.idle { background: var(--surface-sunken); color: var(--text-secondary); }
.aq-tag.bad { background: var(--aq-danger-soft); color: var(--aq-danger-ink); }
.aq-tag.info { background: var(--aq-blue-50); color: var(--aq-blue-700); }

/* ---- Shell ---- */
.aq-brand { display: flex; align-items: center; gap: 10px; color: var(--aq-blue-900); text-decoration: none; }
.aq-brand svg { display: block; }
.aq-search { flex: 1 1 auto; max-width: 560px; margin: 0 24px; }
.aq-kbd { font-family: var(--font-ui); font-size: .6875rem; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border-default);
    border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; line-height: 1.5; background: #fff; }
.mud-appbar.aq-topbar { border-bottom: 1px solid var(--border-subtle); }
.mud-drawer.aq-rail { border-right: 1px solid var(--border-subtle); }
.aq-rail .mud-nav-link { border-radius: var(--radius-md); margin: 2px 10px; min-height: 40px; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.aq-rail .mud-nav-link.active { background: var(--aq-blue-50); color: var(--aq-blue-700); }
.aq-rail .mud-nav-link.active .mud-nav-link-icon { color: var(--aq-blue-600); }

/* ---- Tables ---- */
.aq-table .mud-table-head .mud-table-cell { font-size: .75rem; font-weight: 600; color: var(--text-secondary); background: var(--aq-grey-25); white-space: nowrap; }
.aq-table .mud-table-row.clickable { cursor: pointer; }
.aq-table .mud-table-cell { padding-top: 9px; padding-bottom: 9px; }
.aq-name { font-weight: 600; color: var(--text-primary); text-decoration: none; }
.aq-name:hover { color: var(--action); }

/* ---- Fleet bar ---- */
.aq-fleetbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-sunken); }
.aq-fleetbar span { display: block; height: 100%; }
.aq-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 10px; font-size: .8125rem; color: var(--text-secondary); }
.aq-legend b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.aq-legend a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.aq-legend a:hover b { color: var(--action); }

/* ---- Device page ---- */
.aq-readings { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); background: var(--surface-card); box-shadow: var(--shadow-sm); overflow: hidden; }
.aq-reading { padding: 12px 16px; border-right: 1px solid var(--border-subtle); min-width: 0; }
.aq-reading:last-child { border-right: 0; }
.aq-reading .k { font-size: .75rem; color: var(--text-muted); }
.aq-reading .v { font-family: var(--font-display); font-size: 1.375rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin-top: 2px; white-space: nowrap; }
.aq-reading .v small { font-family: var(--font-ui); font-size: .75rem; font-weight: 500; color: var(--text-muted); margin-left: 3px; }
.aq-reading .band { font-size: .75rem; font-weight: 600; margin-top: 2px; }

.aq-sectionnav { position: sticky; top: 56px; z-index: 5; display: flex; gap: 4px; overflow-x: auto; margin: 20px -28px 0; padding: 8px 28px;
    background: rgba(244, 247, 250, .92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border-subtle); }
.aq-sectionnav button { font: 600 .8125rem/1 var(--font-display); color: var(--text-secondary); background: none; border: 0; padding: 8px 12px; border-radius: var(--radius-md);
    cursor: pointer; white-space: nowrap; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.aq-sectionnav button:hover { background: #fff; color: var(--text-primary); }
.aq-sectionnav button .count { color: var(--text-muted); font-weight: 500; margin-left: 6px; }
@media (max-width: 640px) { .aq-sectionnav { margin: 16px -14px 0; padding: 8px 14px; } }

.aq-livelist { max-height: 420px; overflow: auto; }
.aq-livelist table { width: 100%; border-collapse: collapse; }
.aq-livelist td { padding: 6px 16px; border-bottom: 1px solid var(--aq-grey-100); font-size: .8125rem; }
.aq-livelist tr:hover td { background: var(--aq-grey-25); }
.aq-livelist td.v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.aq-livelist td.t { text-align: right; color: var(--text-muted); white-space: nowrap; width: 1%; }
.aq-livelist tr.picked td { background: var(--aq-blue-50); }

.aq-empty { padding: 28px 20px; text-align: center; color: var(--text-secondary); }
.aq-empty strong { display: block; color: var(--text-primary); font-family: var(--font-display); font-weight: 600; margin-bottom: 4px; }

/* ---- Map ---- */
.aq-map { height: calc(100vh - 56px); position: relative; }
.aq-map-legend { position: absolute; left: 16px; bottom: 24px; z-index: 500; padding: 12px 14px; }
.aq-map-legend div { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--text-secondary); line-height: 1.9; }
.aq-map-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.leaflet-popup-content-wrapper { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-family: var(--font-ui); }
.leaflet-container { font-family: var(--font-ui); background: var(--aq-grey-100); }

/* ---- Blazor chrome ---- */
#blazor-error-ui { display: none; position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 2000; padding: 10px 16px;
    background: var(--aq-blue-900); color: #e6edf7; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); font-size: .875rem; }
#blazor-error-ui a { color: #fff; margin-left: 12px; }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: 12px; background: none; border: 0; color: inherit; padding: 2px; display: inline-flex; vertical-align: middle; }

/* ---- Shell details ---- */
.aq-product { font: 600 .8125rem/1 var(--font-display); color: var(--text-muted); margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--border-subtle); }
.aq-search { position: relative; }
.aq-search .mud-input-outlined { background: var(--aq-grey-25); }
.aq-search-hint { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
@media (max-width: 600px) { .aq-search { margin: 0 8px; } }

/* ---- Account pages (static Identity forms on Bootstrap) ---- */
.aq-account { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; background: var(--surface-page); }
.aq-account-brand { margin-bottom: 24px; }
.aq-account-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 28px 28px 24px; }
.aq-account-card h1, .aq-account-card h2, .aq-account-card h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; }
.aq-account-card h1 { font-size: 1.75rem; margin-bottom: 4px; }
.aq-account-card .row, .aq-account-card .col-lg-6, .aq-account-card .col-md-4 { all: unset; display: block; }
.aq-account-card .form-floating > .form-control { border-color: var(--border-default); border-radius: var(--radius-md); }
.aq-account-card .form-control:focus { border-color: var(--action); box-shadow: 0 0 0 3px var(--aq-blue-100); }
.aq-account-card .btn-primary { background: var(--action); border-color: var(--action); border-radius: var(--radius-md); font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; padding: 10px 16px; }
.aq-account-card .btn-primary:hover { background: var(--aq-blue-700); border-color: var(--aq-blue-700); }
.aq-account-card .btn-link { color: var(--action); }
.aq-account-card hr { border-color: var(--border-subtle); opacity: 1; }
.aq-account-card .text-danger { color: var(--aq-danger-ink) !important; }
.aq-account-foot { margin-top: 20px; color: var(--text-muted); font-size: .75rem; }

.aq-menu-form { margin: 0; }
.aq-menu-btn { display: flex; align-items: center; width: 100%; padding: 6px 16px; background: none; border: 0; font: inherit; font-size: .875rem; color: var(--text-primary); cursor: pointer; text-align: left; }
.aq-menu-btn:hover { background: var(--aq-grey-50); }
.aq-menu-btn .mud-icon-root { color: var(--text-muted); }

/* ---- Device page header ---- */
.aq-crumbs { font-size: .8125rem; color: var(--text-muted); margin-bottom: 10px; }
.aq-crumbs a { color: var(--text-secondary); text-decoration: none; }
.aq-crumbs a:hover { color: var(--action); }
.aq-crumbs span { margin: 0 8px; color: var(--aq-grey-300); }
.aq-devmeta { display: flex; flex-wrap: wrap; gap: 4px 0; margin-top: 8px; color: var(--text-secondary); font-size: .8125rem; }
.aq-devmeta > span:not(:last-child)::after { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--aq-grey-300); margin: 0 10px; vertical-align: middle; }
.aq-overview { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: stretch; }
.aq-overview > .aq-panel:last-child .aq-livelist { flex: 1 1 auto; max-height: 360px; }
@media (max-width: 960px) { .aq-overview { grid-template-columns: 1fr; } }

/* ---- Config + commands ---- */
.aq-config td { vertical-align: middle; }
.aq-history .mud-expand-panel { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg) !important; background: #fff; }
.aq-history .mud-expand-panel-header { font: 600 .8125rem var(--font-display); color: var(--text-secondary); }
.aq-rpcform { display: grid; grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.aq-rpcform .aq-rpcsend { margin-top: 6px; height: 40px; }
@media (max-width: 720px) { .aq-rpcform { grid-template-columns: 1fr; } }
.aq-table .mud-table-root thead th { font-size: .75rem; font-weight: 600; color: var(--text-secondary); background: var(--aq-grey-25); white-space: nowrap; }
.aq-tiles { filter: grayscale(.85) contrast(.9) brightness(1.06); }
.aq-account-lead { color: var(--text-secondary); margin: 0 0 20px; }
.aq-attention { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 500px), 1fr)); gap: 32px 24px; margin-top: 32px; }
.aq-topbar .mud-toolbar { gap: 4px; }
.aq-search { margin: 0 auto 0 28px; width: 100%; }
@media (max-width: 600px) { .aq-search { margin: 0 8px; } .aq-search-hint { display: none !important; } }
h1:focus, h1:focus-visible { outline: none; }  /* FocusOnNavigate moves focus to the page heading for screen readers */
.aq-statusfilter { display: inline-flex !important; width: auto; }
.aq-statusfilter .mud-toggle-item { min-height: 38px; height: 38px;  /* + 2px group border = 40px, same as inputs */ padding: 0 16px !important; flex: none; font: 600 .8125rem var(--font-display); text-transform: none; }
.aq-table td .mud-tooltip-root { display: inline-flex; }
.aq-config td:last-child { white-space: nowrap; }
.aq-filter { min-width: 200px; max-width: 260px; }
.aq-filter-sm { min-width: 140px; max-width: 180px; }
.aq-narrow { display: none; }
@media (max-width: 760px) {
  .aq-wide, .aq-wide-inline { display: none !important; }
  .aq-narrow { display: block; }
  .aq-filter, .aq-filter-sm { min-width: 0; max-width: none; flex: 1 1 40%; }
  .aq-page-head { align-items: flex-start; }
}
.aq-section-head { flex-wrap: wrap; }
@media (max-width: 760px) {
  .aq-section-head .aq-hint { flex-basis: 100%; }
  .aq-table .mud-table-cell, .aq-table td, .aq-table th { padding-left: 8px !important; padding-right: 8px !important; }
}
.aq-useractions { white-space: nowrap; }
.aq-tag.aq-narrow { display: none; }
@media (max-width: 760px) {
  .aq-tag.aq-narrow { display: inline-flex; }
  .aq-table th[style*="170px"] { width: auto !important; }
}

/* Devices filters: one 40px row; table grows with rows and the phone uses page scroll */
.aq-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.aq-filters .mud-input-control { margin-top: 0 !important; margin-bottom: 0 !important; }
.aq-filters .mud-input-outlined, .aq-filters .mud-select .mud-input { min-height: 40px; }
.aq-filterquery { flex: 0 1 340px; }
.aq-filterpair { display: flex; gap: 12px; }
.aq-statusfilter .mud-toggle-item-selected .aq-count { color: inherit; opacity: .85; }
.aq-count { color: var(--text-muted); }
.aq-table .mud-table-container { height: auto !important; max-height: calc(100vh - 264px); }
.aq-narrow-inline { display: none; }
.aq-map-legend summary { font: 600 .9375rem var(--font-display); cursor: pointer; margin-bottom: 4px; list-style-position: inside; }
.aq-map-legend:not([open]) summary { margin-bottom: 0; }
.aq-sectionnav button[aria-current] { background: #fff; color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--action); }
@media (max-width: 760px) {
  .aq-narrow-inline { display: inline-block; }
  .aq-table .mud-table-container { max-height: none; }
  .aq-filterquery { flex: 1 1 100%; }
  .aq-filterpair { flex: 1 1 100%; }
  .aq-filterpair > * { flex: 1 1 50%; min-width: 0; max-width: none; }
  .aq-useremail { word-break: normal; overflow-wrap: anywhere; }
}
