/* Homeo Health Care — v1.2 styles
 * Palette: aqua / green / blue / white. No dark colors.
 */

:root {
  --bg: #f0fafa;
  --bg-card: #ffffff;
  --bg-soft: #e8f5f5;
  --border: #cfe6e4;
  --border-strong: #a9d4d0;

  --text: #1a3a52;
  --text-muted: #4a6b80;
  --text-soft: #7a95a8;

  --green: #2e7d6b;
  --green-soft: #4caf97;
  --aqua: #4dd0c9;
  --aqua-soft: #a3e4e0;
  --blue: #4a90e2;
  --blue-soft: #bcd7f5;

  --warn: #d88a3a;
  --warn-soft: #fbe8cf;
  --danger: #c45c5c;
  --danger-soft: #f5d7d7;

  --ff: #b77fd1;       /* family & friends accent (soft purple fits palette) */
  --ff-soft: #ecd9f5;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(30, 80, 90, 0.06);
  --shadow-md: 0 4px 14px rgba(30, 80, 90, 0.10);
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding: 18px;
}

/* ─── Headings ─── */

h2, h3, h4 {
  color: var(--text);
  font-weight: 600;
  margin: 0 0 10px;
}

h2 { font-size: 22px; letter-spacing: 0.2px; }
h3 { font-size: 18px; }
h4 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-top: 18px; }

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

p { margin: 8px 0; }
em { font-style: normal; color: var(--text-muted); }
strong { font-weight: 600; }
small { color: var(--text-soft); }

/* ─── App header ─── */

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.app-header img.logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
  background: #fff;
}

.app-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.app-header .version {
  font-size: 11px;
  color: var(--text-soft);
  font-weight: normal;
  margin-left: 4px;
}

/* ─── Forms & inputs ─── */

input[type="text"],
input[type="password"],
select {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: var(--tap);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--green-soft);
  box-shadow: 0 0 0 3px rgba(76, 175, 151, 0.18);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
  color: var(--text-soft);
}

/* ─── Buttons ─── */

button {
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  min-height: 36px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}

button:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: var(--green-soft);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

button.primary:hover:not(:disabled) {
  background: var(--green-soft);
  border-color: var(--green-soft);
}

button.big {
  min-height: var(--tap);
  padding: 12px 20px;
  font-size: 16px;
}

/* ─── Login + clinic picker ─── */

#login-section,
#clinic-picker {
  max-width: 380px;
  margin: 40px auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

#login-section .login-logo,
#clinic-picker .login-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

#login-section input,
#clinic-picker input {
  display: block;
  width: 100%;
  margin: 8px 0;
}

#login-section #login-btn,
#clinic-picker button {
  display: inline-block;
  margin: 6px 4px 0;
  min-width: 100px;
}

#login-section #login-btn {
  width: 100%;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  margin-top: 14px;
}

#login-msg, #clinic-msg {
  color: var(--danger);
  min-height: 1.2em;
}

/* ─── Logged-in top bar ─── */

#logged-in-section > p#user-info {
  display: inline-block;
  margin-right: 10px;
  color: var(--text-muted);
}

#logout-btn,
#btn-switch-clinic {
  font-size: 13px;
  padding: 6px 10px;
  min-height: 32px;
}

#clinic-name {
  display: inline-block;
  background: var(--aqua-soft);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}

#peer-warning:not(:empty) {
  background: var(--warn-soft);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warn);
  margin: 8px 0;
}

/* ─── Compounder view — sidebar layout ─── */

#view-compounder {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  align-items: start;
}

#compounder-main,
#compounder-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

#compounder-sidebar hr {
  margin: 14px -18px;
}

#search-input,
#doctor-search-input {
  width: 100%;
  display: block;
}

#search-results, #doctor-search-results {
  margin-top: 8px;
}

#search-results > div,
#doctor-search-results > div {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

#search-results > div:last-child,
#doctor-search-results > div:last-child {
  border-bottom: none;
}

#register-section input,
#register-section select {
  display: block;
  width: 100%;
  margin: 6px 0;
}

#register-section #reg-submit {
  width: 100%;
  margin-top: 8px;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

#reg-msg { color: var(--text-muted); font-size: 13px; }

/* Queue rows (compounder) */

#queue-list h4 {
  margin-top: 14px;
  padding: 6px 10px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--aqua);
}

#queue-list > div {
  padding: 10px 12px;
  margin: 6px 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--aqua);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

#queue-list > div button {
  padding: 6px 10px;
  min-height: 32px;
  font-size: 13px;
}

