/* Tokens mirror digipharma-frontend-testing/src/index.css (light mode). */
:root {
  --primary: #38A8E0;
  --primary-dark: #2D8BC0;
  --primary-light: #5CBDE8;
  --primary-glow: rgba(56, 168, 224, 0.15);
  --on-primary: #0a0a0f;
  --bg: #f8fafc;              /* slate-50 */
  --surface: #ffffff;
  --border: #e2e8f0;          /* slate-200 */
  --text: #1e293b;            /* slate-800 */
  --text-muted: #64748b;      /* slate-500 */
  --secondary: #0f172a;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --warn-bg: #fffbeb;
  --warn-text: #78350f;
  --warn-border: #fde68a;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* Class display rules (e.g. .topbar-right { display: flex }) would otherwise beat the UA hidden rule. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 0; padding: 8px 12px;
  background: var(--secondary); color: #fff; z-index: 100; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; top: 8px; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Header (main-site dashboard header: white, blurred, bottom border) ─── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 36px; width: auto; display: block; }
.brand-text {
  font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; color: var(--text-muted);
  border-left: 1px solid var(--border); padding-left: 12px;
}
.brand-text strong { color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 0.9rem; font-weight: 500; color: var(--text); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.banner {
  background: var(--warn-bg); color: var(--warn-text);
  padding: 8px 16px; font-size: 0.9rem; border-bottom: 1px solid var(--warn-border); text-align: center;
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.container:focus { outline: none; }

.status { min-height: 1.2em; margin: 0 0 8px; color: var(--text-muted); font-size: 0.9rem; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 32px;
}
.card-narrow { max-width: 448px; margin: 24px auto; }

.login-logo { display: flex; justify-content: center; margin: 24px 0 32px; }
.login-logo img { height: 100px; width: auto; }
.login-head { text-align: center; margin-bottom: 32px; }
.login-head h1 { margin-bottom: 8px; }
.login-head p { margin: 0; }

h1 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin: 0 0 8px; color: var(--text); letter-spacing: -0.01em; }
h2 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin: 16px 0 8px; }
.h-small { font-size: 1rem; }
.panel-title { margin-bottom: 12px; }
.muted { color: var(--text-muted); }
.hint { color: var(--text-muted); font-weight: normal; font-size: 0.85em; }
.req { color: var(--danger); }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 500; font-size: 0.9rem; color: var(--text); }
.field-inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field-inline select { min-width: 220px; }

input, select, textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid #cbd5e1; border-radius: var(--radius-sm); padding: 10px 16px; min-height: 48px;
  width: 100%; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
}
textarea { min-height: 80px; resize: vertical; }
input[aria-invalid="true"] { border-color: var(--danger); }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; color: var(--text);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-outline { border: 2px solid var(--primary); color: var(--primary-dark); background: transparent; }
.btn-outline:hover { background: var(--primary); color: var(--on-primary); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.error {
  color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm); padding: 12px 16px; font-size: 0.9rem; margin: 0 0 16px;
}

/* ── App shell ─────────────────────────────────────────────────────────────── */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  font: inherit; font-weight: 500; font-size: 0.9rem; cursor: pointer; min-height: 44px; padding: 8px 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted);
}
.tab:hover { background: #fff; color: var(--text); border-color: var(--border); }
.tab[aria-current="page"] { background: var(--primary-glow); border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input { flex: 1; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.quick-actions .btn { flex: 1 1 160px; }

.entry-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.entry-item {
  width: 100%; text-align: left; font: inherit; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.entry-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.entry-main { font-weight: 600; }
.entry-meta { color: var(--text-muted); font-size: 0.875rem; grid-column: 1 / -1; }
.chip {
  display: inline-block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 10px; border-radius: 999px; background: var(--primary-glow); color: var(--primary-dark);
}
.chip-done { background: var(--success-bg); color: var(--success-text); }

.fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin: 0 0 16px; }
.fieldset legend { font-family: var(--font-display); font-weight: 700; padding: 0 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
#entries-title { margin-top: 32px; }
#notes-hint { margin: 0; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.form-actions .btn { flex: 1 1 140px; }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.stat { flex: 1 1 140px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--bg); }
.stat-label { display: block; color: var(--text-muted); font-size: 0.8rem; font-weight: 500; }
.stat-value { display: block; font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; color: var(--text); }

.kv { display: grid; grid-template-columns: 1fr; gap: 6px 16px; margin: 0; }
.kv dt { font-weight: 500; color: var(--text-muted); font-size: 0.875rem; }
.kv dd { margin: 0 0 8px; white-space: pre-wrap; word-break: break-word; }

.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.plain-list li { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.875rem; }
.run-fail { border-color: var(--danger-border); background: var(--danger-bg); }

dialog {
  width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; }
#dlg-back { width: min(520px, calc(100vw - 24px)); }

/* Main site back: sticky countdown under the standby banner */
.back-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px;
  background: var(--success-bg); color: var(--success-text); border-bottom: 1px solid #86efac;
  padding: 8px 16px; font-size: 0.95rem; font-weight: 600; text-align: center;
}
.back-bar[hidden] { display: none; }
.back-bar-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.back-bar .btn { min-height: 44px; }

@media (min-width: 640px) {
  .toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .kv { grid-template-columns: 200px 1fr; }
  .kv dd { margin-bottom: 4px; }
  .quick-actions .btn, .form-actions .btn { flex: 0 0 auto; }
}

@media print {
  .topbar, .banner, .back-bar, .toolbar, .status, .form-actions, .dialog-head .btn-ghost, #view-app { display: none !important; }
  dialog { position: static; width: auto; max-height: none; border: 0; box-shadow: none; }
  dialog[open] { display: block; }
  body { background: #fff; }
}

/* Single-pharmacy users: the picker is fixed but the name must stay fully readable. */
#pharmacy-select:disabled { opacity: 1; color: inherit; cursor: default; }
