/*
 * webadmin brand + component styles.
 *
 * Brand tokens copied from @yoggo-app/ui's tokens.css (a runtime dep on the
 * React package would pull in a build step we don't want in this Flask
 * app). Any drift in the marketplace UI's tokens.css is picked up manually
 * — v1 accepts the copy-paste, the alternative (a JS build step) violates
 * the "no build step" simplicity target.
 *
 * Slice C ships just enough to make the placeholder templates readable.
 * Slice E lands the real filter-card grid + row rendering.
 */

:root {
  --brand-bg: #fafaf7;
  --brand-fg: #1c1c1c;
  --brand-muted: #6f6f6f;
  --brand-accent: #4f46e5;
  --brand-accent-fg: #ffffff;
  --brand-warn: #b45309;
  --brand-ok: #047857;
  --brand-radius: 12px;
  --brand-gap: 1rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--brand-bg);
  color: var(--brand-fg);
  line-height: 1.5;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--brand-gap) 1.5rem;
  border-bottom: 1px solid #e5e5e0;
  background: #ffffff;
}

.brand {
  color: var(--brand-fg);
  font-weight: 600;
  text-decoration: none;
}

.muted { color: var(--brand-muted); }

main { padding: 1.5rem; }

.flashes {
  list-style: none;
  padding: 0.5rem 1.5rem 0;
  margin: 0;
}
.flash {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.25rem;
}
.flash-info    { background: #eef2ff; color: var(--brand-accent); }
.flash-success { background: #ecfdf5; color: var(--brand-ok); }
.flash-warning { background: #fffbeb; color: var(--brand-warn); }
.flash-error   { background: #fef2f2; color: #b91c1c; }

.auth-card {
  max-width: 360px;
  margin: 2rem auto;
  padding: 1.5rem;
  border: 1px solid #e5e5e0;
  border-radius: var(--brand-radius);
  background: #ffffff;
}
.auth-card form { display: flex; flex-direction: column; gap: 0.9rem; }
.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--brand-muted);
  font-weight: 600;
}
.auth-card input {
  padding: 0.55rem 0.75rem;
  border: 1px solid #d4d4cf;
  border-radius: 6px;
  background: #ffffff;
  color: var(--brand-fg);
  font: inherit;
}
.auth-card button {
  margin-top: 0.35rem;
  padding: 0.6rem 1rem;
  background: var(--brand-accent);
  color: var(--brand-accent-fg);
  border: none;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.auth-card button:hover { filter: brightness(1.05); }

.grid-shell { max-width: 1200px; margin: 0 auto; }

/* ---- Nav ---------------------------------------------------------- */
.nav-form { display: inline; }
.link-btn {
  background: none;
  border: none;
  color: var(--brand-accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ---- Filter card (FR-007.c: YourBreak-style horizontal card) ------ */
.filter-card {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr 1fr auto;
  gap: var(--brand-gap);
  align-items: end;
  padding: 1.25rem;
  margin: 0 0 1.5rem;
  background: #ffffff;
  border: 1px solid #e5e5e0;
  border-radius: var(--brand-radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.filter-field { display: flex; flex-direction: column; gap: 0.35rem; }
.filter-label {
  font-size: 0.85rem;
  color: var(--brand-muted);
  font-weight: 600;
}
.filter-input {
  padding: 0.55rem 0.75rem;
  border: 1px solid #d4d4cf;
  border-radius: 999px;
  background: #ffffff;
  color: var(--brand-fg);
  font: inherit;
}
.filter-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: center;
}
.filter-range-sep { color: var(--brand-muted); }
.filter-submit {
  padding: 0.55rem 1.5rem;
  background: var(--brand-accent);
  color: var(--brand-accent-fg);
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.filter-submit:hover { filter: brightness(1.05); }

@media (max-width: 768px) {
  .filter-card {
    grid-template-columns: 1fr;
  }
}

/* ---- Grid list ---------------------------------------------------- */
.grid-note, .grid-empty {
  margin: 0 0 1rem;
}
.grid-list {
  list-style: none;
  padding: 0 0.5rem 0 0;   /* right padding so scrollbar doesn't overlap card border */
  margin: 0;
  display: grid;
  gap: 0.75rem;
  /* Scroll region — hold all institutes without pushing the page.
     Filter card, bulk bar, and the "showing first N" note stay
     pinned above the scroll area. 65vh gives ~6-7 cards on a
     laptop viewport; the container grows to that height only when
     there's enough content. */
  max-height: 65vh;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
/* Chrome/Safari scrollbar styling — thin, brand-tinted. */
.grid-list::-webkit-scrollbar { width: 8px; }
.grid-list::-webkit-scrollbar-track { background: #f4f4ef; border-radius: 4px; }
.grid-list::-webkit-scrollbar-thumb {
  background: #d4d4cf;
  border-radius: 4px;
}
.grid-list::-webkit-scrollbar-thumb:hover { background: var(--brand-muted); }
.row-card {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 1rem;
  padding: 1rem;
  background: #ffffff;
  border: 1px solid #e5e5e0;
  border-radius: var(--brand-radius);
  align-items: start;
}
.row-card-approved { border-left: 4px solid var(--brand-ok); }
.row-card-rejected { border-left: 4px solid #b91c1c; }
.row-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 8px;
  background: #f4f4ef;
}
.row-name { margin: 0 0 0.15rem; font-size: 1.05rem; }
.row-address, .row-contact { margin: 0.15rem 0; }
.row-chips { margin-top: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: #eef2ff;
  color: var(--brand-accent);
}
.chip-payment { background: #ecfdf5; color: var(--brand-ok); }
.row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  min-width: 6rem;
}
.status-badge {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-pending  { background: #fef3c7; color: #78350f; }
.status-approved { background: #ecfdf5; color: var(--brand-ok); }
.status-rejected { background: #fef2f2; color: #b91c1c; }

/* ---- Row select + bulk-action bar (Slice F) ----------------------- */
.row-card {
  grid-template-columns: auto 80px 1fr auto;
}
.row-select {
  align-self: center;
}
.row-actions {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.row-action {
  margin: 0;
}
.row-action-btn {
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid #d4d4cf;
  background: #ffffff;
  color: var(--brand-fg);
  cursor: pointer;
  font: inherit;
}
.row-action-btn:hover:not(:disabled) { border-color: var(--brand-accent); }
.row-action-btn:disabled { opacity: 0.4; cursor: default; }
.row-approve { color: var(--brand-ok); }
.row-reject  { color: #b91c1c; }

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  background: #ffffff;
  border: 1px solid #e5e5e0;
  border-radius: var(--brand-radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.bulk-bar[hidden] { display: none; }
.bulk-select-all { display: inline-flex; align-items: center; gap: 0.4rem; }
.bulk-count { color: var(--brand-muted); font-size: 0.9rem; }
.bulk-btn {
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.bulk-btn:disabled { opacity: 0.4; cursor: default; }
.bulk-approve { background: var(--brand-ok);  color: #ffffff; }
.bulk-reject  { background: #b91c1c;          color: #ffffff; }

/* ---- Running-sweep banner (2026-07-22) ---------------------------- */
.running-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-left: 4px solid var(--brand-accent);
  border-radius: var(--brand-radius);
  color: var(--brand-fg);
}
.running-banner strong { color: var(--brand-accent); }
.running-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--brand-muted);
  font-size: 0.9rem;
}
.running-item {
  padding: 0.15rem 0.55rem;
  background: #ffffff;
  border-radius: 999px;
  border: 1px solid #c7d2fe;
}
.running-pulse {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--brand-accent);
  animation: running-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes running-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(1.35); }
}
.running-count {
  margin-left: 0.5rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--brand-accent);
  color: var(--brand-accent-fg);
  font-size: 0.8rem;
  font-weight: 600;
}

/* ---- Admin panels (three-panel layout 2026-07-22) ----------------- */
.admin-panel {
  padding: 1rem 1.25rem;
  margin: 0 0 1rem;
  background: #ffffff;
  border: 1px solid #e5e5e0;
  border-radius: var(--brand-radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.admin-panel > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--brand-fg);
  list-style: none;
}
.admin-panel > summary::-webkit-details-marker { display: none; }
.admin-panel[open] > summary { margin-bottom: 0.75rem; }
.admin-panel-pipeline { border-left: 4px solid var(--brand-accent); }
.admin-panel-review   { border-left: 4px solid var(--brand-ok); }
.add-studio           { border-left: 4px solid var(--brand-warn); }

/* Run-pipeline form */
.pipeline-form {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  gap: 1rem;
  align-items: end;
}
.pipeline-field { display: flex; flex-direction: column; gap: 0.3rem; }
.pipeline-steps {
  border: 1px solid #e5e5e0;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.pipeline-steps legend { padding: 0 0.3rem; }
.pipeline-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.pipeline-submit { align-self: end; }

.pipeline-status { margin-top: 1rem; }
.pipeline-status h4 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.85rem;
  color: var(--brand-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.mini-table th, .mini-table td {
  text-align: left;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid #eee;
}
.mini-table th { color: var(--brand-muted); font-weight: 600; }
.run-failed td:nth-child(3) { color: #b91c1c; font-weight: 600; }
.run-success td:nth-child(3) { color: var(--brand-ok); }

@media (max-width: 768px) {
  .pipeline-form { grid-template-columns: 1fr; }
}
.add-studio-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  align-items: end;
  margin-top: 0.75rem;
}
.add-studio-field { display: flex; flex-direction: column; gap: 0.3rem; }
.add-studio-field-wide { grid-column: 1 / -1; }
.add-studio-submit { grid-column: 1 / -1; justify-self: end; }
.multi-select {
  border-radius: 6px !important;   /* rectangular reads better for lists */
  padding: 0.25rem !important;
  font: inherit;
}
@media (max-width: 768px) {
  .add-studio-form { grid-template-columns: 1fr; }
}
