/* ==========================================================================
   ŽOGU FABRIKA — portal shell layout
   Served centrally by the portal app. Sections link it and never fork it.
   Everything here references var(--zf-*) from zf-tokens.css. No raw hex.
   ========================================================================== */

/* --- App frame ------------------------------------------------------------ */
.zf-app {
  display: grid;
  grid-template-columns: var(--zf-sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.zf-main { display: flex; flex-direction: column; min-width: 0; }
.zf-content {
  flex: 1;
  padding: var(--zf-space-6) var(--zf-space-8);
  max-width: var(--zf-content-max);
  width: 100%;
}

/* --- Brand ---------------------------------------------------------------- */
.zf-brand {
  display: flex; align-items: center; gap: var(--zf-space-3);
  height: var(--zf-topbar-h);
  padding: 0 var(--zf-space-4);
  border-bottom: 1px solid var(--zf-border-subtle);
  text-decoration: none; color: inherit; flex: none;
}
.zf-brand__mark { flex: none; }
.zf-brand__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.zf-brand__name {
  font-size: var(--zf-fs-12); font-weight: var(--zf-fw-bold);
  letter-spacing: var(--zf-ls-wide); color: var(--zf-text-primary);
  white-space: nowrap;
}
.zf-brand__sub {
  font-size: var(--zf-fs-11); color: var(--zf-text-muted);
  letter-spacing: var(--zf-ls-wide); text-transform: uppercase;
}

/* --- Sidebar -------------------------------------------------------------- */
.zf-sidebar { position: sticky; top: 0; height: 100vh; }
.zf-nav { padding: var(--zf-space-3) 0; flex: 1; overflow-y: auto; }
.zf-icon { flex: none; }
.zf-sidebar__foot {
  padding: var(--zf-space-4);
  border-top: 1px solid var(--zf-border-subtle);
  font-size: var(--zf-fs-11); color: var(--zf-text-muted);
}

/* --- Top bar -------------------------------------------------------------- */
.zf-topbar { position: sticky; top: 0; z-index: 20; }
.zf-topbar__spacer { flex: 1; }
.zf-crumb { font-size: var(--zf-fs-13); color: var(--zf-text-secondary); font-weight: var(--zf-fw-medium); }

/* --- User menu ------------------------------------------------------------ */
.zf-usermenu { position: relative; }
.zf-usermenu > summary { list-style: none; cursor: pointer; }
.zf-usermenu > summary::-webkit-details-marker { display: none; }
.zf-avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: var(--zf-radius-pill);
  background: var(--zf-accent-wash); color: var(--zf-accent);
  border: 1px solid var(--zf-border-default);
  font-size: var(--zf-fs-12); font-weight: var(--zf-fw-semibold);
  user-select: none;
}
.zf-usermenu__panel {
  position: absolute; right: 0; top: calc(100% + var(--zf-space-2));
  min-width: 200px; padding: var(--zf-space-3);
  display: flex; flex-direction: column; gap: var(--zf-space-2);
  background: var(--zf-bg-surface-raised);
  border: 1px solid var(--zf-border-strong);
  border-radius: var(--zf-radius-md);
  box-shadow: var(--zf-elev-2);
}
.zf-usermenu__name { font-size: var(--zf-fs-13); font-weight: var(--zf-fw-semibold); color: var(--zf-text-primary); }
.zf-usermenu__role { font-size: var(--zf-fs-11); color: var(--zf-text-muted);
  text-transform: uppercase; letter-spacing: var(--zf-ls-wide); }
.zf-usermenu__link { font-size: var(--zf-fs-13); color: var(--zf-text-secondary); text-decoration: none; }
.zf-usermenu__link:hover { color: var(--zf-accent); }

/* --- Page header ---------------------------------------------------------- */
.zf-page-head {
  display: flex; align-items: flex-start; gap: var(--zf-space-4);
  margin-bottom: var(--zf-space-6); flex-wrap: wrap;
}
.zf-page-head__actions { margin-left: auto; display: flex; gap: var(--zf-space-2); align-items: center; }
.zf-page-sub { font-size: var(--zf-fs-13); color: var(--zf-text-muted); margin-top: var(--zf-space-1); }

/* --- Grids ---------------------------------------------------------------- */
.zf-grid { display: grid; gap: var(--zf-space-4); }
.zf-grid--tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .zf-grid--tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px)  { .zf-grid--tiles { grid-template-columns: minmax(0, 1fr); } }

