/* ============================================================
   Uptimast demo — design tokens (from the Flutter app theme)
   ============================================================ */
:root {
  /* brand */
  --uptimast-red: #D8353A;      /* primary action / accent */
  --uptimast-maroon: #4C1007;   /* wordmark / outlined-button text */
  --uptimast-rose: #E7D9D9;     /* STOP / pale fills */
  --logo-grad: linear-gradient(90deg,#9E2A29 33%,#B72E30 61%,#D8353A 100%);

  /* theme */
  --primary-text: #14181B;
  --secondary-text: #57636C;
  --bg-fb: #FBFBFB;             /* app background */
  --primary-bg: #F1F4F8;        /* pole fill / segmented track */
  --secondary-bg: #FFFFFF;      /* cards */
  --alternate: #E0E3E7;
  --border: #CCCCCC;
  --border-soft: #D4D4D4;
  --textfield-unfocused: #A9A9A9;
  --disabled: #95A0A8;
  --success: #249689;
  --error: #FF5963;

  /* type */
  --font-ui: 'Lexend', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

  /* metrics */
  --r-btn: 6px; --r-sm: 8px; --r-md: 16px;
  --sh-card: 0 1px 3px rgba(0,0,0,.12);
  --sh-lift: 0 8px 24px rgba(0,0,0,.18);

  --device-w: 393px;
  --device-h: 852px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  color: var(--primary-text);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(216,53,58,.10), transparent 60%),
    #f3f0ef;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }

/* ============================================================
   Stage (page chrome around the phone)
   ============================================================ */
.stage {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 40px;
}
.stage-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 14px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--uptimast-maroon);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
}
.back-link:hover { background: rgba(76,16,7,.06); }
.stage-bar__right { display: inline-flex; align-items: center; gap: 10px; }
.demo-pill {
  font-size: 11px; font-weight: 700; letter-spacing: .12em;
  color: #fff; background: var(--uptimast-red);
  padding: 4px 9px; border-radius: 999px;
}
.lang-toggle {
  border: 1px solid var(--border); background: #fff;
  color: var(--secondary-text); font-weight: 600; font-size: 12px;
  width: 40px; height: 28px; border-radius: 999px;
}
.stage-hint {
  max-width: 460px; text-align: center;
  color: var(--secondary-text); font-size: 13px; line-height: 1.5;
  margin: 0 0 18px;
}

/* ============================================================
   Device frame
   ============================================================ */
.device {
  width: var(--device-w);
  height: min(var(--device-h), calc(100vh - 150px));
  max-width: 100%;
  background: #0e0e10;
  border-radius: 44px;
  padding: 10px;
  box-shadow: var(--sh-lift), 0 0 0 2px #232326;
  position: relative;
}
.device__notch {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  width: 130px; height: 26px; background: #0e0e10; border-radius: 0 0 16px 16px;
  z-index: 5;
}
.device__screen {
  position: relative;
  width: 100%; height: 100%;
  background: var(--bg-fb);
  border-radius: 36px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: .98;
}

/* App bar (slim brand strip) */
.appbar {
  flex: none;
  height: 62px;
  display: flex; align-items: center; justify-content: center;
  padding-top: 24px;
  background: #fff;
  border-bottom: 1px solid var(--primary-bg);
}
.appbar__brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; display: inline-block; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-word { color: var(--uptimast-maroon); font-weight: 700; font-size: 22px; letter-spacing: .2px; }

/* Tab view */
.tabview {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 18px;
}
.tabview::-webkit-scrollbar { width: 0; }

/* ============================================================
   Bottom tab bar
   ============================================================ */
.tabbar {
  flex: none;
  display: flex;
  background: #F9F9F9;
  border-top: 1px solid #9E9E9E;
}
.tabbar__btn {
  flex: 1;
  border: none; background: none;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--secondary-text);
  font-size: 11px; font-weight: 500;
}
.tabbar__btn.is-active { color: var(--uptimast-red); }
.tabbar__flagicon { width: 25px; height: 25px; display: inline-block; }
.tabbar__flagicon svg { width: 100%; height: 100%; display: block; }

/* ============================================================
   Shared controls
   ============================================================ */
