/* ============================================================
 * Titaness primitives — buttons, inputs, badges, tables, links
 *
 * Sits on top of tokens.css in the cascade. Provides the visual
 * language for the smallest UI elements used across the app.
 *
 * Patterns extracted from explorer_sandbox; harmonisation decisions
 * (which the source had inconsistencies on) are settled here:
 *
 *   - Teal-filled button text colour: #07101f (single canonical dark)
 *   - Button radius:                  6 px (was a mix of rounded / rounded-lg)
 *   - Pill / badge radius:            9999 px (.rounded-full)
 *   - Form-input shell:               one .field rule (was 3 dupes)
 * ============================================================ */


/* ============================================================
 * Headings + body text — sensible defaults for prose
 * ============================================================ */

h1, h2, h3, h4 {
  color: var(--tan);
  margin: 0 0 0.5em;
  letter-spacing: 0.3px;
}
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; margin-top: 1.5em; }
h3 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 1.25em; }
h4 { font-size: 13px; font-weight: 600; }

p { margin: 0 0 0.75em; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--teal);
  text-decoration: none;
  transition: color 0.18s ease;
}
a:hover { color: var(--tan); }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--bg-panel);
  border-radius: 4px;
}
code { padding: 1px 6px; }
pre {
  padding: 12px 16px;
  /* Wrap long unbreakable tokens (S3 keys, command lines, URLs) instead of
     overflowing the container. overflow-x: auto alone fails inside flex/grid
     children, whose default min-width: auto lets intrinsic content width blow
     the parent out. pre-wrap + break-all guarantees every <pre> stays inside
     its box without each call site re-declaring it inline. */
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
  margin: 0.75em 0;
  border: 1px solid var(--border);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

::selection { background: rgba(0, 184, 151, 0.30); }


/* ============================================================
 * Buttons — base + variants
 *
 * Variants (mark with the data-variant attribute or a class):
 *   .btn               base / outline (default)
 *   .btn-primary       teal-filled
 *   .btn-ghost         no border, hover-bg only
 *   .btn-danger        red accent
 *   .btn-sm            smaller padding + font
 * ============================================================ */

button,
.btn,
input[type="button"],
input[type="submit"] {
  appearance: none;
  background: transparent;
  color: var(--body);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.18s ease,
              border-color 0.18s ease,
              background-color 0.18s ease,
              color 0.18s ease,
              box-shadow 0.18s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

button:hover:not(:disabled),
.btn:hover:not(:disabled),
input[type="button"]:hover:not(:disabled),
input[type="submit"]:hover:not(:disabled) {
  border-color: var(--teal);
  background: var(--bg-panel);
  transform: translateY(-1px);
}

button:active:not(:disabled),
.btn:active:not(:disabled) {
  transform: translateY(0);
}

button:focus-visible,
.btn:focus-visible,
input[type="button"]:focus-visible,
input[type="submit"]:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

button:disabled,
.btn:disabled,
input[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary — teal-filled. Note: submit buttons in forms tend to be
   primary. We default <button type="submit"> to the primary look,
   while <button type="button"> stays neutral. */
.btn-primary,
button[type="submit"],
input[type="submit"] {
  background: var(--teal);
  color: #07101f;
  border-color: var(--teal);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled),
button[type="submit"]:hover:not(:disabled),
input[type="submit"]:hover:not(:disabled) {
  background: #00d4ad;
  border-color: #00d4ad;
  color: #07101f;
}

/* Ghost — no border, hover-bg only. */
.btn-ghost {
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  border-color: transparent;
  background: var(--bg-panel);
}

/* Danger — red accent. */
.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.10);
  border-color: var(--danger);
  color: var(--danger);
}

/* Small variant. */
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* Cancel link styled as a ghost button — for delete-confirm pages. */
.btn-cancel {
  /* alias of .btn (default outline) */
}


/* ============================================================
 * Form inputs
 *
 * Single .field rule covers <input type="text|email|password|number">,
 * <textarea>, <select>. The source had three separate declarations
 * (iBase / inputCls / etc.) — collapsed here.
 * ============================================================ */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea,
select,
.field {
  appearance: none;
  background: var(--bg-panel);
  color: var(--body);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  width: 100%;
  max-width: 480px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus,
.field:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 184, 151, 0.18);
}

textarea {
  min-height: 80px;
  resize: vertical;
}


