/* =========================================================
   MediPulse v1.0 - Main stylesheet
   1. Tokens  2. Base  3. Layout  4. Components  5. Utilities
   ========================================================= */
/* 1. Tokens ------------------------------------------------ */
:root {
  --mp-primary: #0e9f9a;
  --mp-primary-rgb: 14, 159, 154;
  --mp-secondary: #1e3a5f;
  --mp-success: #22a06b;
  --mp-warning: #f5a524;
  --mp-danger: #e5484d;
  --mp-info: #3b82f6;
  --mp-bg: #f5f8fa;
  --mp-surface: #ffffff;
  --mp-border: #e3eaf0;
  --mp-text: #1b2a3a;
  --mp-muted: #5f7285;
  --mp-sidebar-bg: #1e3a5f;
  --mp-sidebar-text: #b9c8da;
  --mp-sidebar-w: 260px;
  --mp-sidebar-w-mini: 76px;
  --mp-topbar-h: 64px;
  --mp-radius: 12px;
  --mp-radius-sm: 8px;
  --mp-font-head: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
  --mp-font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-primary: var(--mp-primary);
  --bs-primary-rgb: var(--mp-primary-rgb);
  --bs-link-color: var(--mp-primary);
  --bs-body-font-family: var(--mp-font-body);
  --bs-body-bg: var(--mp-bg);
  --bs-body-color: var(--mp-text);
}

[data-bs-theme=dark] {
  --mp-bg: #0f1a24;
  --mp-surface: #162330;
  --mp-border: #243546;
  --mp-text: #e3ebf3;
  --mp-muted: #8fa3b6;
  --mp-sidebar-bg: #0b141c;
  --bs-body-bg: var(--mp-bg);
  --bs-body-color: var(--mp-text);
  --bs-border-color: var(--mp-border);
}

/* 2. Base -------------------------------------------------- */
body {
  font-size: 0.9375rem;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--mp-font-head);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--mp-text);
}

.num, td.num, .stat__value {
  font-variant-numeric: tabular-nums;
}

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

.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -4rem;
  z-index: 2000;
  background: var(--mp-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--mp-radius-sm);
}

.skip-link:focus {
  top: 1rem;
}

.btn-primary {
  --bs-btn-bg: var(--mp-primary);
  --bs-btn-border-color: var(--mp-primary);
  --bs-btn-hover-bg: #0b8782;
  --bs-btn-hover-border-color: #0b8782;
  --bs-btn-active-bg: #0a7571;
  --bs-btn-active-border-color: #0a7571;
}

/* 3. Layout ------------------------------------------------ */
.app {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 1040;
  width: var(--mp-sidebar-w);
  background: var(--mp-sidebar-bg);
  color: var(--mp-sidebar-text);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, width 0.25s ease;
}

.sidebar__brand {
  height: var(--mp-topbar-h);
  padding-inline: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  font-family: var(--mp-font-head);
  font-weight: 800;
  font-size: 1.25rem;
  text-decoration: none;
}

.sidebar__brand i {
  color: #3fd6cf;
  font-size: 1.5rem;
}

.sidebar__nav {
  overflow-y: auto;
  padding: 0.5rem 1rem 1.5rem;
  flex: 1;
}

.sidebar__heading {
  margin: 1.25rem 0.75rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #7f95ae;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--mp-radius-sm);
  color: var(--mp-sidebar-text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.sidebar__link.active {
  background: var(--mp-primary);
  color: #fff;
}

.sidebar__link i {
  font-size: 1.1rem;
}

.sidebar__badge {
  margin-inline-start: auto;
}

.main {
  margin-inline-start: var(--mp-sidebar-w);
  transition: margin 0.25s ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--mp-topbar-h);
  background: var(--mp-surface);
  border-bottom: 1px solid var(--mp-border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-inline: 1.5rem;
}

.topbar__search {
  max-width: 360px;
  flex: 1;
  position: relative;
}

.topbar__search i {
  position: absolute;
  inset-inline-start: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mp-muted);
}

.topbar__search input {
  padding-inline-start: 2.5rem;
  background: var(--mp-bg);
  border-color: transparent;
}

.topbar__actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.content {
  padding: 1.75rem 1.5rem 3rem;
}

.sidebar-mini .sidebar {
  width: var(--mp-sidebar-w-mini);
}

.sidebar-mini .main {
  margin-inline-start: var(--mp-sidebar-w-mini);
}

.sidebar-mini .sidebar__label, .sidebar-mini .sidebar__heading, .sidebar-mini .sidebar__badge {
  display: none;
}

.sidebar-mini .sidebar__brand {
  padding-inline: 1.45rem;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  [dir=rtl] .sidebar {
    transform: translateX(100%);
  }
  .sidebar-open .sidebar {
    transform: none;
  }
  .main, .sidebar-mini .main {
    margin-inline-start: 0;
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1035;
    display: none;
  }
  .sidebar-open .sidebar-backdrop {
    display: block;
  }
}
/* 4. Components -------------------------------------------- */
.card {
  background: var(--mp-surface);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--mp-border);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.breadcrumb {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
}

.stat {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.stat__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--mp-radius);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  background: rgba(var(--stat-rgb, var(--mp-primary-rgb)), 0.12);
  color: rgb(var(--stat-rgb, var(--mp-primary-rgb)));
}

