/* Admin overrides on top of Pico. Keep this small. */

:root {
  --pico-form-element-spacing-vertical: 0.5rem;
}

/* Compact admin tables */
main.container table { font-size: 0.95rem; }

/* Watch image management grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0;
}
.image-card {
  list-style: none; /* override Pico's base li{list-style:square} */
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  padding: 0.75rem;
  background: var(--pico-card-background-color);
}
.image-card img { width: 100%; height: auto; border-radius: var(--pico-border-radius); }
.image-card.dragging { opacity: 0.5; }
.image-dims { margin: 0.25rem 0; color: var(--pico-muted-color); }
.drag-handle { cursor: grab; display: inline-block; font-size: 1.25rem; line-height: 1; color: var(--pico-muted-color); }

/* Image lightbox: click a thumbnail to view the original in a modal */
.image-zoom { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
dialog.image-lightbox > article { width: auto; max-width: 92vw; position: relative; padding: 0; }
dialog.image-lightbox > article > header { margin: 0; padding: 0; border: 0; background: none; }
dialog.image-lightbox .close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  margin: 0;
  z-index: 1;
  padding: 0.5rem;
  border-radius: 50%;
  box-shadow: 0 0 0.5rem rgba(0, 0, 0, 0.25);
}
dialog.image-lightbox img { display: block; max-width: 100%; max-height: 80vh; width: auto; height: auto; border-radius: var(--pico-border-radius); transition: opacity 0.15s ease-in-out; }
dialog.image-lightbox img.is-loading { opacity: 0; }

/* Pagination (pagy) */
nav.pagy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center; /* override Pico's base nav{justify-content:space-between} */
  gap: 0.375rem;
  margin-top: 1.5rem;
}
nav.pagy a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.6rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  color: var(--pico-color);
  text-decoration: none;
  line-height: 1;
}
nav.pagy a:not([aria-current="page"]):not([aria-disabled="true"]):hover {
  background: var(--pico-muted-border-color);
}
nav.pagy a[aria-current="page"] {
  background: var(--pico-primary-background);
  border-color: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}
nav.pagy a[aria-disabled="true"]:not([aria-current="page"]) {
  color: var(--pico-muted-color);
  opacity: 0.55;
  pointer-events: none;
}

/* Sign out is a button_to <button type="submit">. Pico's
   [type="submit"]{margin-bottom: spacing} rule (an attribute selector) outranks
   its own nav-button reset, leaving a bottom margin that shifts the button off
   the nav's vertical center. Zero it with a matching-attribute selector. */
header nav li [type="submit"] { margin-bottom: 0; }

/* Index page header: heading left, primary action right */
.page-header { display: flex; justify-content: space-between; align-items: start; gap: 1rem; flex-wrap: wrap; }
.page-header hgroup { margin-bottom: 0; }
.page-header > a[role="button"] { flex: none; white-space: nowrap; }

/* Show-page action rows: keep links and button_to forms inline at natural width */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.actions form { margin: 0; }
/* Pico stretches buttons and submit/button inputs to full width; reset them all. */
.actions a[role="button"],
.actions button,
.actions input[type="submit"],
.actions input[type="button"] { width: auto; margin: 0; }

/* Flash toasts — centered at top, auto-dismissed by the flash controller */
.toast-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: max-content;
  max-width: min(90vw, 30rem);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--pico-border-radius, 0.5rem);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  font-size: 0.9rem;
  animation: toast-in 0.25s ease;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.toast-leave { opacity: 0; transform: translateY(-0.5rem); }
.toast-notice { background: #d1f0d9; color: #0f5132; border-color: #b6e3c4; }
.toast-alert { background: #f8d7da; color: #842029; border-color: #f1aeb5; }
.toast-msg { flex: 1; }
.toast-close {
  width: auto;
  margin: 0;
  padding: 0 0.25rem;
  background: none;
  border: 0;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
}
.toast-close:hover { opacity: 1; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-0.5rem); }
  to { opacity: 1; transform: none; }
}

/* Status badges — consistent colors across brand, watch, and caliber pages */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: var(--pico-border-radius, 0.25rem);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-published { background: #d1f0d9; color: #0f5132; }
.badge-draft { background: #fff3cd; color: #856404; }
.badge-candidate { background: #dbeafe; color: #1e40af; }
.badge-rejected { background: #f8d7da; color: #842029; }
.badge-discontinued { background: #e2e3e5; color: #41464b; }
/* Compact button — trims Pico's default height for inline table actions */
.btn-sm {
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* Pipeline run statuses */
.badge-completed { background: #d1f0d9; color: #0f5132; }
.badge-running { background: #dbeafe; color: #1e40af; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-failed { background: #f8d7da; color: #842029; }
.badge-timeout { background: #f8d7da; color: #842029; }

/* Publish-readiness dot — green = ready, yellow = incomplete */
.readiness-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.readiness-dot-ready { background: #198754; }
.readiness-dot-incomplete { background: #e0a800; }

/* Bulk-select toolbar — compact controls on a single row */
.bulk-toolbar { margin: 0 0 0.5rem 0; gap: 0.5rem; }
.bulk-toolbar button {
  width: auto;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}
.bulk-toolbar .bulk-count { color: var(--pico-muted-color, #6c757d); font-size: 0.85rem; margin-left: 0.25rem; }
form[data-controller="bulk-select"] table td:first-child,
form[data-controller="bulk-select"] table th:first-child { width: 1px; white-space: nowrap; }

/* Logo previews sit on a neutral grey panel so white/light logos stay visible. */
.admin-logo-preview {
  display: inline-block;
  padding: 12px 16px;
  background: #8a8a8a;
  border-radius: 8px;
  line-height: 0;
}
.admin-logo-preview img { display: block; }

/* FAQ templates admin index + form */
.faq-tpl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.faq-tpl-head h1 { margin: 0; }
.faq-tpl-section { margin-top: 2.5rem; }
tr.faq-tpl-inactive { opacity: 0.55; }
.faq-tpl-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.faq-tpl-actions a[role="button"],
.faq-tpl-actions button { width: auto; white-space: nowrap; margin: 0; }
.faq-tpl-actions form { margin: 0; }
.faq-tpl-field-end { align-self: end; }
.faq-tpl-error { color: var(--pico-del-color); }
