/* =========================================================
   Clinaid — Global Styles
   Design system tokens, layout primitives, and components
   ========================================================= */

:root {
  /* Brand */
  --color-primary: #1A3560;
  --color-primary-dark: #122545;
  --color-primary-light: #2A4A7A;
  --color-accent: #0B8FAC;
  --color-accent-dark: #097387;

  /* Status */
  --color-success: #27AE60;
  --color-warning: #F39C12;
  --color-danger: #E74C3C;

  /* Neutrals */
  --color-bg: #F5F7FA;
  --color-white: #FFFFFF;
  --color-text: #2C3E50;
  --color-text-secondary: #555555;
  --color-border: #E0E6ED;

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  /* Shadow */
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 60px;

  /* Type */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5 {
  margin: 0 0 0.5em;
  color: var(--color-text);
  font-weight: 600;
}

/* ---------- Layout primitives ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  width: var(--sidebar-width);
  background: var(--color-primary);
  color: var(--color-white);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-white);
  text-decoration: none;
}

.sidebar-nav .nav-item,
.sidebar-nav a.nav-item {
  background: transparent !important;
}

.topbar {
  grid-area: topbar;
  height: var(--topbar-height);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow);
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.main-content {
  grid-area: main;
  padding: 24px;
  overflow-y: auto;
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ---------- Buttons ----------
   Verdana Health design system · Clinaid palette
   Variants: primary · secondary · ghost · teal (AI/CTA) · danger (destructive)
   Size modifiers: .btn-sm (inline/icon) · .btn-lg (page CTA)
*/
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-teal,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  vertical-align: middle;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  font-weight: 500;
  font-size: 14px;
  line-height: 1;
  min-width: fit-content;
  box-sizing: border-box;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
  min-height: 42px;
}

