/* =====================================================================
   SmartMR app theme (doctor, MR and admin pages)
   Built on Bootstrap 5.3. Mobile-first.
   ===================================================================== */

:root {
  --smr-primary: #1d4ed8;
  --smr-primary-600: #1e40af;
  --smr-primary-50: #eff6ff;
  --smr-accent: #0d9488;
  --smr-danger: #dc2626;
  --smr-success: #16a34a;
  --smr-warning: #d97706;
  --smr-bg: #f4f6fb;
  --smr-surface: #ffffff;
  --smr-border: #e5e7eb;
  --smr-text: #1f2937;
  --smr-muted: #6b7280;
  --smr-sidebar-bg: #0f172a;
  --smr-sidebar-text: #cbd5e1;
  --smr-sidebar-active: #1d4ed8;
  --smr-sidebar-w: 248px;
  --smr-sidebar-w-collapsed: 72px;
  --smr-topbar-h: 60px;
  --smr-radius: 12px;
  --smr-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);

  --bs-primary: var(--smr-primary);
  --bs-primary-rgb: 29, 78, 216;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --bs-body-font-size: .9375rem;
  --bs-body-color: var(--smr-text);
  --bs-body-bg: var(--smr-bg);
  --bs-border-radius: 8px;
  --bs-link-color: var(--smr-primary);
  --bs-link-color-rgb: 29, 78, 216;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--bs-body-font-family);
  font-size: var(--bs-body-font-size);
  color: var(--smr-text);
  background: var(--smr-bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: #111827; letter-spacing: -.01em; }

/* Buttons --------------------------------------------------------------- */
.btn { font-weight: 500; border-radius: 8px; }
.btn-primary { --bs-btn-bg: var(--smr-primary); --bs-btn-border-color: var(--smr-primary); --bs-btn-hover-bg: var(--smr-primary-600); --bs-btn-hover-border-color: var(--smr-primary-600); --bs-btn-active-bg: var(--smr-primary-600); --bs-btn-disabled-bg: var(--smr-primary); --bs-btn-disabled-border-color: var(--smr-primary); }
.btn-outline-primary { --bs-btn-color: var(--smr-primary); --bs-btn-border-color: var(--smr-primary); --bs-btn-hover-bg: var(--smr-primary); --bs-btn-hover-border-color: var(--smr-primary); --bs-btn-active-bg: var(--smr-primary); }
.btn-icon { display: inline-flex; align-items: center; gap: .4rem; }

/* Forms ----------------------------------------------------------------- */
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .35rem; color: #374151; }
.form-control, .form-select { border-radius: 8px; border-color: #d1d5db; padding: .55rem .8rem; font-size: .9375rem; }
.form-control:focus, .form-select:focus { border-color: var(--smr-primary); box-shadow: 0 0 0 .2rem rgba(29, 78, 216, .15); }
.form-text { font-size: .8125rem; }
.invalid-feedback { font-size: .8125rem; }
.required::after { content: " *"; color: var(--smr-danger); }
.input-group-text { background: #f9fafb; border-color: #d1d5db; }

/* Cards ----------------------------------------------------------------- */
.card { border: 1px solid var(--smr-border); border-radius: var(--smr-radius); box-shadow: var(--smr-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--smr-border); padding: 1rem 1.25rem; }
.card-body { padding: 1.25rem; }
.card-title { font-size: 1.0625rem; font-weight: 600; margin: 0; }
@media (max-width: 575.98px) {
  .card-body { padding: 1rem; }
  .card-header { padding: .85rem 1rem; }
}

/* =====================================================================
   App shell: sidebar + topbar
   ===================================================================== */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 1040;
  width: var(--smr-sidebar-w);
  background: var(--smr-sidebar-bg);
  color: var(--smr-sidebar-text);
  display: flex; flex-direction: column;
  transition: width .2s ease, transform .25s ease;
  overflow: hidden;
}
.sidebar-brand {
  height: var(--smr-topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: .6rem;
  padding: 0 1.1rem; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand img { height: 34px; width: auto; }
.sidebar-brand .brand-mini { display: none; height: 32px; border-radius: 6px; }
.sidebar-brand .brand-text { font-weight: 700; color: #fff; font-size: 1.05rem; white-space: nowrap; }
.sidebar-nav { list-style: none; margin: 0; padding: .75rem .6rem; overflow-y: auto; flex: 1 1 auto; }
.sidebar-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: .9rem .75rem .35rem; white-space: nowrap; }
.sidebar-link {
  display: flex; align-items: center; gap: .8rem;
  padding: .62rem .75rem; margin-bottom: 2px;
  color: var(--smr-sidebar-text); text-decoration: none;
  border-radius: 8px; white-space: nowrap; font-weight: 500;
}
.sidebar-link i { font-size: 1.15rem; width: 24px; text-align: center; flex: 0 0 24px; }
.sidebar-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-link.active { background: var(--smr-sidebar-active); color: #fff; }
.sidebar-footer { padding: .75rem 1.1rem; font-size: .75rem; color: #64748b; border-top: 1px solid rgba(255, 255, 255, .08); white-space: nowrap; }

.app-main { margin-left: var(--smr-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; }

.topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--smr-topbar-h);
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--smr-border);
  display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
}
.topbar .page-title { font-size: 1.05rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-toggle {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; color: #374151; flex: 0 0 auto;
}
.sidebar-toggle:hover { background: #f3f4f6; }
.topbar-user { margin-left: auto; display: flex; align-items: center; }
.topbar-user .dropdown-toggle { display: flex; align-items: center; gap: .5rem; border: 0; background: transparent; padding: .35rem .5rem; border-radius: 8px; color: var(--smr-text); max-width: 260px; }
.topbar-user .dropdown-toggle:hover { background: #f3f4f6; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--smr-primary-50); color: var(--smr-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex: 0 0 34px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.topbar-user .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: .875rem; }

.app-content { flex: 1 1 auto; padding: 1.5rem; width: 100%; max-width: 1400px; }
.app-footer { padding: 1rem 1.5rem; font-size: .8125rem; color: var(--smr-muted); border-top: 1px solid var(--smr-border); background: #fff; }
.app-footer a { color: inherit; }

/* Desktop collapsed (icon-only) sidebar */
@media (min-width: 992px) {
  body.sidebar-collapsed .sidebar { width: var(--smr-sidebar-w-collapsed); }
  body.sidebar-collapsed .app-main { margin-left: var(--smr-sidebar-w-collapsed); }
  body.sidebar-collapsed .sidebar .brand-text,
  body.sidebar-collapsed .sidebar .link-text,
  body.sidebar-collapsed .sidebar .sidebar-section,
  body.sidebar-collapsed .sidebar .sidebar-footer { display: none; }
  body.sidebar-collapsed .sidebar-link { justify-content: center; padding: .7rem 0; }
  body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
  body.sidebar-collapsed .sidebar-brand .brand-full { display: none; }
  body.sidebar-collapsed .sidebar-brand .brand-mini { display: block; }
}

/* Mobile: off-canvas sidebar */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: min(82vw, 290px); box-shadow: none; }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 1035; }
  body.sidebar-open { overflow: hidden; }
  .app-main { margin-left: 0; }
  .app-content { padding: 1rem; }
  .topbar { padding: 0 .75rem; }
  .app-footer { padding: .85rem 1rem; }
}

/* Page header ------------------------------------------------------------ */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.4rem; margin: 0; }
.page-header .subtitle { color: var(--smr-muted); margin: .2rem 0 0; font-size: .875rem; }
@media (max-width: 575.98px) {
  .page-header h1 { font-size: 1.2rem; }
  .page-header .btn { width: 100%; }
}

/* Alerts ------------------------------------------------------------------ */
.alert { border-radius: 10px; border: 0; font-size: .9rem; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info { background: var(--smr-primary-50); color: #1e3a8a; }
.notice { display: flex; gap: .75rem; align-items: flex-start; }
.notice > i { font-size: 1.25rem; line-height: 1.2; }

/* Badges ------------------------------------------------------------------ */
.badge-soft-success { background: #dcfce7; color: #166534; }
.badge-soft-danger { background: #fee2e2; color: #991b1b; }
.badge-soft-primary { background: var(--smr-primary-50); color: var(--smr-primary); }
.badge { font-weight: 600; padding: .4em .65em; border-radius: 6px; }

/* Tables / DataTables ----------------------------------------------------- */
.table { --bs-table-hover-bg: #f8fafc; margin-bottom: 0; }
.table > thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--smr-muted); font-weight: 600; background: #f9fafb; border-bottom-width: 1px; white-space: nowrap; }
.table > :not(caption) > * > * { padding: .7rem .75rem; vertical-align: middle; }
table.dataTable { width: 100% !important; margin: 0 !important; }
div.dataTables_wrapper div.dataTables_length select { width: auto; min-width: 5rem; display: inline-block; padding-right: 2.25rem; margin: 0 .35rem; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table.dataTable td, .table-scroll table.dataTable th { white-space: nowrap; }
div.dataTables_wrapper div.dataTables_filter input { margin-left: .5rem; width: 220px; max-width: 100%; display: inline-block; }
div.dataTables_wrapper div.dataTables_info { font-size: .8125rem; color: var(--smr-muted); padding-top: .85rem; }
div.dataTables_wrapper div.dataTables_paginate { padding-top: .5rem; }
div.dataTables_wrapper .row { --bs-gutter-x: 1rem; }
div.dataTables_wrapper > .row:first-child, .dt-toolbar { margin-bottom: .75rem; }
div.dataTables_processing { border: 0 !important; box-shadow: var(--smr-shadow); border-radius: 10px; background: #fff; }
.dt-buttons .btn { font-size: .8125rem; padding: .3rem .7rem; }
@media (max-width: 767.98px) {
  div.dataTables_wrapper div.dataTables_length,
  div.dataTables_wrapper div.dataTables_filter,
  div.dataTables_wrapper div.dataTables_info,
  div.dataTables_wrapper div.dataTables_paginate { text-align: left !important; }
  div.dataTables_wrapper div.dataTables_filter input { width: 100%; margin-left: 0; margin-top: .35rem; }
  div.dataTables_wrapper div.dataTables_filter label { width: 100%; }
  div.dataTables_wrapper div.dataTables_paginate ul.pagination { justify-content: flex-start !important; flex-wrap: wrap; }
}
/* Two-line record table (Admin > All MR Profiles) ---------------------------- */
.mr-stack { table-layout: auto; }
.mr-stack td { white-space: normal; }
.mr-stack .cell-main { font-weight: 500; color: var(--smr-text); line-height: 1.3; }
.mr-stack .cell-sub { font-size: .8125rem; color: var(--smr-muted); line-height: 1.35; margin-top: 2px; }
.mr-stack .cell-email { overflow-wrap: anywhere; display: flex; align-items: baseline; }
.mr-stack .cell-email i { flex: 0 0 auto; }
.mr-stack .badge { font-size: .72rem; }
.mr-stack td .btn-sm { padding: .2rem .45rem; }
@media (min-width: 1200px) {
  /* visible columns: 1 select, 2 MR, 3 contact, 4 hospital, 5 paid, 6 status, 7 actions */
  .mr-stack th:nth-child(1) { width: 32px; }
  .mr-stack td:nth-child(2) { min-width: 150px; }
  .mr-stack td:nth-child(3) { min-width: 210px; }
  .mr-stack td:nth-child(4) { min-width: 150px; }
  .mr-stack td:nth-child(5) { min-width: 110px; white-space: nowrap; }
  .mr-stack td:nth-child(6) { width: 100px; white-space: nowrap; }
  .mr-stack td:nth-child(7) { width: 112px; white-space: nowrap; }
}

/* Smaller screens: every record becomes a small card, no sideways scrolling */
@media (max-width: 1199.98px) {
  .mr-stack thead { display: none; }
  .mr-stack, .mr-stack tbody, .mr-stack tr, .mr-stack td { display: block; width: 100% !important; }
  .mr-stack tr { position: relative; border: 1px solid var(--smr-border); border-radius: 10px; margin-bottom: .75rem; padding: .6rem .75rem .6rem 2.4rem; background: #fff; }
  .mr-stack > :not(caption) > * > * { border: 0; padding: .2rem 0; box-shadow: none; }
  .mr-stack td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--smr-muted); }
  .mr-stack td:first-child { position: absolute; left: .75rem; top: .8rem; width: auto !important; padding: 0; }
  .mr-stack td:last-child { text-align: left !important; padding-top: .4rem; }
}
/* Tablets: fields of each card laid out in 3 columns */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .mr-stack tr { display: grid; grid-template-columns: 1fr 1fr 1fr; column-gap: 1rem; }
  .mr-stack td { width: auto !important; }
  .mr-stack td:last-child { align-self: end; text-align: right !important; }
  .mr-stack tbody tr td.dataTables_empty { padding: 1rem 0; text-align: center; }
}

.filter-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filter-bar .filter-item { min-width: 180px; flex: 1 1 180px; max-width: 320px; }
.filter-bar .form-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--smr-muted); }
@media (max-width: 575.98px) { .filter-bar .filter-item { max-width: none; } }

/* Profile ----------------------------------------------------------------- */
.profile-photo { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 4px solid #fff; box-shadow: var(--smr-shadow); background: #e5e7eb; }
.detail-list { margin: 0; }
.detail-list .detail-row { display: flex; flex-wrap: wrap; padding: .7rem 0; border-bottom: 1px dashed var(--smr-border); gap: .25rem 1rem; }
.detail-list .detail-row:last-child { border-bottom: 0; }
.detail-list dt { width: 160px; font-weight: 500; color: var(--smr-muted); font-size: .875rem; }
.detail-list dd { margin: 0; flex: 1 1 200px; word-break: break-word; }

/* Stat tiles -------------------------------------------------------------- */
.stat { display: flex; align-items: center; gap: .85rem; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; background: var(--smr-primary-50); color: var(--smr-primary); flex: 0 0 44px; }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .8125rem; color: var(--smr-muted); }

/* FullCalendar ------------------------------------------------------------ */
.fc { --fc-border-color: var(--smr-border); --fc-today-bg-color: #fef9c3; --fc-button-bg-color: #fff; --fc-button-border-color: #d1d5db; --fc-button-text-color: #374151; --fc-button-hover-bg-color: #f3f4f6; --fc-button-hover-border-color: #d1d5db; --fc-button-active-bg-color: var(--smr-primary); --fc-button-active-border-color: var(--smr-primary); --fc-event-border-color: transparent; font-size: .875rem; }
.fc .fc-button { font-weight: 500; text-transform: capitalize; box-shadow: none !important; border-radius: 8px; padding: .35rem .7rem; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
.fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 600; }
.fc .fc-daygrid-day-number, .fc .fc-col-header-cell-cushion { color: var(--smr-text); text-decoration: none; }
.fc .fc-event { cursor: pointer; border-radius: 6px; padding: 1px 4px; }
.fc .fc-daygrid-event { white-space: normal; }
.fc-day-past .fc-daygrid-day-number { color: #9ca3af; }
.fc .fc-list-day-cushion a, .fc .fc-list-day-text, .fc .fc-list-day-side-text { text-decoration: none; color: var(--smr-text); font-weight: 600; }
.fc .fc-list-event-time { display: none; }
.fc .fc-list-event-title { white-space: normal; }
.booking-calendar .fc-daygrid-day.fc-day-future:not(.is-holiday):hover,
.booking-calendar .fc-daygrid-day.fc-day-today:not(.is-holiday):hover { background: var(--smr-primary-50); cursor: pointer; }
.booking-calendar .fc-daygrid-day.is-holiday { background: #fef2f2; }
@media (max-width: 575.98px) {
  .fc .fc-toolbar { flex-direction: column; gap: .5rem; align-items: stretch; }
  .fc .fc-toolbar-chunk { display: flex; justify-content: center; }
  .fc .fc-toolbar-title { font-size: 1rem; text-align: center; }
  .fc { font-size: .75rem; }
  .fc .fc-daygrid-event { font-size: .68rem; }
}
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .8125rem; color: var(--smr-muted); }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; background: var(--c); }

/* Auth pages -------------------------------------------------------------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; position: relative; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #0d9488 120%); }
.auth-video { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; opacity: .28; }
.auth-wrap { position: relative; z-index: 1; width: 100%; max-width: 460px; }
.auth-wrap.wide { max-width: 760px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 1.25rem; }
.auth-logo img { height: 52px; }
.auth-card { background: #fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); padding: 2rem; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: .35rem; }
.auth-card .lead-text { color: var(--smr-muted); font-size: .9rem; margin-bottom: 1.25rem; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; margin-top: 1.25rem; font-size: .875rem; }
.auth-links a { font-weight: 500; text-decoration: none; }
.auth-footer { text-align: center; color: rgba(255, 255, 255, .7); font-size: .8125rem; margin-top: 1.25rem; }
.auth-footer a { color: #fff; }
.auth-role-switch { display: flex; justify-content: center; gap: .5rem; margin-bottom: 1rem; }
.auth-role-switch a { color: rgba(255, 255, 255, .85); text-decoration: none; font-size: .875rem; padding: .35rem .85rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .3); }
.auth-role-switch a.active, .auth-role-switch a:hover { background: #fff; color: var(--smr-primary); }
.captcha-box { display: flex; align-items: center; gap: .75rem; }
.captcha-q { font-weight: 700; font-size: 1.05rem; background: var(--smr-primary-50); color: var(--smr-primary); padding: .5rem .85rem; border-radius: 8px; white-space: nowrap; letter-spacing: .03em; }
.otp-input { font-size: 1.6rem; letter-spacing: .5em; text-align: center; font-weight: 600; }
@media (max-width: 575.98px) {
  .auth-card { padding: 1.35rem; border-radius: 14px; }
  .auth-video { display: none; }
}

.choice-list { display: grid; gap: .75rem; }
.choice-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; border: 1px solid var(--smr-border); border-radius: 10px; padding: .85rem 1rem; }
.choice-item .hospital { font-weight: 600; }
.choice-item .email { color: var(--smr-muted); font-size: .875rem; word-break: break-all; }
@media (max-width: 575.98px) { .choice-item form, .choice-item .btn { width: 100%; } }

.pay-box { border: 1px dashed #93c5fd; background: var(--smr-primary-50); border-radius: 12px; padding: 1rem; }
.pay-box img { max-width: 180px; width: 100%; border-radius: 8px; background: #fff; }

/* Camera ------------------------------------------------------------------ */
.camera-frame { position: relative; width: 100%; max-width: 420px; aspect-ratio: 4 / 3; background: #0f172a; border-radius: 12px; overflow: hidden; }
.camera-frame video, .camera-frame img { width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #94a3b8; gap: .5rem; text-align: center; padding: 1rem; }
.camera-placeholder i { font-size: 2.5rem; }

/* Misc -------------------------------------------------------------------- */
.text-muted-2 { color: var(--smr-muted) !important; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--smr-muted); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; color: #cbd5e1; }
.swal2-popup { font-family: var(--bs-body-font-family) !important; border-radius: 14px !important; }
.ads-slot { margin: 1rem 0; text-align: center; }
@media print {
  .sidebar, .topbar, .app-footer, .dt-buttons, .dataTables_filter, .dataTables_length, .dataTables_paginate { display: none !important; }
  .app-main { margin: 0 !important; }
}
