/*
 * carnotif shared theme layer (decision #61 in docs/06-decisions.md).
 *
 * Tailwind's Play CDN (loaded in base.html) is still the primary styling
 * tool for one-off layout/spacing via utility classes in markup. This file
 * adds the small set of reusable *component* classes (buttons, cards,
 * badges, banners, form fields) that templates previously reinvented ad hoc
 * in every file. Keep it plain CSS: Play CDN only scans HTML for utility
 * classes, it does not process `@apply` in linked stylesheets, so no
 * Tailwind-specific syntax below.
 *
 * Radius convention: `.btn` / `.field-input` / `.badge` / `.banner`
 * ("controls") use 8px; `.card` ("containers") uses 12px.
 */

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  border-radius: 0.5rem;
  padding: 0.625rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-primary {
  background: #18181b; /* zinc-900 */
  color: #fff;
}

.btn-primary:hover {
  background: #3f3f46; /* zinc-700 */
}

.btn-secondary {
  background: #fff;
  border-color: #d4d4d8; /* zinc-300 */
  color: #3f3f46; /* zinc-700 */
}

.btn-secondary:hover {
  background: #fafafa; /* zinc-50 */
}

.btn-ghost {
  background: transparent;
  color: #71717a; /* zinc-500 */
}

.btn-ghost:hover {
  color: #3f3f46; /* zinc-700 */
}

/* Variants for use on dark backgrounds (e.g. the marketing CTA band). */
.btn-invert {
  background: #fff;
  color: #18181b;
}

.btn-invert:hover {
  background: #f4f4f5; /* zinc-100 */
}

.btn-outline-invert {
  background: transparent;
  border-color: #52525b; /* zinc-600 */
  color: #fff;
}

.btn-outline-invert:hover {
  background: #27272a; /* zinc-800 */
}

/* Small icon-only buttons (edit/delete controls on list rows). */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem;
  border-radius: 0.375rem;
  color: #a1a1aa; /* zinc-400 */
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  color: #3f3f46; /* zinc-700 */
  background: #f4f4f5; /* zinc-100 */
}

.icon-btn.icon-btn-danger:hover {
  color: #dc2626; /* red-600 */
  background: #fef2f2; /* red-50 */
}

/* ---------------------------------------------------------------------- */
/* Cards                                                                   */
/* ---------------------------------------------------------------------- */

.card {
  border-radius: 0.75rem;
  border: 1px solid #e4e4e7; /* zinc-200 */
  background: #fff;
  padding: 1.25rem;
}

.card-sm {
  padding: 0.75rem;
}

/* ---------------------------------------------------------------------- */
/* Badges (small status pills)                                            */
/* ---------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.1875rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1rem;
  white-space: nowrap;
}

.badge-zinc {
  background: #f4f4f5; /* zinc-100 */
  color: #52525b; /* zinc-600 */
}

.badge-green {
  background: #f0fdf4; /* green-50 */
  color: #15803d; /* green-700 */
}

.badge-amber {
  background: #fffbeb; /* amber-50 */
  color: #b45309; /* amber-700 */
}

.badge-red {
  background: #fef2f2; /* red-50 */
  color: #b91c1c; /* red-700 */
}

.badge-blue {
  background: #eff6ff; /* blue-50 */
  color: #1d4ed8; /* blue-700 */
}

.badge-purple {
  background: #faf5ff; /* purple-50 */
  color: #7e22ce; /* purple-700 */
}

/* Interactive badge (e.g. the alert active/paused toggle). */
button.badge {
  border: none;
  cursor: pointer;
}

/* ---------------------------------------------------------------------- */
/* Banners (flash messages, inline notices)                                */
/* ---------------------------------------------------------------------- */

.banner {
  border-radius: 0.5rem;
  border: 1px solid;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.375rem;
}

.banner-info {
  border-color: #bfdbfe; /* blue-200 */
  background: #eff6ff; /* blue-50 */
  color: #1d4ed8; /* blue-700 */
}

.banner-success {
  border-color: #bbf7d0; /* green-200 */
  background: #f0fdf4; /* green-50 */
  color: #15803d; /* green-700 */
}

.banner-warning {
  border-color: #fde68a; /* amber-200 */
  background: #fffbeb; /* amber-50 */
  color: #92400e; /* amber-800 */
}

.banner-error {
  border-color: #fecaca; /* red-200 */
  background: #fef2f2; /* red-50 */
  color: #b91c1c; /* red-700 */
}

/* ---------------------------------------------------------------------- */
/* Form fields                                                             */
/* ---------------------------------------------------------------------- */

.field-input {
  display: block;
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid #d4d4d8; /* zinc-300 */
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #18181b; /* zinc-900 */
  background: #fff;
}

.field-input::placeholder {
  color: #a1a1aa; /* zinc-400 */
}

.field-input:focus {
  outline: 2px solid transparent;
  border-color: #18181b; /* zinc-900 */
  box-shadow: 0 0 0 1px #18181b;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #52525b; /* zinc-600 */
  margin-bottom: 0.25rem;
}

.field-error {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #dc2626; /* red-600 */
}

/*
 * Third-party form markup we don't own (django-allauth's `form.as_p`
 * output) renders bare <input>/<select>/<textarea>/<label> with no
 * classes at all. Style it generically wherever it appears in the main
 * content area, scoped with :not([class]) so it never touches inputs we
 * already styled explicitly above.
 */
main form label:not([class]) {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #3f3f46; /* zinc-700 */
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

main form p:first-of-type label:not([class]) {
  margin-top: 0;
}

main input:not([class]):not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
main select:not([class]),
main textarea:not([class]) {
  display: block;
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid #d4d4d8; /* zinc-300 */
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #18181b; /* zinc-900 */
  background: #fff;
}

main input:not([class]):focus,
main select:not([class]):focus,
main textarea:not([class]):focus {
  outline: 2px solid transparent;
  border-color: #18181b; /* zinc-900 */
  box-shadow: 0 0 0 1px #18181b;
}

main input[type="checkbox"]:not([class]),
main input[type="radio"]:not([class]) {
  width: auto;
  margin-right: 0.375rem;
}

main .helptext {
  display: block;
  font-size: 0.75rem;
  color: #71717a; /* zinc-500 */
  margin-top: 0.25rem;
}

main .errorlist {
  list-style: none;
  margin: 0.375rem 0 0;
  padding: 0;
  color: #dc2626; /* red-600 */
  font-size: 0.8125rem;
}

main .errorlist.nonfield {
  background: #fef2f2; /* red-50 */
  border: 1px solid #fecaca; /* red-200 */
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}