/* Primary — filled navy */
.btn-primary {
  background: #1A3560;
  color: #fff;
  border-color: #1A3560;
}
.btn-primary:hover { background: #0F2347; border-color: #0F2347; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* Secondary — outlined navy */
.btn-secondary {
  background: transparent;
  color: #1A3560;
  border-color: #1A3560;
}
.btn-secondary:hover { background: rgba(26, 53, 96, 0.05); }
.btn-secondary:active { transform: translateY(1px); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* Ghost — text only navy */
.btn-ghost {
  background: transparent;
  color: #1A3560;
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(26, 53, 96, 0.05); }
.btn-ghost:active { transform: translateY(1px); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

/* Teal — filled teal (AI actions / primary CTAs) */
.btn-teal {
  background: #0B8FAC;
  color: #fff;
  border-color: #0B8FAC;
}
.btn-teal:hover { background: #0A7A93; border-color: #0A7A93; }
.btn-teal:active { transform: translateY(1px); }
.btn-teal:disabled { opacity: 0.4; cursor: not-allowed; }

/* Destructive — filled red (delete only) */
.btn-danger {
  background: #EF4444;
  color: #fff;
  border-color: #EF4444;
}
.btn-danger:hover { background: #DC2626; border-color: #DC2626; }
.btn-danger:active { transform: translateY(1px); }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }

/* Size modifiers */
.btn-sm { padding: 6px 14px; min-height: 32px; font-size: 13px; }
.btn-lg { padding: 12px 24px; min-height: 48px; font-size: 16px; }

.btn-block {
  width: 100%;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--color-white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 16px;
}

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

.form-input,
select.form-input,
textarea.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(11, 143, 172, 0.15);
}

textarea.form-input {
  min-height: 100px;
  resize: vertical;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-bg);
  color: var(--color-text-secondary);
}

.badge-success { background: rgba(39, 174, 96, 0.12); color: var(--color-success); }
.badge-warning { background: rgba(243, 156, 18, 0.12); color: var(--color-warning); }
.badge-danger  { background: rgba(231, 76, 60, 0.12);  color: var(--color-danger); }
.badge-primary { background: rgba(26, 53, 96, 0.10);   color: var(--color-primary); }

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th,
.table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

.table th {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

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

.table tr:hover td {
  background: var(--color-bg);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 53, 96, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* =========================================================
   Login page
   ========================================================= */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #F5F7FA 0%, #E8EDF4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-card {
  width: 100%;
  padding: 36px 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background: var(--color-white);
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.logo-text {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}

.login-title {
  text-align: center;
  font-size: 22px;
  margin-bottom: 6px;
}

.login-subtitle {
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 14px;
  margin: 0 0 24px;
}

.login-form .form-input {
  font-size: 15px;
  padding: 12px 14px;
}

.login-message {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 12px;
}

.login-message.is-error {
  display: block;
  background: rgba(231, 76, 60, 0.1);
  color: var(--color-danger);
  border: 1px solid rgba(231, 76, 60, 0.25);
}

.login-message.is-success {
  display: block;
  background: rgba(39, 174, 96, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(39, 174, 96, 0.25);
}

.login-forgot {
  display: block;
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.login-forgot:hover {
  color: var(--color-accent);
}

/* Password field + inline reveal toggle */
.input-reveal {
  position: relative;
  display: flex;
  align-items: center;
}
.input-reveal .form-input {
  /* Room for the reveal button so the icon never overlaps typed text. */
  padding-right: 44px;
}
.reveal-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  transition: color 0.15s, background 0.15s;
}
.reveal-btn:hover { color: var(--color-primary); }
.reveal-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}
.reveal-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
/* Default: show the "eye" (password hidden). When revealed, swap to "eye-off". */
.reveal-btn .icon-eye-off { display: none; }
.reveal-btn.is-revealed .icon-eye { display: none; }
.reveal-btn.is-revealed .icon-eye-off { display: block; }

/* Inline self-serve reset panel (revealed by "Forgot password?") */
.login-reset {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-reset[hidden] { display: none; }

/* CL-351 — `.device-limit-list` / `.device-choice*` styled the device-limit
   recovery list on the login card. They go with the panel they dressed: with
   one registered device per user the doctor is never asked to choose a device
   to sign out, so nothing renders that list any more. Removed by decision, not
   by a bug. */

.login-footer {
  margin-top: 24px;
  font-size: 13px;
  color: var(--color-text-secondary);
  text-align: center;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .sidebar {
    position: fixed;
    left: -100%;
    transition: left 0.25s;
    z-index: 100;
    width: 80%;
    max-width: 280px;
  }
  .sidebar.is-open {
    left: 0;
  }
  .login-card {
    padding: 28px 22px;
  }
}

/* ── Consultation Type Selector ── */
.consult-type-btn {
  padding: 7px 14px;
  border: 1.5px solid #E0E6ED;
  border-radius: 20px;
  background: #fff;
  color: #555555;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.consult-type-btn:hover {
  border-color: #0B8FAC;
  color: #0B8FAC;
  background: #EBF5FB;
}
.consult-type-btn.active {
  border-color: #1A3560;
  background: #1A3560;
  color: #fff;
  font-weight: 600;
}
.consult-type-btn.emergency-active {
  border-color: #FBBBB9 !important;
  background: #FFF8F8 !important;
  color: #C0392B !important;
  font-weight: 600;
}

/* ── Patient Folder Tabs ── */
.folder-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 2px solid #E0E6ED;
  margin-bottom: 0;
  background: #fff;
  border-radius: 10px 10px 0 0;
  padding: 0 4px;
}
.folder-tab {
  padding: 10px 16px;
  border: none;
  background: none;
  color: #555555;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  white-space: nowrap;
}
.folder-tab:hover {
  color: #1A3560;
  background: #F5F7FA;
}
.folder-tab.active {
  color: #1A3560;
  font-weight: 700;
  border-bottom: 2px solid #1A3560;
  background: none;
}
.folder-tab-content {
  display: none !important;
}
.folder-tab-content.active {
  display: block !important;
}
/* 3 Nov 2026 (Dr Motaz, again): a tab's first row — "Drug monitoring … Start a
   plan", a part header — sat flush against the tab bar. Every folder tab now
   starts 14px below it; an element that sets its own top margin inline keeps it. */
.folder-tab-content > :first-child {
  margin-top: 14px;
}

/* ── Approve / Reject items ── */
.ar-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 4px;
  border: 1px solid #E0E6ED;
  border-radius: 6px;
  background: #fff;
  transition: all 0.15s;
}
.ar-item.approved {
  background: #EAFAF1;
  border-color: #27AE60;
}
.ar-item.rejected {
  background: #F9F9F9;
  border-color: #E0E6ED;
  opacity: 0.6;
}
.ar-item.rejected .ar-text {
  text-decoration: line-through;
  color: #555555;
}
.ar-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.6;
  color: #2C3E50;
  cursor: text;
}
.ar-text:focus {
  outline: 1px dashed #0B8FAC;
  border-radius: 4px;
  padding: 2px 4px;
}
.ar-btn-approve {
  min-width: 28px;
  height: 28px;
  border: 1.5px solid #27AE60;
  border-radius: 6px;
  background: white;
  color: #27AE60;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ar-btn-approve.active {
  background: #27AE60;
  color: white;
}
.ar-btn-reject {
  min-width: 28px;
  height: 28px;
  border: 1.5px solid #E74C3C;
  border-radius: 6px;
  background: white;
  color: #E74C3C;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ar-btn-reject.active {
  background: #E74C3C;
  color: white;
}

/* ── Approve/Reject editable text cursor ── */
.ar-text[contenteditable="true"]:hover {
  background: #FAFFFE;
  border-radius: 4px;
  outline: 1px dashed #0B8FAC;
  cursor: text;
  padding: 2px 4px;
}
.ar-text[contenteditable="true"]:focus {
  background: #EBF5FB;
  border-radius: 4px;
  outline: 2px solid #0B8FAC;
  padding: 2px 4px;
}
.ar-btn-edit {
  min-width: 28px;
  height: 28px;
  border: 1.5px solid #0B8FAC;
  border-radius: 6px;
  background: white;
  color: #0B8FAC;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ar-btn-edit:hover {
  background: #EBF5FB;
}
.ar-text[contenteditable="true"] {
  outline: 2px solid #0B8FAC;
  border-radius: 4px;
  padding: 2px 6px;
  background: #EBF5FB;
  cursor: text;
}

.ar-add-btn {
  font-size: 12px;
  padding: 3px 10px;
  border: 1.5px dashed #0B8FAC;
  border-radius: 6px;
  background: transparent;
  color: #0B8FAC;
  cursor: pointer;
  font-weight: 600;
}
.ar-add-btn:hover {
  background: #EBF5FB;
}
.ar-text:empty:before {
  content: attr(placeholder);
  color: #555555;
  font-style: italic;
}

/* Smart add dropdown reset */
.ar-add-dropdown li {
  padding: 4px 10px !important;
  margin: 0 !important;
  line-height: 1.2 !important;
  list-style: none !important;
  border-bottom: 1px solid #F0F0F0;
  cursor: pointer;
}
.ar-add-dropdown li:hover {
  background: #EBF5FB;
}
