/*
  Fyxdo — app-schil: menu, zoeken, lege staten en systeemtoestanden.
  Laadvolgorde: brand/fonts/fonts.css → brand/tokens.css → brand/icons/icons.css
               → screens/auth/auth.css (basiscomponenten: knop, melding, kaart, rij, link) → app.css
  Alleen variabelen uit tokens.css. Geen gradiënten, geen schaduwen.

  Breed scherm: in de app @media (min-width: 768px). Hier een container query,
  zodat mobiel en breed in de referentie naast elkaar staan.
*/

/* ---------- Skip-link ---------- */
.fx-skip {
  position: absolute;
  left: var(--space-2);
  top: var(--space-2);
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.fx-skip:focus { transform: none; outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Schil: mobiel ---------- */
.fx-shell {
  position: relative;
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas: "header" "main" "banner" "nav";
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}
.fx-side { display: contents; }

.fx-header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 2;
  height: 56px;
  padding: 0 var(--space-3) 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.fx-home-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-touch);
  min-width: var(--size-touch);
  border-radius: var(--radius-sm);
}
.fx-home-link img { display: block; height: var(--size-wordmark-header); width: auto; }
.fx-home-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Zoekknop: mobiel alleen icoon, breed een veld-achtige knop */
.fx-search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: var(--size-touch);
  height: var(--size-touch);
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
}
.fx-search-btn:hover { background: var(--tint); }
.fx-search-btn[aria-current="page"] { background: var(--tint); }
.fx-search-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-search-btn .fx-search-text,
.fx-search-btn kbd { display: none; }

.fx-main {
  grid-area: main;
  min-width: 0;
  padding: var(--space-6) var(--space-6) var(--space-10);
}
.fx-main:focus { outline: none; }

/* ---------- Menu ---------- */
.fx-nav {
  grid-area: nav;
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.fx-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  height: var(--size-nav-bar);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.fx-nav a {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px; line-height: 16px; font-weight: 600;   /* text-label, zonder hoofdletters */
}
.fx-nav-icon {
  width: 56px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
}
.fx-nav a[aria-current] { color: var(--text); }
.fx-nav a[aria-current] .fx-nav-icon { background: var(--tint); }
.fx-nav a:focus-visible { outline: 2px solid var(--focus); outline-offset: -4px; border-radius: var(--radius-md); }

/* ---------- Pagina-opbouw ---------- */
.fx-page-head { margin: 0 0 var(--space-6); }
.fx-page-head h1 { margin: 0; font-size: 28px; line-height: 34px; font-weight: 600; }   /* text-h1 */
.fx-page-head p { margin: var(--space-1) 0 0; color: var(--text-muted); }
.fx-page-head--row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }

.fx-more {
  margin: var(--space-4) 0 0;
  color: var(--text-muted);
}
.fx-more a { margin-left: var(--space-1); }

/* ---------- Subpagina: terug naar het bovenliggende scherm ---------- */
.fx-backlink {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--size-touch);                 /* aanraakdoel 44 px */
  margin: calc(var(--space-3) * -1) 0 var(--space-2) calc(var(--space-2) * -1);   /* links: icoon lijnt uit met de h1 */
  padding: 0 var(--space-2);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px; line-height: 20px; font-weight: 600;   /* text-field-label */
  text-decoration: none;
}
.fx-backlink:hover span { text-decoration: underline; text-underline-offset: 3px; }
.fx-backlink:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Links naar de juridische pagina's, onder Account */
.fx-legal-links { margin: var(--space-6) 0 0; font-size: 14px; line-height: 20px; color: var(--text-muted); }
.fx-legal-links .fx-link { font-weight: 400; }

/* ---------- Agenda: datum (Dag/Week-knop is nu niet in gebruik; komt terug met het agenda-ontwerp) ---------- */
.fx-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-6);
}
.fx-segment {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--card);
}
.fx-segment button {
  min-width: 64px;
  height: 40px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px; line-height: 20px; font-weight: 600;
  cursor: pointer;
}
.fx-segment button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.fx-segment button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.fx-datenav { display: flex; align-items: center; gap: var(--space-2); }
.fx-iconbtn {
  width: var(--size-touch);
  height: var(--size-touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.fx-iconbtn--plain { border-color: transparent; background: transparent; }
.fx-iconbtn:hover { background: var(--tint); }
.fx-iconbtn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-btn--auto { width: auto; }
.fx-btn--compact { height: var(--size-touch); padding: 0 var(--space-4); font-size: 14px; line-height: 20px; }
.fx-date { margin: 0 0 var(--space-4); font-size: 20px; line-height: 28px; font-weight: 600; }   /* text-h2 */

/* ---------- Zoeken ---------- */
.fx-searchbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-6);
}
.fx-searchbar .fx-control { flex: 1; }
.fx-input--search { padding-left: 44px; }
.fx-search-ico {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.fx-hint-block { margin: 0; color: var(--text-muted); }
.fx-results h2 { margin: var(--space-6) 0 var(--space-2); font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; color: var(--text-muted); }
.fx-results h2:first-child { margin-top: 0; }
.fx-results mark { background: var(--tint); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ---------- Statusbalken ---------- */
.fx-statusbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) var(--space-6);
  padding: var(--space-2) var(--space-6);
  font-size: 14px; line-height: 20px; font-weight: 600;
}
.fx-statusbar--offline { background: var(--tint); color: var(--text); }
.fx-statusbar--online  { background: var(--green-tint); color: var(--green-text); }

