/* ============================================================
   Page templates showcase shell
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--ui-font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--color-bg-canvas);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---- Language visibility ---- */
.t-ar { display: none; }
html[lang="ar"] .t-en { display: none; }
html[lang="ar"] .t-ar { display: unset; }
.tmpl-ar { display: none; }
html[lang="ar"] .tmpl-en { display: none; }
html[lang="ar"] .tmpl-ar { display: block; }

/* ---- Topbar ---- */
.tmpl-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--color-surface-default) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--color-border-subtle);
}

.tmpl-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.tmpl-breadcrumb a:hover { color: var(--color-text-primary); }

.tmpl-breadcrumb-sep {
  color: var(--color-text-tertiary);
  font-size: 0.75rem;
}

.tmpl-breadcrumb strong {
  color: var(--color-text-primary);
  font-weight: 600;
}

.tmpl-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---- Control toggles ---- */
.ctrl-toggle {
  display: inline-flex;
  align-self: flex-start;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 1px;
}

.ctrl-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-family: var(--ui-font-sans);
  color: var(--color-text-secondary);
  cursor: pointer;
  line-height: 1.4;
  font-weight: 400;
  transition: background var(--motion-fast) var(--easing-standard),
              color var(--motion-fast) var(--easing-standard);
}

.ctrl-toggle button[aria-pressed="true"] {
  background: var(--color-surface-default);
  color: var(--color-text-primary);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

.ctrl-select {
  appearance: none;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-full);
  padding: 4px 28px 4px 12px;
  font-size: 0.75rem;
  font-family: var(--ui-font-sans);
  color: var(--color-text-primary);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* ---- Gallery ---- */
.tmpl-gallery {
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
  padding: 2rem 2.5rem 5rem;
}

/* ---- Page hero ---- */
.tmpl-page-hero {
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border-subtle);
  margin-bottom: 0.5rem;
}

.tmpl-page-eyebrow {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-tertiary);
  margin: 0 0 0.5rem;
}

.tmpl-page-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 0.625rem;
}

.tmpl-page-desc {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  margin: 0;
  max-width: 52ch;
  line-height: 1.65;
}

/* ---- Template card ---- */
.tmpl-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tmpl-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
  margin: 0 0 0.25rem;
}

.tmpl-card-desc {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin: 0;
}

/* ---- Template rendered surface ---- */
.tmpl-surface {
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-canvas);
  max-width: 960px;
}

/* ---- App layout: sidebar + main ---- */
.tmpl-app {
  display: flex;
  height: 500px;
}

.tmpl-side {
  width: 196px;
  flex-shrink: 0;
  border-inline-end: 1px solid var(--color-border-subtle);
  background: var(--color-surface-default);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  gap: 0.125rem;
}

.tmpl-logo {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-action-primary-bg);
  padding: 0.25rem 0.5rem;
  margin-bottom: 1rem;
}

.tmpl-nav-link {
  display: block;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  cursor: default;
}

.tmpl-nav-link--active {
  background: var(--color-action-secondary-bg);
  color: var(--color-action-secondary-text);
  font-weight: 500;
}

.tmpl-main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Inner topbar ---- */
.tmpl-inner-topbar {
  height: 3rem;
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: var(--color-surface-default);
  flex-shrink: 0;
  gap: 0.75rem;
}

.tmpl-search {
  flex: 1;
  max-width: 200px;
}

.tmpl-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.tmpl-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-action-primary-bg);
  color: var(--color-action-primary-text);
  font-size: 0.5625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---- Scrollable content area ---- */
.tmpl-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.tmpl-content-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}

/* ---- Stat grid ---- */
.tmpl-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.tmpl-stat-card {
  background: var(--color-surface-default);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem;
}

.tmpl-stat-label {
  font-size: 0.625rem;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.3rem;
}

.tmpl-stat-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.tmpl-stat-delta {
  font-size: 0.625rem;
  color: var(--color-feedback-success-text);
  margin-top: 0.25rem;
}

.tmpl-subsection-heading {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 0.625rem;
}

/* ---- Form sections (settings template) ---- */
.tmpl-form-section {
  background: var(--color-surface-default);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 0.875rem;
}

.tmpl-form-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.tmpl-avatar-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 0.875rem;
}

.tmpl-avatar-lg {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-action-primary-bg);
  color: var(--color-action-primary-text);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tmpl-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
}

.tmpl-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--color-border-subtle);
}

.tmpl-toggle-row:last-child { border-bottom: 0; }

.tmpl-toggle-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-primary);
}