/* Status-colored left borders — applied via class in ui.js */
.qrow-at_reception { border-left-color: var(--aqua) !important; }
.qrow-queued       { border-left-color: var(--blue) !important; }
.qrow-with_doctor  { border-left-color: var(--green) !important; }
.qrow-rx_ready     { border-left-color: var(--warn) !important; background: var(--warn-soft) !important; }
.qrow-dispensed    { border-left-color: var(--green-soft) !important; opacity: 0.7; }
.qrow-walked_away  { border-left-color: var(--danger) !important; opacity: 0.6; }

.ff-tag {
  background: var(--ff-soft);
  color: var(--ff);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-left: 6px;
}

/* ─── Doctor view — tablet-first ─── */

#view-doctor {
  max-width: 900px;
  margin: 0 auto;
}

#doctor-search-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.current-patient-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 6px solid var(--green);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 14px;
}

.current-patient-card.empty {
  border-left-color: var(--border-strong);
  text-align: center;
  color: var(--text-muted);
}

.current-patient-card h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.current-patient-id {
  font-size: 14px;
  color: var(--text-muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.current-patient-name {
  font-size: 28px;
  font-weight: 600;
  margin: 4px 0 16px;
  color: var(--text);
}

.current-patient-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.current-patient-actions button {
  min-height: var(--tap);
}

#doctor-queued {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

#doctor-queued:empty { display: none; }

#doctor-queued h4 {
  margin-top: 0;
}

.queued-row {
  padding: 12px;
  margin: 6px 0;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
}

.queued-row button {
  min-height: 38px;
  padding: 8px 14px;
}

#doctor-rx-ready:not(:empty) {
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

#doctor-rx-ready p { margin: 0; color: var(--text); }

#doctor-reception-details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  box-shadow: var(--shadow-sm);
}

#doctor-reception-summary {
  cursor: pointer;
  padding: 8px 0;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
  user-select: none;
}

#doctor-reception-summary::-webkit-details-marker { display: none; }

#doctor-reception-summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.15s;
  color: var(--aqua);
}

#doctor-reception-details[open] #doctor-reception-summary::before {
  transform: rotate(90deg);
}

#doctor-reception-list > div {
  padding: 10px 12px;
  margin: 6px 0;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--aqua);
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

#doctor-reception-list > div button {
  padding: 6px 10px;
  min-height: 32px;
  font-size: 13px;
}

/* ─── Edit form (shared) ─── */

#edit-section {
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-md);
  margin: 14px 0;
}

#edit-section input,
#edit-section select {
  display: block;
  width: 100%;
  margin: 6px 0;
}

#edit-section button {
  margin-top: 8px;
  margin-right: 6px;
}

#edit-msg { color: var(--text-muted); font-size: 13px; }

/* ─── Patient detail (shared) ─── */

#detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin: 14px 0;
}

#detail-patient-info {
  color: var(--text-muted);
  font-size: 14px;
}

#detail-visits > div,
#detail-notes > div,
#detail-attachments > div {
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  margin: 6px 0;
  font-size: 14px;
}

/* Rx thumbnail — click-to-enlarge */
.rx-thumb {
  max-width: 180px;
  max-height: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 6px;
  cursor: zoom-in;
  transition: transform 0.1s, box-shadow 0.1s;
  display: block;
}

.rx-thumb:hover {
  box-shadow: var(--shadow-md);
  transform: scale(1.02);
}

/* Rx lightbox overlay */
#rx-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 58, 82, 0.85);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

#rx-lightbox.open { display: flex; }

#rx-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  background: #fff;
}

/* ─── Prescription canvas overlay ─── */

#rx-overlay {
  background: var(--bg) !important;
}

#rx-toolbar {
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px !important;
  gap: 8px !important;
}

#rx-toolbar button {
  min-height: 38px;
  padding: 8px 14px;
}

#rx-toolbar #rx-save {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

#rx-patient-label {
  font-size: 15px;
  color: var(--text);
}

#rx-save-msg {
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Toast ─── */

#toast-container { gap: 8px !important; }

.toast {
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--green);
  max-width: 320px;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateY(-4px);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.doctor { border-left-color: var(--blue); }
.toast.compounder { border-left-color: var(--green); }

/* ─── Responsive — compounder collapses below 1024px ─── */

@media (max-width: 1023px) {
  #view-compounder {
    grid-template-columns: 1fr;
  }
}

/* ─── Tablet portrait tweaks ─── */

@media (max-width: 820px) {
  body { padding: 12px; }
  h2 { font-size: 20px; }
  .current-patient-name { font-size: 26px; }
  .current-patient-actions button { flex: 1 1 auto; }
}