.stat__label {
  color: var(--mp-muted);
  font-size: 0.85rem;
}

.stat__value {
  font-family: var(--mp-font-head);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat__trend {
  font-size: 0.8rem;
  font-weight: 600;
}

.stat--success {
  --stat-rgb: 34, 160, 107;
}

.stat--warning {
  --stat-rgb: 245, 165, 36;
}

.stat--info {
  --stat-rgb: 59, 130, 246;
}

.table {
  --bs-table-bg: transparent;
  margin: 0;
}

.table > :not(caption) > * > * {
  padding: 0.85rem 1.25rem;
  vertical-align: middle;
}

.table thead th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--mp-muted);
  background: var(--mp-bg);
  border-bottom: 0;
  white-space: nowrap;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: var(--mp-secondary);
  flex: none;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status--confirmed {
  color: var(--mp-success);
  background: rgba(34, 160, 107, 0.12);
}

.status--pending {
  color: #b87503;
  background: rgba(245, 165, 36, 0.16);
}

.status--cancelled {
  color: var(--mp-danger);
  background: rgba(229, 72, 77, 0.12);
}

.status--progress {
  color: var(--mp-info);
  background: rgba(59, 130, 246, 0.12);
}

[data-bs-theme=dark] .status--pending {
  color: #f5a524;
}

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

.schedule__item {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--mp-border);
}

.schedule__item:last-child {
  border-bottom: 0;
}

.schedule__time {
  width: 64px;
  flex: none;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.schedule__body {
  flex: 1;
  min-width: 0;
}

/* 5. Utilities --------------------------------------------- */
.text-muted-mp {
  color: var(--mp-muted);
}

.theme-icon-dark {
  display: none;
}

[data-bs-theme=dark] .theme-icon-light {
  display: none;
}

[data-bs-theme=dark] .theme-icon-dark {
  display: inline;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
/* 6. Patient module ---------------------------------------- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.timeline::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 11px;
  width: 2px;
  background: var(--mp-border);
}

.timeline__item {
  position: relative;
  padding-inline-start: 2.75rem;
  padding-bottom: 1.75rem;
}

.timeline__dot {
  position: absolute;
  inset-inline-start: 0;
  top: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  color: #fff;
  background: var(--mp-primary);
}

.timeline__dot--info {
  background: var(--mp-info);
}

.timeline__dot--warning {
  background: var(--mp-warning);
}

.timeline__dot--danger {
  background: var(--mp-danger);
}

.profile-cover {
  height: 96px;
  border-radius: var(--mp-radius) var(--mp-radius) 0 0;
  background: linear-gradient(120deg, var(--mp-secondary), var(--mp-primary));
}

.profile-avatar {
  width: 88px;
  height: 88px;
  font-size: 1.75rem;
  margin-top: -44px;
  border: 4px solid var(--mp-surface);
  background: var(--mp-primary);
}

.info-list {
  margin: 0;
}

.info-list dt {
  font-weight: 500;
  color: var(--mp-muted);
  font-size: 0.85rem;
}

.info-list dd {
  margin-bottom: 0.85rem;
}

.vital {
  text-align: center;
}

.vital__value {
  font-family: var(--mp-font-head);
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.vital__unit {
  color: var(--mp-muted);
  font-size: 0.85rem;
}

.form-section + .form-section {
  margin-top: 1.5rem;
}

/* 7. Appointments ------------------------------------------ */
.fc {
  --fc-border-color: var(--mp-border);
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: var(--mp-bg);
  --fc-button-bg-color: var(--mp-primary);
  --fc-button-border-color: var(--mp-primary);
  --fc-button-hover-bg-color: #0b8782;
  --fc-button-hover-border-color: #0b8782;
  --fc-button-active-bg-color: #0a7571;
  --fc-button-active-border-color: #0a7571;
  --fc-today-bg-color: rgba(var(--mp-primary-rgb), .08);
  --fc-list-event-hover-bg-color: var(--mp-bg);
  font-size: 0.875rem;
}

.fc .fc-toolbar-title {
  font-family: var(--mp-font-head);
  font-size: 1.25rem;
}

.fc a {
  color: inherit;
  text-decoration: none;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.5rem;
}

.slot-grid .btn {
  font-variant-numeric: tabular-nums;
}

.wizard-steps {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  flex-wrap: wrap;
}

.wizard-steps li {
  flex: 1;
  min-width: 120px;
  padding: 0.6rem 0.9rem;
  border-radius: var(--mp-radius-sm);
  background: var(--mp-bg);
  color: var(--mp-muted);
  font-weight: 600;
  border: 1px solid var(--mp-border);
}

.wizard-steps li.is-active {
  background: rgba(var(--mp-primary-rgb), 0.1);
  color: var(--mp-primary);
  border-color: var(--mp-primary);
}

.wizard-steps li.is-done {
  color: var(--mp-success);
}

.queue-now {
  background: var(--mp-secondary);
  color: #fff;
  border-radius: var(--mp-radius);
  padding: 1.5rem;
}

.queue-now__token {
  font-family: var(--mp-font-head);
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.token {
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  padding: 0.2rem 0.5rem;
  border-radius: var(--mp-radius-sm);
  background: rgba(var(--mp-primary-rgb), 0.12);
  color: var(--mp-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 8. Billing and wards ------------------------------------- */
.bed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 0.75rem;
}

.bed {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  padding: 0.6rem 0.7rem;
  background: var(--mp-surface);
  text-align: start;
}

.bed__no {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bed__state {
  font-size: 0.75rem;
  color: var(--mp-muted);
  display: block;
}

.bed--free {
  border-color: var(--mp-success);
  background: rgba(34, 160, 107, 0.08);
}

.bed--busy {
  border-color: var(--mp-danger);
  background: rgba(229, 72, 77, 0.08);
}

.bed--clean {
  border-color: var(--mp-warning);
  background: rgba(245, 165, 36, 0.1);
}

.invoice-total td {
  font-weight: 700;
}

@media print {
  .sidebar, .topbar, .page-head .btn, .sidebar-backdrop, .skip-link {
    display: none !important;
  }
  .main {
    margin: 0 !important;
  }
  .content {
    padding: 0;
  }
  .card {
    border: 0;
  }
}
/* 9. Messaging and authentication -------------------------- */
.chat {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 560px;
}

.chat__list {
  border-inline-end: 1px solid var(--mp-border);
  overflow-y: auto;
  max-height: 640px;
}

.chat__contact {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: start;
  border-bottom: 1px solid var(--mp-border);
}

.chat__contact:hover, .chat__contact.active {
  background: rgba(var(--mp-primary-rgb), 0.08);
}

.chat__panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat__log {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg {
  max-width: 75%;
  padding: 0.6rem 0.9rem;
  border-radius: var(--mp-radius);
  background: var(--mp-bg);
}

.msg--out {
  align-self: flex-end;
  background: var(--mp-primary);
  color: #fff;
}

.msg time {
  display: block;
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.2rem;
}

.chat__form {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--mp-border);
}

@media (max-width: 767.98px) {
  .chat {
    grid-template-columns: 1fr;
  }
  .chat__list {
    max-height: 220px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--mp-border);
  }
}
.mail-item {
  display: flex;
  gap: 0.85rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--mp-border);
  color: inherit;
  text-decoration: none;
}

.mail-item:hover {
  background: var(--mp-bg);
  color: inherit;
}

.mail-item--unread .mail-item__subject {
  font-weight: 700;
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mp-primary);
  flex: none;
  margin-top: 0.5rem;
}

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--mp-bg);
}