/* ============================================================
 * File inputs (GRT-589 finding #1)
 *
 * The browser-native file picker control doesn't pick up the .field
 * rule above (input[type="file"] isn't in the selector list) and
 * defaults to whatever the browser provides -- which looks like a
 * raw 1996 form control next to every other styled input. Style the
 * input itself plus the ::file-selector-button pseudo-element so the
 * "Choose file" button reads as a button in our design language.
 * ============================================================ */

input[type="file"] {
  appearance: none;
  background: var(--bg-panel);
  color: var(--body);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  max-width: 480px;
  width: 100%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[type="file"]::file-selector-button {
  appearance: none;
  background: transparent;
  color: var(--body);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  margin-right: 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--teal);
  background-color: rgba(0, 184, 151, 0.08);
}

input[type="file"]:focus,
input[type="file"]:focus-visible {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 184, 151, 0.18);
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

/* Django's form.as_p wraps each field in <p>; tighten the spacing. */
form p {
  margin: 0 0 14px;
}

/* Help text + errors that Django renders. */
.helptext, .help-text {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

ul.errorlist, .errors {
  list-style: none;
  padding: 0;
  margin: 6px 0 12px;
  color: var(--danger);
  font-size: 12px;
}
ul.errorlist li, .errors p {
  margin: 2px 0;
}

/* File input — make Django's default less ugly. */
input[type="file"] {
  background: var(--bg-panel);
  color: var(--body);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 12px;
  width: 100%;
  max-width: 480px;
}
input[type="file"]:focus {
  outline: none;
  border-color: var(--teal);
}

/* Checkboxes + radios — keep native sizing but match colour. */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--teal);
}


/* ============================================================
 * Badges + status pills
 * ============================================================ */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.badge-neutral  { background: var(--bg-panel); color: var(--body);    border-color: var(--border); }
.badge-success  { background: rgba(74, 222, 128, 0.12); color: var(--success); border-color: rgba(74, 222, 128, 0.30); }
.badge-warning  { background: rgba(251, 191, 36, 0.12); color: var(--warning); border-color: rgba(251, 191, 36, 0.30); }
.badge-info     { background: rgba(96, 165, 250, 0.12); color: var(--info);    border-color: rgba(96, 165, 250, 0.30); }
.badge-danger   { background: rgba(248, 113, 113, 0.12); color: var(--danger); border-color: rgba(248, 113, 113, 0.30); }
.badge-teal     { background: rgba(0, 184, 151, 0.12);  color: var(--teal);    border-color: rgba(0, 184, 151, 0.30); }

/* Status dot — used inside a row to show pipeline-run status. */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  vertical-align: middle;
  margin-right: 6px;
}
.status-dot-success { background: var(--success); }
.status-dot-warning { background: var(--warning); }
.status-dot-info    { background: var(--info); }
.status-dot-danger  { background: var(--danger); }
.status-dot-running { background: var(--teal); animation: pulse-dot 1.4s ease-in-out infinite; }


/* ============================================================
 * Tables
 *
 * Used in the run-list, the wells list, etc. Subtle bordering;
 * dark-mode-friendly.
 * ============================================================ */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75em 0;
}

table th,
table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

table thead th {
  background: var(--bg-panel);
  color: var(--tan);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

table tbody tr {
  transition: background-color 0.15s ease;
}
table tbody tr:hover {
  background: var(--bg-panel);
}


/* ============================================================
 * Description lists (<dl>) — used on detail pages
 * ============================================================ */

dl {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  gap: 8px 16px;
  margin: 0.75em 0;
}
dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  align-self: baseline;
}
dd {
  margin: 0;
  font-size: 13px;
  color: var(--body);
}


/* ============================================================
 * Message bus — Django's messages framework
 *
 * Replaces the inline <style> block in base.html with proper
 * dark-mode-friendly message variants.
 * ============================================================ */

ul.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}
.message {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  border: 1px solid;
}
.message-success {
  background: rgba(74, 222, 128, 0.08);
  border-color: rgba(74, 222, 128, 0.35);
  color: var(--success);
}
.message-warning {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--warning);
}
.message-error,
.message-danger {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--danger);
}
.message-info {
  background: rgba(96, 165, 250, 0.08);
  border-color: rgba(96, 165, 250, 0.35);
  color: var(--info);
}
