/* Aalsum Pharmacy — shared theme
   Derived from the legacy old-clinic-portal/ implementation.
   Reuse these variables and utility classes on all project screens.
*/

:root {
  /* Brand palette */
  --primary: #E85D04;
  --primary-light: #F4A261;
  --primary-dark: #9C6644;

  /* Supporting colours */
  --success: #059669;
  --info: #2563EB;
  --warning: #F59E0B;
  --warning-bs: #ffc107;
  --danger: #DC2626;
  --neutral-dark: #343a40;
  --neutral: #6c757d;
  --light: #f8f9fa;
  --border: #e9ecef;
  --page-bg: #f5f5f5;
  --white: #ffffff;

  /* Aliases for consistency with legacy naming */
  --bg: var(--page-bg);
  --card-bg: var(--white);
  --fg: var(--neutral-dark);
  --muted: var(--neutral);
  --accent: var(--primary);
  --accent-fg: var(--white);
  --error-bg: #FEE2E2;
  --error-border: #FECACA;
  --error-fg: #DC2626;

  /* Typography */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--page-bg);
  color: var(--neutral-dark);
  font-family: inherit;
  line-height: 1.5;
}

/* Layout helpers ------------------------------------------------------- */

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

@media (max-width: 768px) {
  .container {
    padding: 15px 20px;
  }
}

/* Cards ---------------------------------------------------------------- */

.card, .auth-card, .panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card {
  padding: 25px;
  margin-bottom: 20px;
}

/* Navbars -------------------------------------------------------------- */

.navbar {
  background: var(--primary);
  color: var(--white);
  padding: 1rem 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0;
  padding-bottom: 0;
}

.navbar h1 {
  margin: 0;
  font-size: 1.5rem;
}

.navbar a, .navbar .nav-link {
  color: var(--white);
  text-decoration: none;
  margin-right: 20px;
  font-size: 14px;
}

.navbar a:hover, .navbar .nav-link:hover {
  text-decoration: underline;
}

.navbar .logout-form {
  display: inline;
}

.navbar .logout-form button {
  color: var(--white);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

/* Portal-specific navbar overrides */
.navbar.navbar-pharmacy,
.navbar.navbar-staff {
  background: var(--primary-dark);
}

.navbar.navbar-inventory {
  background: #1e5a5a;
}

/* Buttons -------------------------------------------------------------- */

.btn, button, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary, button.primary, input[type="submit"].primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(232, 93, 4, 0.3);
}

.btn-primary:hover, button.primary:hover, input[type="submit"].primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(232, 93, 4, 0.4);
}

.btn-secondary, button.secondary, .btn-secondary:visited {
  background: var(--neutral);
  color: var(--white);
}

.btn-secondary:hover, button.secondary:hover {
  background: #5a6268;
}

.btn-success, button.success {
  background: var(--success);
  color: var(--white);
}

.btn-success:hover, button.success:hover {
  background: #047857;
}

.btn-info, button.info {
  background: var(--info);
  color: var(--white);
}

.btn-info:hover, button.info:hover {
  background: #1d4ed8;
}

.btn-warning, button.warning {
  background: var(--warning);
  color: #212529;
}

.btn-danger, button.danger {
  background: var(--danger);
  color: var(--white);
}

.btn-danger:hover, button.danger:hover {
  background: #b91c1c;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

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

.form-group {
  margin-bottom: 18px;
}

.form-label, form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--neutral-dark);
  margin-bottom: 6px;
}

.form-input,
form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="tel"],
form input[type="url"],
form input[type="date"],
form select,
form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--white);
  color: var(--neutral-dark);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus,
form input:focus,
form select:focus,
form textarea:focus {
  border-color: var(--primary);
}

.form-input.is-invalid,
form input.is-invalid,
form select.is-invalid,
form textarea.is-invalid {
  border-color: var(--danger);
}

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

.table-responsive {
  overflow-x: auto;
}

table.data-table,
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

table.data-table th,
table th {
  background: var(--light);
  color: var(--neutral);
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

table.data-table td,
table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

table.data-table tr:last-child td,
table tr:last-child td {
  border-bottom: none;
}

table.data-table tbody tr:nth-of-type(odd),
table tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Stat cards ----------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--white);
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: var(--neutral);
  font-weight: 500;
}

.stat-card .value {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 8px 0;
  line-height: 1;
}

