/* Zedenz Healthcare: hand-written stylesheet, no framework. */

:root {
  --brand: #0f766e;        /* white text on this: 5.5:1 contrast */
  --brand-dark: #115e59;
  --brand-light: #ccfbf1;
  --danger: #b91c1c;       /* 6.5:1 on white */
  --danger-light: #fee2e2;
  --success-light: #dcfce7;
  --text: #1f2937;
  --muted: #4b5563;        /* 7.6:1 on white */
  --border: #d1d5db;
  --surface: #ffffff;
  --page: #f3f4f6;
  --focus: #f59e0b;
  --radius: 8px;
  --gap: 1rem;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--brand-dark);
}

a:hover {
  color: var(--brand);
}

/* Visible keyboard focus everywhere. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

h1,
h2 {
  line-height: 1.2;
  margin: 0 0 var(--gap);
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.3rem;
  margin-top: 2rem;
}

/* ---------- Header, menu, footer ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.75rem 1rem;
  background: var(--brand);
  color: #ffffff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: #ffffff;
  text-decoration: none;
  font-size: 1.35rem;
  font-weight: 700;
}

.brand:hover {
  color: var(--brand-light);
}

.brand img {
  border-radius: 10px;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.6);
}

.logout {
  margin: 0;
}

.logout button {
  background: transparent;
  color: #ffffff;
  border-color: #ffffff;
}

.logout button:hover {
  background: #ffffff;
  color: var(--brand-dark);
}

.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem;
  list-style: none;
}

.site-nav a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.site-nav a:hover {
  color: var(--brand-dark);
  border-bottom-color: var(--brand-light);
}

.site-nav a[aria-current="page"] {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
}

.content {
  flex: 1;
  width: 100%;
  max-width: 64rem;
  margin: 1.5rem auto;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}

.site-footer {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

/* ---------- Home ---------- */

.hero {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 1.5rem;
  border-radius: var(--radius);
}

/* ---------- Buttons and actions ---------- */

button,
.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #ffffff;
}

button.danger,
.button.danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

button.danger:hover,
.button.danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: var(--gap) 0;
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:nth-child(even) {
  background: #f9fafb;
}

/* ---------- Detail lists ---------- */

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.5rem;
  margin: 0 0 var(--gap);
}

.details dt {
  font-weight: 700;
  color: var(--muted);
}

.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.pdf-link {
  display: inline-block;
  border-radius: 4px;
}

.pdf-link:hover img {
  transform: scale(1.08);
}

/* ---------- Forms ---------- */

.record-form {
  max-width: 36rem;
}

.field,
.record-form p {
  margin: 0 0 1.1rem;
}

label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #9ca3af;  /* 3:1 against white for control borders */
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input[type="checkbox"] {
  width: auto;
  margin-right: 0.4rem;
}

/* Keep the checkbox and its label on one line. */
.field:has(input[type="checkbox"]) {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: center;
}

.field:has(input[type="checkbox"]) label {
  margin: 0;
}

input[type="file"] {
  padding: 0.4rem;
  background: var(--page);
}

textarea {
  resize: vertical;
}

.help {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--danger);
}

.errorlist {
  margin: 0.3rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Messages and alerts ---------- */

.messages {
  margin: 0 0 var(--gap);
  padding: 0;
  list-style: none;
}

.message,
.errors {
  margin: 0 0 var(--gap);
  padding: 0.75rem 1rem;
  border-left: 5px solid var(--brand);
  border-radius: 4px;
  background: var(--brand-light);
}

.message.success {
  border-left-color: #15803d;
  background: var(--success-light);
}

.message.error,
.errors {
  border-left-color: var(--danger);
  background: var(--danger-light);
}

.errors .errorlist {
  margin: 0;
}

/* ---------- Small screens ---------- */

@media (max-width: 40rem) {
  .site-header {
    padding: 0.6rem 0.75rem;
  }

  .brand {
    font-size: 1.1rem;
  }

  .brand img {
    width: 36px;
    height: 36px;
  }

  .site-nav ul {
    padding: 0 0.5rem;
  }

  .site-nav a {
    padding: 0.6rem 0.6rem;
  }

  .content {
    margin: 0;
    padding: 1rem;
    border-radius: 0;
    box-shadow: none;
  }

  .details {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .details dd {
    margin-bottom: 0.6rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .pdf-link img {
    transition: transform 0.15s ease;
  }
}
