/* ============================================================================
   CafeSync — Design System: layout.css
   Global reusable layout / structural classes, built on global.css tokens.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   Layout helpers
   ---------------------------------------------------------------------------- */
.ui-row {
  display: flex;
  flex-direction: row;
  height: auto;
}

.ui-column {
  display: flex;
  flex-direction: column;
  height: auto;
}

.ui-row-content-hor-centered {
  display: flex;
  flex-direction: column;
  height: auto;
  margin: 0 auto;
}

.hor-centered-texts {
  display: flex;
  flex-direction: column;
  height: auto;
  text-align: center;
  margin: 0 auto var(--s3);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }

.site-main { display: flex; flex-direction: column; min-height: 100vh; }

.skip-link {
  position: absolute; top: -100px; left: 16px; z-index: 100;
  padding: 10px 16px; background: var(--primary); color: #fff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 0; }

.stack { display: flex; flex-direction: column; gap: var(--s5); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s3); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4);
}
.form-grid .field-full { grid-column: 1 / -1; }
.btn-row { display: flex; gap: var(--s3); align-items: stretch; }
.btn-row .btn { flex: 1; }

.divider {
  display: flex; align-items: center; gap: var(--s4);
  color: var(--ink-faint); font-size: 0.8125rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* ----------------------------------------------------------------------------
   Brand
   ---------------------------------------------------------------------------- */
.brand {
  display: inline-flex; align-items: center; gap: var(--s3);
  color: var(--ink); text-decoration: none; font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 34px; height: 34px; flex: none;
  background: linear-gradient(135deg, var(--primary), #c05b2e);
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-size: 1.125rem; }
.brand-sm .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.brand-sm .brand-mark svg { width: 16px; height: 16px; }
.brand-sm .brand-name { font-size: 1rem; }
.brand-logo {
  width: 28px; height: 28px; flex: none;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  object-fit: cover;
}

/* ----------------------------------------------------------------------------
   Cards & layout shells
   ---------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--s6);
}

.card-head { margin-bottom: var(--s6); }
.card-head .brand { margin-bottom: var(--s5); }
.card-title { font-size: 1.5rem; margin-bottom: var(--s2); }
.card-sub { color: var(--ink-soft); font-size: 0.9375rem; }

.auth-page {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: var(--s7) var(--s5);
}
.auth-card { width: 100%; max-width: 440px; }
.auth-switch {
  margin-top: var(--s6); text-align: center;
  color: var(--ink-soft); font-size: 0.875rem;
}
.auth-switch a { font-weight: 600; }

.onboard-page {
  flex: 1; display: flex; align-items: flex-start; justify-content: center;
  padding: var(--s7) var(--s5);
}
.onboard-card { width: 100%; max-width: 640px; }

.dash-page {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: var(--s7) var(--s5);
  width: 100%;
}
.dash-inner { width: 100%; max-width: 720px; }

/* ----------------------------------------------------------------------------
   Topbar
   ---------------------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4); flex-wrap: wrap;
  padding: var(--s4) var(--s6);
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}

/* ----------------------------------------------------------------------------
   Forms layout
   ---------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--s2); }

/* ----------------------------------------------------------------------------
   Logo picker
   ---------------------------------------------------------------------------- */
.logo-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.logo-preview {
  width: 84px; height: 84px; flex: none;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  object-fit: cover;
}
.logo-actions { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.logo-actions .btn { white-space: nowrap; }

/* ----------------------------------------------------------------------------
   Stepper
   ---------------------------------------------------------------------------- */
.stepper {
  display: flex; list-style: none; gap: 0;
  margin: var(--s6) 0 0; padding: 0;
  counter-reset: step;
}
.step {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--s2);
  position: relative; counter-increment: step;
  color: var(--ink-faint);
}
.step:not(:last-child)::after {
  content: ""; position: absolute; top: 13px; left: calc(50% + 16px);
  width: calc(100% - 32px); height: 2px;
  background: var(--line-strong);
}
.step.done:not(:last-child)::after { background: var(--primary); }
.step-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong);
  display: grid; place-items: center;
  font-size: 0.75rem; font-weight: 700;
  z-index: 1;
}
.step-label { font-size: 0.75rem; font-weight: 600; text-align: center; }
.step.done .step-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.active .step-dot {
  border-color: var(--primary); color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}
.step.active .step-label { color: var(--primary-ink); }
.step.done .step-label { color: var(--ink-soft); }

/* ----------------------------------------------------------------------------
   Meta list
   ---------------------------------------------------------------------------- */
.meta-list {
  list-style: none; display: grid; gap: var(--s3);
  margin: 0 0 var(--s6);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--s4);
}
.meta-list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  font-size: 0.875rem;
}
.meta-list li span:first-child { color: var(--ink-faint); }
.meta-list li span:last-child { font-weight: 600; color: var(--ink); text-align: right; }

/* ----------------------------------------------------------------------------
   Status layout
   ---------------------------------------------------------------------------- */
.status-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s4);
}
.status-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--s5);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--s3);
}
.status-card .status-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.status-card h3 { font-size: 0.9375rem; font-weight: 600; }

/* ----------------------------------------------------------------------------
   Responsive layout
   ---------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .auth-page, .onboard-page, .dash-page { padding: var(--s5) var(--s4); }
  .card { padding: var(--s5); }
  .topbar { padding: var(--s3) var(--s4); }
  .form-grid { grid-template-columns: 1fr; }
  .btn-row { flex-direction: column; }
  .status-grid { grid-template-columns: 1fr; }
  .step-label { font-size: 0.6875rem; }
}

/* ----------------------------------------------------------------------------
   RTL layout adjustments
   ---------------------------------------------------------------------------- */
[dir="rtl"] .skip-link { left: auto; right: 16px; }
[dir="rtl"] .meta-list { text-align: right; }
[dir="rtl"] .meta-list li span:last-child { text-align: left; }
[dir="rtl"] .step:not(:last-child)::after { left: auto; right: calc(50% + 16px); }