.stat-card a {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.stat-card.primary-dark .value,
.stat-card.primary-dark a {
  color: var(--primary-dark);
}

.stat-card.info .value,
.stat-card.info a {
  color: var(--info);
}

.stat-card.success .value,
.stat-card.success a {
  color: var(--success);
}

/* Badges --------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.badge-success {
  background: #d1fae5;
  color: #059669;
}

.badge-info {
  background: #dbeafe;
  color: #2563eb;
}

.badge-warning {
  background: #fef3c7;
  color: #d97706;
}

.badge-danger {
  background: #fee2e2;
  color: #dc2626;
}

.badge-neutral {
  background: var(--light);
  color: var(--neutral);
}

/* Hero banner ---------------------------------------------------------- */

.hero-banner {
  background: linear-gradient(135deg, #C2410C 0%, #EA580C 100%);
  padding: 30px;
  border-radius: 8px;
  color: var(--white);
  margin-bottom: 40px;
}

.hero-banner h2,
.hero-banner h3 {
  margin: 0 0 10px 0;
  font-size: 24px;
}

.hero-banner p {
  margin: 0;
  opacity: 0.9;
}

.hero-banner .cta {
  display: inline-block;
  background: var(--white);
  color: #C2410C;
  padding: 12px 30px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}

/* Alerts / messages ---------------------------------------------------- */

.alert, .messages .message {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-success, .messages .success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error, .alert-danger, .messages .error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-warning, .messages .warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
}

.alert-info, .messages .info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Toast notifications -------------------------------------------------- */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #333;
  color: var(--white);
  padding: 12px 20px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  min-width: 200px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: var(--success);
}

.toast-container .toast.error {
  background: var(--danger);
  color: var(--white);
}

.toast.warning {
  background: var(--warning);
  color: #212529;
}

/* Page title / section header ------------------------------------------ */

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 6px 0;
}

.page-subtitle {
  color: var(--neutral);
  margin: 0 0 25px 0;
  font-size: 15px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary-dark);
  margin: 25px 0 12px 0;
}

/* Auth (public/login/register) centred layout -------------------------- */

body.auth-page {
  background: var(--light);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  font-family: 'Poppins', sans-serif;
}

body.auth-page .auth-card {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

body.auth-page .auth-card h2 {
  font-size: 28px;
  margin: 0 0 6px 0;
  color: var(--neutral-dark);
}

body.auth-page .auth-card .subtitle {
  color: var(--neutral);
  margin: 0 0 28px 0;
  font-size: 15px;
}

body.auth-page .auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--neutral);
}

body.auth-page .auth-footer a { color: var(--primary); text-decoration: none; }
body.auth-page .auth-footer a:hover { text-decoration: underline; }

/* Pharmacy login — brown sign-in button (scoped to pharmacy-auth only) ---- */
body.pharmacy-auth .btn-primary {
  background: linear-gradient(135deg, #6F4E37, var(--primary-dark));
  box-shadow: 0 4px 15px rgba(111, 78, 55, 0.35);
}
body.pharmacy-auth .btn-primary:hover {
  box-shadow: 0 6px 25px rgba(111, 78, 55, 0.45);
}

/* Actions / button groups --------------------------------------------- */

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.actions-right {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

/* Definition lists / read-only detail panels --------------------------- */

dl.kv {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 10px 20px;
  margin: 0 0 22px 0;
}

dl.kv dt {
  color: var(--neutral);
  font-weight: 500;
  font-size: 13px;
}

dl.kv dd {
  margin: 0;
  color: var(--neutral-dark);
  font-size: 14px;
}

@media (max-width: 768px) {
  dl.kv { grid-template-columns: 1fr; gap: 4px 0; }
  dl.kv dt { padding-top: 8px; }
}

/* Inline chips (status / group / permission) ------------------------- */

.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--light);
  color: var(--neutral);
}

.chip-success,
.chip-ok {
  background: #d1fae5;
  color: #059669;
}

.chip-warning {
  background: #fef3c7;
  color: #d97706;
}

.chip-danger,
.chip-no {
  background: #fee2e2;
  color: #dc2626;
}

.chip-info {
  background: #dbeafe;
  color: #2563eb;
}

/* Plain lists ---------------------------------------------------------- */

ul.plain {
  list-style: none;
  padding: 0;
  margin: 0;
}

ul.plain li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

ul.plain li:last-child { border-bottom: none; }

ul.plain li.ok { color: var(--success); }
ul.plain li.no { color: var(--neutral); text-decoration: line-through; }

/* Errors --------------------------------------------------------------- */

.error {
  background: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid var(--error-border);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* Wizard step indicator ------------------------------------------------ */

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.wizard-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  background: var(--light);
  color: var(--neutral);
}

.wizard-step.active {
  background: var(--primary);
  color: var(--white);
}

.wizard-step.completed {
  background: var(--success);
  color: var(--white);
}

.wizard-divider {
  flex: 0 0 24px;
  height: 2px;
  background: var(--border);
}

/* Modal ---------------------------------------------------------------- */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 480px;
  padding: 28px;
}

/* Misc utilities ------------------------------------------------------- */

.text-primary { color: var(--primary); }
.text-primary-dark { color: var(--primary-dark); }
.text-success { color: var(--success); }
.text-info { color: var(--info); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--neutral); }

.bg-light { background: var(--light); }
.bg-white { background: var(--white); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

.full-width { width: 100%; }

/* Status track selector (order detail status grid) ---------------------- */

.status-help-text {
  color: var(--neutral);
  font-size: 14px;
  margin-top: -10px;
  margin-bottom: 18px;
}

.preview-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 768px) {
  .preview-panel { grid-template-columns: 1fr; }
}

.preview-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.preview-card h4 {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: var(--neutral);
  font-weight: 500;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 1200px) {
  .status-grid { grid-template-columns: 1fr; }
}