.auth__aside {
  background: linear-gradient(150deg, var(--mp-secondary), #0b6f6b);
  color: #fff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth__aside h2 {
  color: #fff;
  font-size: 2rem;
  max-width: 18ch;
}

.auth__main {
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  position: relative;
}

.auth__box {
  width: 100%;
  max-width: 420px;
}

.auth__theme {
  position: absolute;
  top: 1rem;
  inset-inline-end: 1rem;
}

.otp {
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
}

.otp input {
  width: 3.25rem;
  height: 3.5rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 991.98px) {
  .auth {
    grid-template-columns: 1fr;
  }
  .auth__aside {
    display: none;
  }
}
/* 10. Utility pages ---------------------------------------- */
.plan {
  height: 100%;
}

.plan--featured {
  border: 2px solid var(--mp-primary);
}

.plan__price {
  font-family: var(--mp-font-head);
  font-size: 2.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.plan__list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0;
}

.plan__list li {
  padding: 0.35rem 0;
  display: flex;
  gap: 0.5rem;
}

.plan__list i {
  color: var(--mp-success);
}

.plain {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  text-align: center;
  background: var(--mp-bg);
}

.plain__code {
  font-family: var(--mp-font-head);
  font-size: clamp(5rem, 18vw, 9rem);
  font-weight: 800;
  line-height: 1;
  color: var(--mp-primary);
  font-variant-numeric: tabular-nums;
}

.plain__box {
  max-width: 460px;
}

.accordion {
  --bs-accordion-bg: var(--mp-surface);
  --bs-accordion-border-color: var(--mp-border);
  --bs-accordion-btn-bg: var(--mp-surface);
  --bs-accordion-active-bg: rgba(var(--mp-primary-rgb), .08);
  --bs-accordion-active-color: var(--mp-primary);
}

/* 11. RTL typography ---------------------------------------- */
[dir=rtl] {
  --mp-font-body: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif;
  --mp-font-head: "IBM Plex Sans Arabic", "Plus Jakarta Sans", system-ui, sans-serif;
}