.pole-select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  background: #fff;
  padding: 0 14px;
  font-size: 15px; color: var(--primary-text);
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><path fill='%2357636C' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.btn {
  border: none;
  border-radius: var(--r-btn);
  font-weight: 300;
  font-size: 15px;
  padding: 0 16px;
  height: 43px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn--primary { background: var(--uptimast-red); color: #fff; }
.btn--primary:disabled { background: var(--disabled); color: #fff; cursor: not-allowed; }
.btn--ghost { background: var(--uptimast-rose); color: var(--uptimast-maroon); border: 2px solid var(--border); }
.btn--soft { background: var(--primary-bg); color: var(--secondary-text); text-decoration: underline; height: 40px; }
.btn--block { width: 100%; }

.field-label { font-weight: 500; font-size: 14px; margin: 14px 0 6px; display: block; }
.text-input {
  width: 100%; height: 44px;
  border: 2px solid var(--textfield-unfocused);
  border-radius: var(--r-btn);
  background: #fff; padding: 0 12px;
  font-family: inherit; font-size: 15px; color: var(--primary-text);
}
.text-input:focus { outline: none; border-color: var(--primary-text); }

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--primary-bg);
  border: 1px solid var(--alternate);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 3px;
}
.segmented__btn {
  border: none; background: transparent;
  border-radius: 4px; height: 30px; min-width: 82px;
  font-size: 13px; font-weight: 500; color: var(--primary-text);
}
.segmented__btn.is-on { background: var(--uptimast-red); color: #fff; }
.segmented__btn:disabled { opacity: 0; pointer-events: none; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--alternate); transition: background .2s;
}
.switch__track::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.switch input:checked + .switch__track { background: var(--uptimast-red); }
.switch input:checked + .switch__track::before { transform: translateX(20px); background: var(--alternate); }

/* ============================================================
   Mit Flag tab
   ============================================================ */
.flag-screen { display: flex; flex-direction: column; min-height: 100%; }
.flag-status {
  text-align: center; font-size: 19px; margin: 54px 0 6px; min-height: 26px;
  color: var(--primary-text);
}
.flag-status.is-moving { color: var(--uptimast-red); }

.flag-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 470px;
  overflow: hidden;
}

/* Dome / ground — a single clean top arc. Fill = page bg so only the arc line
   shows; sits ABOVE the mast (z-index) so the pole base tucks into the ground. */
.arch {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 108%; height: 170px;
  background: var(--bg-fb);
  border-top: 1px solid #D9D9D9;
  border-radius: 50% 50% 0 0 / 100px 100px 0 0;
  z-index: 1; pointer-events: none;
}

/* Mast sits behind the dome; left-of-center; light grey like prod; base hidden in the ground */
.mast {
  position: absolute;
  left: 39%; transform: translateX(-50%);
  top: 40px;          /* start lower so there's a gap under the status text */
  bottom: 74px;
  width: 16px;
  background: #E9E7E5;
  border: 1px solid #D9D5D2;
  border-radius: 3px 3px 0 0;
  box-shadow: inset -2px 0 3px rgba(0,0,0,.06);
  z-index: 0;
}

/* The flag hangs flush from the top-right of the mast (top = full, middle = half).
   preserveAspectRatio=xMinYMid on the SVG left-aligns the drawing, so it touches the pole. */
.flag {
  position: absolute;
  left: calc(39% + 6px);
  width: 84px; height: 58px;
  top: var(--flag-top, 30px);
  z-index: 2;
}
.flag svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,.22)); }

/* Waiting screen shown while the flag is physically moving (app's LoadingWidget) */
.loading-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 128px;
  background: var(--secondary-bg); z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.loading-txt { font-size: 18px; font-weight: 600; color: var(--primary-text); }
