/* DrugStack web UI — modern teal theme. Hand-written, no build step. */

:root {
  --brand: #0d9488;        /* teal */
  --brand-600: #0f766e;    /* darker teal (hover) */
  --brand-50: #f0fdfa;     /* teal tint */
  --accent: #0891b2;       /* cyan */
  --fg: #0f172a;           /* slate-900 */
  --muted: #64748b;        /* slate-500 */
  --border: #e2e8f0;       /* slate-200 */
  --surface: #ffffff;
  --bg: #f8fafc;           /* slate-50 */
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
  --ok: #047857; --ok-bg: #ecfdf5;
  --err: #b91c1c; --err-bg: #fef2f2;
  --warn: #b45309; --warn-bg: #fffbeb;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 0.75rem; }
.muted { color: var(--muted); }

/* ---- Header ---------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.7rem 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 750;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.topbar .brand:hover { text-decoration: none; }
.topbar .brand svg { color: var(--brand); }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }
.topbar nav a {
  color: var(--fg);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-weight: 550;
}
.topbar nav a:hover { background: var(--brand-50); color: var(--brand-600); text-decoration: none; }
.topbar .who { color: var(--muted); font-size: 0.875rem; margin: 0 0.3rem; }

/* ---- Layout ---------------------------------------------------------------- */
.container { width: 100%; max-width: 1040px; margin: 1.75rem auto; padding: 0 1.5rem; flex: 1; }
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.25rem;
}

/* ---- Buttons / form controls ---------------------------------------------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1.1rem;
  border: none; border-radius: 999px;
  background: var(--brand); color: #fff;
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
button:hover, .btn:hover { background: var(--brand-600); text-decoration: none; }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.35); }

.link-btn {
  background: none; color: var(--brand-600);
  padding: 0.4rem 0.7rem; border-radius: 8px; font-weight: 550;
}
.link-btn:hover { background: var(--brand-50); }
.logout-form { margin: 0; display: inline; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit; color: var(--fg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

/* ---- Cards ----------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

/* ---- Auth (login / register) ---------------------------------------------- */
.auth-wrap { max-width: 420px; margin: 2.5rem auto; }
.auth-wrap .card { box-shadow: var(--shadow-lg); }
.form p { margin: 0 0 1rem; }
.form label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.9rem; }
.form button[type="submit"] { width: 100%; margin-top: 0.25rem; }
.form .helptext { color: var(--muted); font-size: 0.8rem; }
.errors, ul.errorlist {
  color: var(--err); background: var(--err-bg);
  border: 1px solid #fecaca; border-radius: var(--radius);
  padding: 0.5rem 0.75rem; margin: 0 0 1rem; list-style: none;
}
ul.errorlist { padding-left: 0.75rem; font-size: 0.85rem; }
.auth-alt { text-align: center; color: var(--muted); margin-top: 1rem; }

/* ---- Search ---------------------------------------------------------------- */
.search-hero { text-align: center; margin: 1rem 0 2rem; }
.search-form {
  display: flex; flex-wrap: wrap; gap: 0.6rem;
  max-width: 760px; margin: 1.25rem auto 0;
}
.search-form input[type="search"] {
  flex: 1 1 320px; font-size: 1.05rem; padding: 0.8rem 1rem;
}
.search-form select { flex: 0 0 auto; width: auto; min-width: 130px; }
.result-meta { color: var(--muted); margin: 0 0 0.75rem; font-size: 0.9rem; }

/* ---- Tables ---------------------------------------------------------------- */
table.results {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow);
}
table.results th, table.results td {
  text-align: left; padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border); vertical-align: top;
}
table.results thead th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); background: var(--bg); font-weight: 650;
}
table.results tbody tr:last-child td { border-bottom: none; }
table.results tbody tr:hover { background: var(--brand-50); }
table.results td.notes { color: var(--muted); font-size: 0.88rem; }
table.results a { font-weight: 600; }

.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1.25rem; color: var(--muted); }

/* ---- Drug detail ----------------------------------------------------------- */
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.25rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 1.25rem; }
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.78rem; font-weight: 600;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  background: var(--brand-50); color: var(--brand-600); border: 1px solid #ccfbf1;
}
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.badge.neutral { background: var(--bg); color: var(--muted); border-color: var(--border); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.detail-grid .card { padding: 1.25rem; }
.detail-grid h2 { margin-bottom: 0.6rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
ul.items { padding-left: 0; margin: 0; list-style: none; }
ul.items li { padding: 0.35rem 0; border-bottom: 1px dashed var(--border); }
ul.items li:last-child { border-bottom: none; }
.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 0.05rem 0.45rem; border-radius: 6px;
  background: #ecfeff; color: var(--accent); vertical-align: middle;
}
code { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 6px; font-size: 0.85em; }
.back-link { display: inline-block; margin-bottom: 0.75rem; color: var(--muted); }

/* ---- Dashboard ------------------------------------------------------------- */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 1.25rem 0 2rem; }
.summary .stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.summary .stat .num { display: block; font-size: 1.5rem; font-weight: 750; letter-spacing: -0.02em; color: var(--brand-600); }
.summary .stat .lbl { color: var(--muted); font-size: 0.82rem; }

.status { display: inline-block; font-weight: 650; font-size: 0.78rem; padding: 0.15rem 0.55rem; border-radius: 999px; }
.status-completed { color: var(--ok); background: var(--ok-bg); }
.status-failed { color: var(--err); background: var(--err-bg); }
.status-running { color: var(--warn); background: var(--warn-bg); }

/* ---- Responsive ------------------------------------------------------------ */
@media (max-width: 600px) {
  .topbar { padding: 0.7rem 1rem; gap: 0.75rem; }
  .topbar .who { display: none; }
  .container { margin: 1.25rem auto; padding: 0 1rem; }
  dl.facts { grid-template-columns: 1fr; gap: 0.1rem 0; }
  dl.facts dt { margin-top: 0.5rem; }
}