.tmpl-toggle-desc {
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  margin-top: 0.125rem;
}

/* ---- Sign-in layout ---- */
.tmpl-signin-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 2rem;
  background: var(--color-bg-canvas);
}

.tmpl-signin-card {
  background: var(--color-surface-default);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tmpl-signin-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--color-action-primary-bg);
}

.tmpl-signin-heading {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.tmpl-signin-sub {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin: 0.125rem 0 0;
}

.tmpl-signin-fields {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.tmpl-signin-remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.tmpl-signin-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  padding-top: 0.5rem;
}

.tmpl-signin-footer a {
  color: var(--color-action-primary-bg);
  font-weight: 500;
}

/* ---- Data list layout ---- */
.tmpl-datalist {
  padding: 1.25rem 1.5rem;
}

.tmpl-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tmpl-toolbar-search {
  flex: 1;
  min-width: 160px;
  max-width: 220px;
}

.tmpl-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.875rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--color-border-subtle);
}

.tmpl-page-info {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.tmpl-page-controls {
  display: flex;
  gap: 0.25rem;
}

.tmpl-page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-subtle);
  background: transparent;
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  cursor: default;
  font-family: var(--ui-font-sans);
}

.tmpl-page-btn--active {
  background: var(--color-action-primary-bg);
  border-color: var(--color-action-primary-bg);
  color: var(--color-action-primary-text);
  font-weight: 600;
}

/* ============================================================
   Responsive — mobile breakpoint

   Canonical mobile breakpoint for the page-templates showcase is
   768px. Below it, the fixed desktop app shell is replaced with a
   vertically-stacked layout: sidebars become horizontally-scrolling
   top strips, the 500px-tall `.tmpl-app` releases its fixed height
   and lets the surrounding page handle scrolling, grids collapse,
   and toolbars wrap. A secondary 420px breakpoint drops dense grids
   to a single column.

   Rules in this section are shared by every template card. Template-
   specific tweaks (Settings forms, Sign-in card, Data list toolbar
   and pagination) are layered on top inside per-template blocks.
   ============================================================ */
@media (max-width: 768px) {
  /* ---- Topbar reflow ---- */
  .tmpl-topbar {
    height: auto;
    min-height: 3rem;
    padding: 0.5rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .tmpl-controls { flex-wrap: wrap; gap: 0.375rem; }

  /* ---- Gallery padding + spacing between cards ---- */
  .tmpl-gallery { padding: 1.5rem 1rem 4rem; gap: 2.5rem; }

  /* ---- Surfaces drop their desktop width cap ---- */
  .tmpl-surface { max-width: 100%; }

  /* ---- App shell stacks vertically; fixed height released ---- */
  .tmpl-app { flex-direction: column; height: auto; }

  /* ---- Sidebar becomes a horizontal nav strip ---- */
  .tmpl-side {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-inline-end: 0;
    border-bottom: 1px solid var(--color-border-subtle);
    padding: 0.5rem 0.75rem;
    gap: 0.25rem;
  }
  .tmpl-logo { margin-bottom: 0; flex-shrink: 0; }
  .tmpl-nav-link { flex-shrink: 0; padding: 0.375rem 0.625rem; }

  /* ---- Inner topbar / content tighten ---- */
  .tmpl-inner-topbar { padding: 0 0.75rem; gap: 0.5rem; }
  .tmpl-search { max-width: none; }
  .tmpl-content { padding: 1rem; overflow-y: visible; }

  /* ---- Stat grid: 2 cols on tablets, 1 col on phones ---- */
  .tmpl-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
  .tmpl-stat-grid { grid-template-columns: 1fr; }
}

/* ---- Template-specific: Settings ---- */
@media (max-width: 768px) {
  .tmpl-form-section { padding: 0.875rem 1rem; }
  .tmpl-field-grid { grid-template-columns: 1fr; }
  .tmpl-avatar-row { gap: 0.75rem; }
}

/* ---- Template-specific: Sign-in ---- */
@media (max-width: 768px) {
  .tmpl-signin-wrap { padding: 2rem 1rem; }
  .tmpl-signin-card { padding: 1.5rem; }
}

/* ---- Template-specific: Data list ---- */
@media (max-width: 768px) {
  .tmpl-datalist { padding: 1rem; }
  .tmpl-toolbar-search {
    flex-basis: 100%;
    max-width: none;
    min-width: 0;
  }
  .tmpl-pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 0.625rem;
  }
  .tmpl-page-info { text-align: center; }
  .tmpl-page-controls { justify-content: center; flex-wrap: wrap; }
}