/* Melding "nieuwe versie" */
.fx-update {
  grid-area: banner;
  position: sticky;
  bottom: calc(var(--size-nav-bar) + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px; line-height: 20px;
}
.fx-update p { margin: 0; flex: 1; }
.fx-update-actions { display: flex; align-items: center; gap: var(--space-1); }
.fx-update strong { display: block; font-weight: 600; }
.fx-update .fx-btn {
  width: auto;
  height: var(--size-touch);
  padding: 0 var(--space-4);
  background: var(--on-primary);
  border-color: var(--on-primary);
  color: var(--primary);
  font-size: 14px; line-height: 20px;
}
.fx-update .fx-btn:focus-visible,
.fx-update .fx-iconbtn:focus-visible { outline-color: var(--focus-on-primary); }
.fx-update .fx-iconbtn { color: var(--on-primary); border-color: transparent; background: transparent; }
.fx-update .fx-iconbtn:hover { background: var(--primary); }
.fx-update .fx-spinner { border-color: var(--primary); border-right-color: transparent; }

/* ---------- Leeg / fout in de inhoud ---------- */
.fx-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 1px solid var(--border);
}
.fx-state h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; }
.fx-state p { margin: 0; color: var(--text-muted); }
.fx-state--danger { background: var(--danger-tint); border-color: var(--danger-tint); }
.fx-state--danger h2 { color: var(--danger); }
.fx-state--danger p { color: var(--text); }
.fx-state .fx-btn { width: auto; }
.fx-state-icon { color: var(--text-muted); }
.fx-state--danger .fx-state-icon { color: var(--danger); }
.fx-code { font-variant-numeric: tabular-nums; user-select: all; font-weight: 600; color: var(--text); }

/* ---------- Laadscherm (in index.html, vóór de app start) ---------- */
.fx-boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.fx-boot img {
  width: 72px;
  height: 72px;
  opacity: 0;
  animation: fx-boot-in .3s ease-out .4s forwards;   /* pas na 0,4 s zichtbaar: geen flits bij snel laden */
}
@keyframes fx-boot-in { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .fx-boot img { animation: none; opacity: 1; } }

/* ---------- Breed scherm ---------- */
@container (min-width: 768px) {
  .fx-shell {
    grid-template-columns: var(--size-sidebar) minmax(0, 1fr);
    grid-template-rows: 1fr;
    grid-template-areas: "side main";
  }
  .fx-side {
    grid-area: side;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    align-self: start;
    min-height: 100%;
    height: 100%;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: var(--space-6) var(--space-4);
    box-sizing: border-box;
    gap: var(--space-6);
  }
  .fx-header {
    position: static;
    height: auto;
    padding: 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-6);
    background: transparent;
    border: 0;
  }
  .fx-home-link { align-self: flex-start; padding: 0 var(--space-2); }

  .fx-search-btn {
    width: 100%;
    height: var(--size-touch);
    justify-content: flex-start;
    padding: 0 var(--space-3);
    box-sizing: border-box;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text-muted);
  }
  .fx-search-btn[aria-current="page"] { border-color: var(--primary); background: var(--tint); color: var(--text); }
  .fx-search-btn .fx-search-text { display: inline; flex: 1; font-size: 16px; line-height: 24px; }
  .fx-search-btn kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 12px; line-height: 16px; font-weight: 600;
    color: var(--text-muted);
  }

  .fx-nav { position: static; border: 0; padding: 0; background: transparent; }
  .fx-nav ul { height: auto; display: flex; flex-direction: column; gap: var(--space-1); }
  .fx-nav a {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-3);
    min-height: var(--size-touch);
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    font-size: 16px; line-height: 24px; font-weight: 400;
    color: var(--text);
  }
  .fx-nav-icon { width: auto; height: auto; background: transparent !important; color: var(--text-muted); }
  .fx-nav a:hover { background: var(--bg); }
  .fx-nav a[aria-current] { background: var(--tint); font-weight: 600; }
  .fx-nav a[aria-current] .fx-nav-icon { color: var(--text); }
  .fx-nav a:focus-visible { outline-offset: 2px; }

  .fx-main { padding: var(--space-10); box-sizing: border-box; width: 100%; }
  .fx-main > * { max-width: 880px; }                 /* inhoud max. 880 px; de statusbalk loopt door */
  .fx-main > .fx-statusbar { max-width: none; }
  .fx-statusbar { margin: calc(var(--space-10) * -1) calc(var(--space-10) * -1) var(--space-6); padding: var(--space-2) var(--space-10); }

  .fx-update {
    position: static;
    margin-top: auto;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }
  .fx-update-actions { display: flex; align-items: center; gap: var(--space-2); }
  .fx-update-actions .fx-btn { flex: 1; }
  .fx-searchbar .fx-back { display: none; }
  .fx-backlink { margin-top: calc(var(--space-4) * -1); }
}
