/* App shell + core components — design-system/components.md.
   Uses --z-* tokens only; see tokens.css for the contract. */

/* ---- 1. App shell ---- */
.z-app {
  display: flex;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
}

.z-sidebar {
  width: var(--z-sidebar-w);
  background: var(--z-bg-inverse);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: var(--z-space-4) 0;
}

.z-sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 0 var(--z-space-4) var(--z-space-4);
  color: var(--z-text-inverse);
  font-family: var(--z-font-display);
  font-size: var(--z-text-xl);
  font-weight: var(--z-weight-semibold);
}

.z-nav__item {
  display: flex;
  align-items: center;
  gap: var(--z-space-3);
  padding: var(--z-space-3) var(--z-space-4);
  color: var(--z-text-inverse);
  opacity: 0.8;
  text-decoration: none;
  font-size: var(--z-text-md);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.z-nav__item:hover { opacity: 1; }

.z-nav__item--active {
  background: var(--z-primary-700);
  opacity: 1;
  border-left-color: var(--z-accent-400);
  font-weight: var(--z-weight-medium);
}

.z-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.z-topbar {
  height: 56px;
  background: var(--z-bg-surface);
  border-bottom: 1px solid var(--z-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--z-space-6);
  flex-shrink: 0;
}

.z-topbar__user {
  display: flex;
  align-items: center;
  gap: var(--z-space-3);
  font-size: var(--z-text-sm);
  color: var(--z-text-secondary);
}

.z-page {
  max-width: var(--z-container-max);
  width: 100%;
  margin: 0 auto;
  padding: var(--z-space-6);
}

.z-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--z-space-6);
}

.z-page__title { font-size: var(--z-text-3xl); }

.z-tabbar {
  display: none;
}

@media (max-width: 768px) {
  .z-sidebar { display: none; }
  .z-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--z-bg-inverse);
    z-index: var(--z-layer-sticky);
  }
  .z-tabbar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--z-text-inverse);
    opacity: 0.75;
    font-size: var(--z-text-2xs);
    text-decoration: none;
    cursor: pointer;
  }
  .z-tabbar__item--active { opacity: 1; }
  .z-main { padding-bottom: 64px; }
  .z-page { padding: var(--z-space-4); }
}

/* ---- 2. Button ---- */
.z-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--z-space-2);
  height: var(--z-control-md);
  padding: 0 var(--z-space-4);
  border-radius: var(--z-radius-md);
  font-size: var(--z-text-md);
  font-weight: var(--z-weight-medium);
  border: none;
  cursor: pointer;
  transition: background var(--z-duration-fast) var(--z-ease-standard);
  white-space: nowrap;
}
.z-btn--primary { background: var(--z-action-primary-bg); color: var(--z-action-primary-fg); }
.z-btn--primary:hover { background: var(--z-action-primary-bg-hover); }
.z-btn--primary:active { background: var(--z-action-primary-bg-active); }
.z-btn--secondary {
  background: var(--z-action-secondary-bg);
  color: var(--z-action-secondary-fg);
  border: 1px solid var(--z-action-secondary-border);
}
.z-btn--secondary:hover { background: var(--z-action-secondary-bg-hover); }
.z-btn--ghost { background: transparent; color: var(--z-text-secondary); }
.z-btn--danger { background: var(--z-action-danger-bg); color: var(--z-action-danger-fg); }
.z-btn--lg { height: var(--z-control-lg); font-size: var(--z-text-lg); width: 100%; }
.z-btn--sm { height: var(--z-control-sm); font-size: var(--z-text-sm); padding: 0 var(--z-space-3); }
.z-btn:disabled { background: var(--z-action-disabled-bg); color: var(--z-action-disabled-fg); cursor: not-allowed; }

/* ---- 3. Input / Field ---- */
.z-field { display: flex; flex-direction: column; margin-bottom: var(--z-space-4); }
.z-field__label {
  font-size: var(--z-text-sm);
  font-weight: var(--z-weight-medium);
  color: var(--z-text-secondary);
  margin-bottom: var(--z-space-1);
}
.z-field__required { color: var(--z-danger); }
.z-input {
  height: var(--z-control-md);
  border-radius: var(--z-radius-md);
  border: 1px solid var(--z-border-default);
  background: var(--z-bg-surface);
  color: var(--z-text-primary);
  padding: 0 var(--z-space-3);
  font-size: var(--z-text-md);
  font-family: inherit;
}
.z-input:focus { border-color: var(--z-border-focus); box-shadow: var(--z-shadow-focus); outline: none; }
.z-input--error { border-color: var(--z-danger); }
.z-field__error { font-size: var(--z-text-sm); color: var(--z-danger-text); margin-top: var(--z-space-1); }
.z-field__hint { font-size: var(--z-text-xs); color: var(--z-text-muted); margin-top: var(--z-space-1); }
.z-input--num { font-family: var(--z-font-mono); text-align: right; }
.z-input--lg { height: var(--z-control-lg); font-size: var(--z-text-lg); }

/* ---- 6. Table ---- */
.z-table { width: 100%; border-collapse: collapse; background: var(--z-bg-surface); }
.z-table th {
  background: var(--z-bg-raised);
  font-size: var(--z-text-xs);
  font-weight: var(--z-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--z-tracking-caps);
  color: var(--z-text-secondary);
  text-align: left;
  padding: var(--z-space-2) var(--z-space-3);
}
.z-table td {
  height: 48px;
  padding: 0 var(--z-space-3);
  border-bottom: 1px solid var(--z-border-subtle);
  font-size: var(--z-text-sm);
}
.z-table tr:hover td { background: var(--z-primary-50); }
.z-table .z-num { text-align: right; }