.loading-anim { position: relative; width: 90px; height: 130px; margin-top: 14px; }
.loading-pole {
  position: absolute; left: 40px; bottom: 0; width: 6px; height: 100%;
  background: #E0E3E7; border-radius: 3px;
}
.loading-flag { position: absolute; left: 46px; width: 46px; height: 31px; bottom: 0; animation: hoist 1.7s ease-in-out infinite; }
.loading-flag svg { width: 100%; height: 100%; display: block; }
@keyframes hoist {
  0% { bottom: 0; opacity: .35; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { bottom: calc(100% - 31px); opacity: 1; }
}

/* Overlay card: "Vælg flag for at se status" / offline */
.notsel-card {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  z-index: 3;
  width: 250px; max-width: 80%;
  background: #fff; border-radius: 6px;
  box-shadow: 0 1px 10px rgba(0,0,0,.12);
  padding: 44px 18px; text-align: center;
  font-size: 18px; font-weight: 500; color: var(--primary-text); line-height: 1.4;
}

/* Bottom controls sit on the arch */
.stage-bottom {
  position: absolute; left: 0; right: 0; bottom: 12px; z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 0 16px;
}
.knap-row { display: flex; gap: 12px; width: 100%; }
.knap {
  flex: 1; height: 44px; border: none; border-radius: var(--r-btn);
  background: var(--uptimast-red); color: #fff; font-size: 15px; font-weight: 400;
}
/* Knap2: pale pink secondary style (matches prod) */
.knap--soft { background: var(--uptimast-rose); color: var(--uptimast-maroon); }
.knap:disabled { background: var(--disabled); color: #fff; cursor: not-allowed; }

/* small inline spinner */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(216,53,58,.25); border-top-color: var(--uptimast-red);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin-icon { animation: spin 2s linear infinite; display: inline-block; }

/* ============================================================
   Planlægning tab
   ============================================================ */
.plan-toggle-row {
  height: 40px; display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 10px; font-size: 14px; font-weight: 500;
}
.events-card {
  margin-top: 10px;
  background: #fff; border: 1px solid var(--border-soft); border-radius: var(--r-sm);
  padding: 10px 4px; min-height: 220px;
}
.events-card__title { font-size: 18px; font-weight: 600; padding: 4px 10px 8px; }
.event-row {
  display: flex; align-items: center; gap: 8px;
  padding: 12px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.event-row:last-child { border-bottom: none; }
.event-row__main { flex: 1; min-width: 0; }
.event-row__title { font-size: 14px; }
.event-row.is-global .event-row__title { color: var(--uptimast-red); }
.event-row__sub { font-size: 12px; color: var(--secondary-text); }
.event-row__chev { color: var(--secondary-text); flex: none; }
.events-empty { text-align: center; color: var(--secondary-text); font-size: 15px; padding: 40px 20px; }

.fab {
  position: absolute; right: 18px; bottom: 74px; z-index: 6;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--uptimast-red); color: #fff; border: none;
  font-size: 30px; line-height: 1;
  box-shadow: var(--sh-lift);
  display: flex; align-items: center; justify-content: center;
}
.fab:disabled { background: var(--disabled); }

/* ============================================================
   Settings tab
   ============================================================ */
/* Prod-style settings card */
.settings-card {
  background: #fff; border: 1px solid var(--border-soft); border-radius: var(--r-sm);
  padding: 14px 16px 18px; margin-top: 12px;
}
.settings-card__title { font-size: 20px; font-weight: 600; }
.settings-card__sub { font-size: 12px; font-weight: 300; color: var(--secondary-text); margin-top: 2px; }
.field-desc { font-size: 12px; font-weight: 300; color: var(--secondary-text); margin: 2px 0 8px; line-height: 1.45; }
input.range { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px; background: #EADADA; margin: 8px 0 4px; }
input.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--uptimast-red); cursor: pointer; }
input.range::-moz-range-thumb { width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--uptimast-red); cursor: pointer; }
.range-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--secondary-text); }
.sun-row { display: flex; gap: 28px; align-items: center; margin: 6px 0 10px; }
.sun-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.opned-row { display: flex; gap: 18px; }
.opned-field { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.opned-field .text-input { width: 90px; height: 40px; }

.settings-group { background: #fff; border: 1px solid var(--border-soft); border-radius: var(--r-sm); padding: 4px 14px 14px; margin-top: 12px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--primary-bg); }
.settings-row:last-child { border-bottom: none; }
.settings-row__label { font-size: 14px; }
.settings-row__hint { font-size: 12px; color: var(--secondary-text); margin-top: 2px; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--secondary-text); margin: 18px 2px 2px; }

/* ============================================================
   Modals
   ============================================================ */
.modal-host {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.42);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-host[hidden] { display: none; }
.modal {
  width: 300px; max-width: 100%;
  max-height: calc(100vh - 40px);
  background: var(--bg-fb); border: 1px solid var(--border-soft);
  border-radius: var(--r-btn); padding: 14px 12px;
  overflow-y: auto;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; }
.modal__title { font-size: 20px; font-weight: 600; }
.modal__close {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  border: none; background: var(--primary-bg); color: var(--secondary-text);
  font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.modal__sub { font-size: 12px; font-weight: 300; color: var(--primary-text); margin: 6px 0 12px; }
.modal .field-block { text-align: center; margin: 8px 0; }
.modal .field-block > .seg-caption { font-weight: 500; font-size: 15px; margin-bottom: 6px; display: block; }

/* Manual OP/STOP/NED stack */
.run-box {
  width: 128px; margin: 10px auto 0;
  border: .5px solid var(--secondary-text); border-radius: 4px;
  padding: 10px; display: flex; flex-direction: column; gap: 10px;
}
.run-btn { height: 35px; width: 100%; border: none; border-radius: var(--r-btn); font-size: 14px; font-weight: 500; }
.run-btn--go { background: var(--uptimast-red); color: #fff; }
.run-btn--stop { background: var(--uptimast-rose); color: var(--uptimast-maroon); border: 2px solid var(--border); }
.run-btn:disabled { background: var(--disabled); color: #fff; cursor: not-allowed; }

.picker-row { display: flex; gap: 10px; }
.picker-row .text-input { flex: 1; }
.modal-actions { display: flex; justify-content: space-evenly; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; height: 42px; }

/* ============================================================
   Toasts
   ============================================================ */
.toast-host {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #202124; color: #fff; font-size: 14px;
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--sh-lift);
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ============================================================
   Responsive: on small screens the phone fills the viewport
   ============================================================ */
@media (max-width: 460px), (max-height: 720px) {
  body { background: var(--bg-fb); }
  .stage { padding: 0; }
  .stage-bar { max-width: 100%; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--primary-bg); }
  .stage-hint { display: none; }
  .device {
    width: 100%; height: calc(100vh - 45px); height: calc(100dvh - 45px);
    border-radius: 0; padding: 0; box-shadow: none;
  }
  .device__notch { display: none; }
  .device__screen { border-radius: 0; }
}