.status-track {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  overflow: visible;
}
.status-track-header {
  background: var(--light);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--neutral-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-track-body { padding: 8px; }

.status-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1.15fr) minmax(0, 1.6fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-bottom: 4px;
}
.status-row:last-child { margin-bottom: 0; }
.status-row:hover { background: rgba(0, 0, 0, 0.03); }
.status-row.selected { background: rgba(232, 93, 4, 0.22); border-left: 4px solid #e85d05; padding-left: 6px; }
/* Disabled rows are view-only: no pointer cursor, no hover, dimmed, and the
   radio circle is removed entirely (the row is informational, not clickable). */
.status-row.disabled { cursor: default; opacity: 0.55; }
.status-row.disabled:hover { background: transparent; }
.status-row.disabled .status-badge { opacity: 0.85; }
.status-row.disabled input[type="checkbox"],
.status-row.disabled input[type="radio"] { visibility: hidden; }
.status-row input[type="checkbox"],
.status-row input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.status-row input[type="checkbox"]:disabled,
.status-row input[type="radio"]:disabled { cursor: not-allowed; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: break-word;
  min-width: 0;
}
.status-text {
  font-size: 13px;
  color: var(--neutral);
  overflow-wrap: break-word;
  min-width: 0;
}
.status-role {
  font-size: 11px;
  color: var(--neutral);
  text-align: right;
  overflow-wrap: break-word;
  min-width: 0;
}

/* Status colour palette — exact values from 2026-SETTING.xlsx */
.bg-yellow      { background: #FFFF00; color: #000000; }
.bg-green       { background: #00FF00; color: #000000; }
.bg-light-green { background: #93C47D; color: #000000; }
.bg-red         { background: #FF0000; color: #FFFFFF; }
.bg-orange      { background: #FF6D01; color: #FFFFFF; }
.bg-peach       { background: #FCE5CD; color: #000000; }
.bg-blue        { background: #4A86E8; color: #000000; }
.bg-purple      { background: #D9D2E9; color: #000000; }
.bg-beige       { background: #FCE5CD; color: #000000; }
.bg-black       { background: #000000; color: #FFFFFF; }
.bg-neutral     { background: var(--light); color: var(--neutral); }

.bg-yellow.selected-ring      { box-shadow: 0 0 0 3px #d97706; }
.bg-green.selected-ring       { box-shadow: 0 0 0 3px #059669; }
.bg-light-green.selected-ring { box-shadow: 0 0 0 3px #6b9c55; }
.bg-red.selected-ring         { box-shadow: 0 0 0 3px #b91c1c; }
.bg-orange.selected-ring      { box-shadow: 0 0 0 3px #c2410c; }
.bg-peach.selected-ring       { box-shadow: 0 0 0 3px #d97706; }
.bg-blue.selected-ring        { box-shadow: 0 0 0 3px #2563eb; }
.bg-purple.selected-ring      { box-shadow: 0 0 0 3px #7c3aed; }
.bg-beige.selected-ring       { box-shadow: 0 0 0 3px #d97706; }
.bg-black.selected-ring       { box-shadow: 0 0 0 3px #4b5563; }
.bg-neutral.selected-ring     { box-shadow: 0 0 0 3px var(--neutral); }

/* Logistic attachment records ----------------------------------------- */
.logistic-attachment-list { display:flex; flex-direction:column; gap:8px; }
.logistic-attachment-row {
  display:flex; align-items:center; justify-content:space-between;
  padding:8px 10px; border:1px solid var(--border); border-radius:8px;
  background:var(--white);
}
.logistic-attachment-row form {
  display:flex; gap:6px; align-items:center; flex-wrap:wrap;
  width:100%; margin-top:6px;
}
.logistic-attachment-row form input[type="file"],
.logistic-attachment-row form input[type="url"] {
  flex:1 1 200px; padding:6px 8px; font-size:13px;
  border:1.5px solid var(--border); border-radius:8px;
}
.logistic-attachment-row form input[type="text"] {
  flex:1 1 140px; padding:6px 8px; font-size:13px;
  border:1.5px solid var(--border); border-radius:8px;
}
.logistic-attachment-row form button {
  flex:0 0 auto; padding:6px 14px; font-size:13px;
}
.logistic-reupload-group {
  padding:10px; margin-top:8px;
  border:1px dashed var(--border); border-radius:8px;
  background:var(--light);
}

/* Product search typeahead dropdown on order resolve screen ----- */

.resolve-typeahead {
  position: relative;
}

.resolve-typeahead-results {
  position: fixed;
  z-index: 1000;
  background: var(--white);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 0;
  margin: 0;
  list-style: none;
  min-width: 260px;
  max-height: calc((100vh - 180px) / 2);
  overflow-y: auto;
}

.resolve-typeahead-results li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  word-break: break-word;
}

.resolve-typeahead-results li:last-child {
  border-bottom: none;
}

.resolve-typeahead-results li:hover,
.resolve-typeahead-results li:focus {
  background: var(--light);
  outline: none;
}