/* --- Section tiles on the portal home ------------------------------------- */
.zf-sectile {
  display: flex; flex-direction: column; gap: var(--zf-space-2);
  text-decoration: none; color: inherit;
  transition: background var(--zf-dur-fast) var(--zf-ease),
              border-color var(--zf-dur-fast) var(--zf-ease);
}
.zf-sectile:hover { background: var(--zf-bg-surface-hover); border-color: var(--zf-border-strong); }
.zf-sectile__top { display: flex; align-items: center; gap: var(--zf-space-3); }
.zf-sectile__icon {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: var(--zf-radius-md);
  background: var(--zf-accent-wash); color: var(--zf-accent);
}
.zf-sectile__name { font-size: var(--zf-fs-14); font-weight: var(--zf-fw-semibold); color: var(--zf-text-primary); }
.zf-sectile__desc { font-size: var(--zf-fs-12); color: var(--zf-text-muted); }
.zf-sectile__status { margin-top: auto; padding-top: var(--zf-space-3); }

/* --- Login ---------------------------------------------------------------- */
.zf-login {
  min-height: 100vh; display: grid; place-items: center;
  padding: var(--zf-space-6);
}
.zf-login__box { width: 100%; max-width: 380px; }
.zf-login__brand { display: flex; align-items: center; gap: var(--zf-space-3); justify-content: center;
  margin-bottom: var(--zf-space-6); }
.zf-field { display: flex; flex-direction: column; gap: var(--zf-space-2); margin-bottom: var(--zf-space-4); }
.zf-label { font-size: var(--zf-fs-11); font-weight: var(--zf-fw-semibold);
  letter-spacing: var(--zf-ls-wide); text-transform: uppercase; color: var(--zf-text-muted); }
.zf-input, .zf-select { width: 100%; }
.zf-btn--block { width: 100%; justify-content: center; }

/* --- Alerts --------------------------------------------------------------- */
.zf-alert {
  display: flex; gap: var(--zf-space-2); align-items: flex-start;
  padding: var(--zf-space-3);
  border-radius: var(--zf-radius-md);
  border: 1px solid var(--zf-border-default);
  background: var(--zf-bg-inset);
  font-size: var(--zf-fs-13);
  margin-bottom: var(--zf-space-4);
}
.zf-alert--error { color: var(--zf-status-critical-text); border-color: rgba(239,122,122,.35); }
.zf-alert--good  { color: var(--zf-status-good-text); }

/* --- Empty / error state -------------------------------------------------- */
.zf-empty { text-align: center; padding: var(--zf-space-12) var(--zf-space-4); }
.zf-empty__code { font-size: var(--zf-fs-40); font-weight: var(--zf-fw-semibold);
  color: var(--zf-text-disabled); letter-spacing: var(--zf-ls-tight); }
.zf-empty h1 { margin: var(--zf-space-2) 0; }
.zf-empty p { color: var(--zf-text-muted); margin: 0 0 var(--zf-space-6); }

/* --- Utility -------------------------------------------------------------- */
.zf-stack { display: flex; flex-direction: column; gap: var(--zf-space-4); }
.zf-row   { display: flex; align-items: center; gap: var(--zf-space-3); flex-wrap: wrap; }
.zf-muted { color: var(--zf-text-muted); }
.zf-scroll-x { overflow-x: auto; }

/* --------------------------------------------------------------------------
   Narrow screens. Mobile is out of scope for v1, but the sidebar must not
   simply vanish or a phone user lands with no way to reach another section.
   It becomes a horizontal strip above the content instead.
   -------------------------------------------------------------------------- */
@media (max-width: 700px) {
  .zf-app { grid-template-columns: minmax(0, 1fr); }
  .zf-sidebar { position: static; height: auto; width: auto;
    border-right: 0; border-bottom: 1px solid var(--zf-border-subtle); }
  .zf-nav { display: flex; gap: var(--zf-space-1); overflow-x: auto; padding: var(--zf-space-2); }
  .zf-nav__item { margin: 0; white-space: nowrap; }
  .zf-nav__item--active::before { display: none; }
  /* The nav is a horizontal strip here, so nesting has nothing to indent
     from — sub-pages become peers rather than children. */
  .zf-nav__sub { margin: 0; padding-left: 0; border-left: 0;
                 flex-direction: row; gap: var(--zf-space-1); }
  .zf-nav__subitem { white-space: nowrap; }
  .zf-sidebar__foot { display: none; }
  .zf-content { padding: var(--zf-space-4); }
}

/* --- Real logo mark ------------------------------------------------------- */
/* The mark is a gray disc with a white ring; it needs a little breathing room
   on the dark nav or the ring reads as a hard edge. */
.zf-brand__mark { display: block; border-radius: 50%; }
.zf-login__brand--stacked { flex-direction: column; gap: var(--zf-space-3); }
.zf-login__logo { display: block; border-radius: 50%; }