/* ---- 7. Badge / Status pill ---- */
.z-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--z-space-2);
  border-radius: var(--z-radius-full);
  font-size: var(--z-text-xs);
  font-weight: var(--z-weight-medium);
  border: 1px solid transparent;
}
.z-pill--success { background: var(--z-success-bg); color: var(--z-success-text); border-color: var(--z-success-border); }
.z-pill--warning { background: var(--z-warning-bg); color: var(--z-warning-text); border-color: var(--z-warning-border); }
.z-pill--danger  { background: var(--z-danger-bg);  color: var(--z-danger-text);  border-color: var(--z-danger-border); }
.z-pill--info    { background: var(--z-info-bg);    color: var(--z-info-text);    border-color: var(--z-info-border); }

/* ---- 8. KPI Card ---- */
.z-kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--z-space-4); margin-bottom: var(--z-space-6); }
.z-kpi-card {
  background: var(--z-bg-surface);
  border-radius: var(--z-radius-lg);
  box-shadow: var(--z-shadow-sm);
  border: 1px solid var(--z-border-subtle);
  padding: var(--z-space-5);
}
.z-kpi-card__label {
  font-size: var(--z-text-xs);
  text-transform: uppercase;
  letter-spacing: var(--z-tracking-caps);
  color: var(--z-text-muted);
  margin-bottom: var(--z-space-2);
}
.z-kpi-card__value { font-size: var(--z-text-4xl); font-weight: var(--z-weight-semibold); color: var(--z-text-primary); }
@media (max-width: 768px) {
  .z-kpi-grid { grid-template-columns: repeat(3, 1fr); gap: var(--z-space-2); }
  .z-kpi-card { padding: var(--z-space-3); }
  .z-kpi-card__value { font-size: var(--z-text-2xl); }
}

/* ---- Cards / section blocks (attention, low stock, recent orders) ---- */
.z-card {
  background: var(--z-bg-surface);
  border: 1px solid var(--z-border-subtle);
  border-radius: var(--z-radius-lg);
  margin-bottom: var(--z-space-6);
  overflow: hidden;
}
.z-card__header {
  padding: var(--z-space-4) var(--z-space-5);
  border-bottom: 1px solid var(--z-border-subtle);
  font-size: var(--z-text-xs);
  font-weight: var(--z-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--z-tracking-caps);
  color: var(--z-text-secondary);
}
.z-attention__row, .z-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--z-space-3) var(--z-space-5);
  border-bottom: 1px solid var(--z-border-subtle);
  text-decoration: none;
  color: var(--z-text-primary);
  cursor: pointer;
}
.z-attention__row:last-child, .z-list__row:last-child { border-bottom: none; }
.z-attention__row:hover, .z-list__row:hover { background: var(--z-primary-50); }
.z-attention__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--z-warning); margin-right: var(--z-space-2); display: inline-block; }
.z-card__footer {
  padding: var(--z-space-3) var(--z-space-5);
  text-align: right;
  font-size: var(--z-text-sm);
  color: var(--z-text-link);
}
.z-empty { padding: var(--z-space-8); text-align: center; color: var(--z-text-muted); }

/* ---- 9. Toast ---- */
.z-toast-region {
  position: fixed;
  bottom: var(--z-space-4);
  right: var(--z-space-4);
  z-index: var(--z-layer-toast);
  display: flex;
  flex-direction: column;
  gap: var(--z-space-2);
}
@media (max-width: 768px) {
  .z-toast-region { top: var(--z-space-4); right: var(--z-space-4); left: var(--z-space-4); bottom: auto; }
}
.z-toast {
  background: var(--z-bg-surface);
  box-shadow: var(--z-shadow-lg);
  border-radius: var(--z-radius-md);
  border-left: 4px solid var(--z-success);
  padding: var(--z-space-3) var(--z-space-4);
  font-size: var(--z-text-sm);
  min-width: 240px;
  animation: z-toast-in var(--z-duration-normal) var(--z-ease-entrance);
}
.z-toast--error { border-left-color: var(--z-danger); }
@keyframes z-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Skeletons / loading ---- */
.z-skeleton { background: var(--z-bg-raised); border-radius: var(--z-radius-sm); animation: z-pulse 1.4s ease-in-out infinite; }
@keyframes z-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---- Login screen ---- */
.z-auth {
  min-height: 100vh;
  background: var(--z-primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--z-space-4);
}
.z-auth__card {
  width: 100%;
  max-width: 400px;
  background: var(--z-bg-surface);
  border-radius: var(--z-radius-xl);
  box-shadow: var(--z-shadow-lg);
  padding: var(--z-space-8);
}
.z-auth__mark { text-align: center; margin-bottom: var(--z-space-4); font-size: 40px; }
.z-auth__title {
  text-align: center;
  font-family: var(--z-font-display);
  font-size: var(--z-text-3xl);
  letter-spacing: var(--z-tracking-wide);
}
.z-auth__tagline {
  text-align: center;
  font-size: var(--z-text-2xs);
  text-transform: uppercase;
  letter-spacing: var(--z-tracking-caps);
  color: var(--z-accent-400);
  margin: var(--z-space-1) 0 var(--z-space-6);
}
.z-auth__error {
  color: var(--z-danger-text);
  font-size: var(--z-text-sm);
  margin-bottom: var(--z-space-3);
  text-align: center;
}
.z-auth__checkbox { display: flex; align-items: center; gap: var(--z-space-2); margin-bottom: var(--z-space-5); font-size: var(--z-text-sm); }
