/* =========================================================
   3AYAN (عيان) - Smart Pharmacy & Telehealth Platform
   Design System: High-End Medical Glassmorphism & Cyber-Health
   ========================================================= */

:root {
  /* Color Palette */
  --bg-primary: #070d19;
  --bg-secondary: #0e172a;
  --bg-tertiary: #162238;
  
  --card-bg: rgba(15, 23, 42, 0.75);
  --card-bg-solid: #0f172a;
  --card-border: rgba(255, 255, 255, 0.09);
  --card-border-glow: rgba(6, 182, 212, 0.35);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Brand Accents */
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.4);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.4);
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.4);
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  /* UI Tokens */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(6, 182, 212, 0.25);

  --font-arabic: 'Cairo', system-ui, -apple-system, sans-serif;
  --font-latin: 'Outfit', system-ui, -apple-system, sans-serif;

  --transition-fast: 0.18s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset & Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-arabic);
  background: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(6, 182, 212, 0.12), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(139, 92, 246, 0.1), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.05), transparent 60%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  direction: rtl;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: rgba(14, 23, 42, 0.5);
}
::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.4);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

/* =========================================================
   HEADER & NAVIGATION
   ========================================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: rgba(7, 13, 25, 0.85);
  border-bottom: 1px solid var(--card-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Brand Section */
.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  cursor: pointer;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
  box-shadow: 0 0 20px var(--accent-cyan-glow);
  position: relative;
  z-index: 2;
}

.logo-pulse-ring {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 2px solid var(--accent-cyan);
  animation: pulse-ring 2.5s infinite;
  z-index: 1;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-logo {
  font-family: var(--font-latin);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #38bdf8 0%, #22c55e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-ar {
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  font-weight: 800;
  color: #f1f5f9;
  -webkit-text-fill-color: #f1f5f9;
  background: none;
}

.brand-tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Nav Portal Tabs */
.portal-nav {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.9);
  padding: 0.3rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--card-border);
  gap: 0.35rem;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-arabic);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  transition: var(--transition-normal);
  position: relative;
}

.nav-tab i {
  font-size: 1rem;
}

.nav-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(16, 185, 129, 0.25));
  color: #fff;
  border: 1px solid var(--card-border-glow);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.2);
}

.pulse-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

.badge-count {
  background: var(--accent-rose);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.role-badge {
  background: rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.5);
  font-size: 0.65rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  font-family: var(--font-latin);
  font-weight: 700;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.system-status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.system-status-pill.cloudflare-d1-pill {
  background: rgba(246, 130, 31, 0.12);
  border-color: rgba(246, 130, 31, 0.4);
  color: #ff9800;
  font-weight: 600;
  cursor: default;
  transition: all var(--transition-fast);
}
.system-status-pill.cloudflare-d1-pill:hover {
  background: rgba(246, 130, 31, 0.2);
  border-color: rgba(246, 130, 31, 0.7);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.online {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* =========================================================
   PORTALS & LAYOUTS
   ========================================================= */
.app-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: calc(100vh - 80px);
}

.portal-view {
  display: none;
  animation: fadeIn 0.35s ease;
}

.portal-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Generic Glass Card */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: var(--transition-normal);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* =========================================================
   PORTAL 1: PATIENT INTERFACE
   ========================================================= */
.patient-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  height: calc(100vh - 125px);
  min-height: 620px;
}

/* Sidebar */
.patient-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  height: 100%;
}

.patient-card {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.patient-card-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.avatar-large {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(16, 185, 129, 0.3));
  border: 1px solid var(--card-border-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--accent-cyan);
}

.patient-info-summary h3 {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
}

.gender-pill {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  margin-top: 0.2rem;
}

.patient-contact-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.75rem;
  border-radius: var(--radius-md);
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.detail-row i {
  color: var(--accent-cyan);
  width: 16px;
  text-align: center;
}

/* Doctor Call Card (Action Banner) */
.doctor-call-card {
  padding: 1.25rem;
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.call-banner-icon {
  width: 48px;
  height: 48px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin: 0 auto;
}

.call-text h4 {
  font-size: 1.05rem;
  color: #fff;
  margin-bottom: 0.25rem;
}

.call-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-emergency {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 0.85rem 1.2rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  transition: var(--transition-normal);
}

.btn-emergency:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.6);
}

.call-features-list {
  display: flex;
  justify-content: center;
  gap: 0.85rem;
  font-size: 0.72rem;
  color: #a7f3d0;
}

/* AI Status Card */
.ai-status-card {
  padding: 1rem;
  margin-top: auto;
}

.card-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
}

.ai-active-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
}

.ai-active-pill i {
  color: var(--accent-purple);
  font-size: 1.2rem;
}

.ai-badge-text {
  display: flex;
  flex-direction: column;
}

.ai-badge-text strong {
  font-size: 0.85rem;
  color: #e2e8f0;
}

.ai-badge-text small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Center Chat Container */
.patient-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--card-border);
}

.chat-header {
  padding: 1rem 1.5rem;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.chat-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.bot-status-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(139, 92, 246, 0.25));
  border: 1px solid var(--card-border-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  font-size: 1.25rem;
}

.live-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: var(--accent-emerald);
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
}

.chat-title-group h2 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.chat-title-group p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0 0.65rem;
}

.select-wrapper i {
  color: var(--accent-cyan);
  font-size: 0.85rem;
  margin-left: 0.45rem;
}

.select-wrapper select {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-arabic);
  font-size: 0.82rem;
  padding: 0.45rem 0.3rem;
  cursor: pointer;
  outline: none;
}

.select-wrapper select option {
  background: var(--bg-secondary);
  color: #fff;
}

/* Chat Messages */
.chat-messages-area {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.message-wrapper {
  display: flex;
  gap: 0.75rem;
  max-width: 82%;
  animation: fadeIn 0.25s ease;
}

.message-wrapper.patient {
  align-self: flex-start; /* in RTL, patient message appears on right */
  flex-direction: row;
}

.message-wrapper.bot, .message-wrapper.doctor {
  align-self: flex-end; /* in RTL, bot message on left */
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.message-wrapper.patient .msg-avatar {
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.4);
}

.message-wrapper.bot .msg-avatar {
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.message-wrapper.doctor .msg-avatar {
  background: rgba(16, 185, 129, 0.25);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.msg-bubble {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--card-border);
  padding: 0.9rem 1.15rem;
  border-radius: var(--radius-lg);
  position: relative;
  box-shadow: var(--shadow-sm);
}

.message-wrapper.patient .msg-bubble {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(15, 23, 42, 0.9));
  border-color: rgba(6, 182, 212, 0.3);
  border-top-right-radius: 4px;
}

.message-wrapper.bot .msg-bubble {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(139, 92, 246, 0.3);
  border-top-left-radius: 4px;
}

.message-wrapper.doctor .msg-bubble {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(15, 23, 42, 0.95));
  border-color: rgba(16, 185, 129, 0.4);
  border-top-left-radius: 4px;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.msg-sender-name {
  font-weight: 700;
  color: #e2e8f0;
}

.msg-model-tag {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
}

.msg-text {
  font-size: 0.94rem;
  line-height: 1.65;
  color: #f1f5f9;
  white-space: pre-line;
}

.msg-media-preview {
  margin-top: 0.65rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 320px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
}

.msg-media-preview img, .msg-media-preview video {
  width: 100%;
  display: block;
  max-height: 220px;
  object-fit: cover;
}

.msg-voice-note {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-msg-audio {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition-fast);
}

.btn-msg-audio:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
}

/* Attachment Preview Bar */
.attachment-preview-bar {
  padding: 0.65rem 1.5rem;
  background: rgba(2, 6, 23, 0.9);
  border-top: 1px solid var(--card-border);
}

.preview-item {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
}

.preview-details {
  display: flex;
  flex-direction: column;
}

.preview-details .file-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
}

.preview-details .file-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-close-preview {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
}

/* Chat Input Bar */
.chat-input-wrapper {
  padding: 1rem 1.5rem;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

/* Attachment Menu & (+) Button */
.attachment-menu-container {
  position: relative;
}

.btn-plus {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--accent-cyan);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-normal);
}

.btn-plus:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
  transform: rotate(90deg);
}

.attachment-dropdown {
  position: absolute;
  bottom: 55px;
  right: 0;
  width: 250px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}

.attachment-dropdown.active {
  display: flex;
}

.attachment-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: right;
  transition: var(--transition-fast);
  color: var(--text-main);
  width: 100%;
}

.attachment-option:hover {
  background: rgba(255, 255, 255, 0.07);
}

.opt-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.img-icon { background: rgba(6, 182, 212, 0.2); color: var(--accent-cyan); }
.vid-icon { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); }
.mic-icon { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); }
.doc-icon { background: rgba(245, 158, 11, 0.2); color: var(--accent-amber); }

.opt-label strong {
  display: block;
  font-size: 0.85rem;
}

.opt-label small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Text Input Field */
.text-input-field {
  flex: 1;
  background: rgba(2, 6, 23, 0.75);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: 0.5rem 1.15rem;
  display: flex;
  align-items: center;
  transition: var(--transition-normal);
}

.text-input-field:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 14px var(--accent-cyan-glow);
}

.text-input-field textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-arabic);
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
}

/* Mic & Send Buttons */
.btn-mic, .btn-send {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: var(--transition-normal);
}

.btn-mic {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}

.btn-mic:hover {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

.btn-mic.recording {
  background: var(--accent-rose);
  color: #fff;
  animation: pulse-ring 1.2s infinite;
}

.btn-send {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald));
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-cyan-glow);
}

.btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px var(--accent-cyan-glow);
}

/* =========================================================
   PORTAL 2: DOCTOR INTERFACE
   ========================================================= */
.doctor-dashboard-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: calc(100vh - 120px);
}

.doctor-header-bar {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.doctor-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.doc-avatar {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(6, 182, 212, 0.3));
  border: 1px solid rgba(16, 185, 129, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-emerald);
  font-size: 1.35rem;
}

.specialty-badge {
  font-size: 0.75rem;
  color: var(--accent-emerald);
}

.doctor-kpi-bar {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.kpi-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.kpi-num {
  font-size: 1.45rem;
  font-weight: 800;
  font-family: var(--font-latin);
  color: #fff;
  line-height: 1.1;
}

.kpi-num.highlight {
  color: var(--accent-amber);
}

.kpi-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Split Columns */
.doctor-main-split {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  height: calc(100vh - 235px);
  min-height: 580px;
}

/* Directory Sidebar */
.patient-directory-sidebar {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.directory-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.directory-header h3 {
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-input-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid var(--card-border);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-md);
}

.search-input-box i {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.search-input-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-arabic);
  font-size: 0.85rem;
  width: 100%;
}

.patients-scroll-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 0.25rem;
}

.patient-list-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.patient-list-card:hover {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(6, 182, 212, 0.4);
}

.patient-list-card.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(16, 185, 129, 0.1));
  border-color: var(--accent-cyan);
}

.plc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.plc-header strong {
  font-size: 0.95rem;
  color: #fff;
}

.plc-time {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.plc-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.plc-complaint {
  font-size: 0.76rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Active Consultation Container */
.doctor-active-consultation {
  padding: 1.25rem;
  height: 100%;
  overflow: hidden;
}

.empty-state-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-dim);
  gap: 1rem;
}

.empty-state-view i {
  font-size: 3.5rem;
  color: rgba(255, 255, 255, 0.1);
}

.consultation-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--card-border);
}

.patient-banner-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.patient-avatar-mini {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.tags-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}

.info-tag {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.initial-complaint-box {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
}

.box-badge {
  font-size: 0.78rem;
  color: var(--accent-cyan);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.initial-complaint-box p {
  font-size: 0.88rem;
  color: #e2e8f0;
}

/* History Tabs */
.patient-history-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

.tab-pill {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-arabic);
  font-size: 0.85rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tab-pill.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #fff;
}

.patient-tab-content-container {
  flex: 1;
  overflow-y: auto;
  min-height: 180px;
}

.ptab-content {
  display: none;
  height: 100%;
}

.ptab-content.active {
  display: block;
}

.chat-transcript-view {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-right: 0.5rem;
}

/* Doctor Reply Box (مكان الرد) */
.doctor-reply-box {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.reply-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reply-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-emerald);
}

.quick-phrases {
  display: flex;
  gap: 0.45rem;
}

.badge-phrase {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-family: var(--font-arabic);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
}

.badge-phrase:hover {
  background: rgba(6, 182, 212, 0.15);
  color: #fff;
}

.reply-input-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.reply-input-row textarea {
  flex: 1;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  color: #fff;
  font-family: var(--font-arabic);
  font-size: 0.9rem;
  resize: none;
}

.btn-reply {
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 52px;
}

/* =========================================================
   PORTAL 3: ADMIN / MANAGER INTERFACE
   ========================================================= */
.admin-dashboard-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-header-bar {
  padding: 1.25rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-shield {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(244, 63, 94, 0.3));
  border: 1px solid rgba(139, 92, 246, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c4b5fd;
  font-size: 1.5rem;
}

.admin-title-group h2 {
  font-size: 1.35rem;
  font-weight: 800;
}

.admin-title-group p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.admin-quick-ctrls {
  display: flex;
  gap: 0.75rem;
}

/* Admin KPI Grid */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

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

.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.patient-stat { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.doctor-stat { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.call-stat { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.db-stat { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 1.85rem;
  font-weight: 800;
  font-family: var(--font-latin);
  line-height: 1.1;
  color: #fff;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Admin Sub Tabs */
.admin-tabs-nav {
  display: flex;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.35rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
}

.admin-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-arabic);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  transition: var(--transition-fast);
}

.admin-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
}

.admin-subview {
  display: none;
}

.admin-subview.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

.section-card {
  padding: 1.5rem;
}

.card-action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-action-header h3 {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.card-action-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.88rem;
}

.data-table th {
  background: rgba(2, 6, 23, 0.6);
  color: var(--text-muted);
  padding: 0.85rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--card-border);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.password-cell {
  font-family: monospace;
  direction: ltr;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.btn-toggle-eye {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
}

/* Manager Security Card */
.manager-sec-card {
  max-width: 750px;
}

.manager-password-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.security-status-box {
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.82rem;
  color: #93c5fd;
}

/* =========================================================
   CALL INTERFACE MODAL (اتصال بالدكتور)
   ========================================================= */
.call-dialog {
  width: 95%;
  max-width: 600px;
  background: #020617;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  border: 1px solid var(--card-border);
}

.call-screen {
  display: flex;
  flex-direction: column;
  height: 480px;
}

.call-video-canvas {
  flex: 1;
  background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.call-doctor-avatar {
  position: relative;
  margin-bottom: 1.5rem;
}

.call-doctor-avatar .avatar-box {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  color: #fff;
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.5);
  position: relative;
  z-index: 2;
}

.pulse-ring-outer {
  position: absolute;
  top: -20px;
  right: -20px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 2px solid var(--accent-emerald);
  animation: call-pulse 1.8s infinite;
  z-index: 1;
}

@keyframes call-pulse {
  0% { transform: scale(0.85); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

.call-status-indicator {
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
}

.call-timer {
  font-family: var(--font-latin);
  font-size: 1.25rem;
  color: var(--accent-emerald);
  margin-top: 0.35rem;
  font-weight: 700;
}

.self-video-pip {
  position: absolute;
  bottom: 1.25rem;
  left: 1.25rem;
  width: 90px;
  height: 120px;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.call-controls-row {
  background: #090d16;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  border-top: 1px solid var(--card-border);
}

.call-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: var(--transition-normal);
}

.btn-mute, .btn-video {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-mute.active, .btn-video.active {
  background: var(--accent-amber);
  color: #000;
}

.btn-hangup {
  background: var(--accent-rose);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.5);
}

.btn-hangup:hover {
  transform: scale(1.18);
}

/* =========================================================
   GENERIC MODALS & FORMS
   ========================================================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-dialog {
  width: 100%;
  max-width: 540px;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-dialog.modal-wide {
  max-width: 820px;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.icon-circle {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.modal-title-wrap h3 {
  font-size: 1.15rem;
}

.modal-title-wrap p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
}

.required {
  color: var(--accent-rose);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

input[type="text"], input[type="email"], input[type="tel"], input[type="password"], select, textarea {
  width: 100%;
  background: rgba(2, 6, 23, 0.75);
  border: 1px solid var(--card-border);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-arabic);
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.field-hint code {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--accent-emerald);
}

/* AI Model Selection Grid in Settings */
.ai-models-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.ai-model-card {
  cursor: pointer;
  position: relative;
}

.ai-model-card input {
  display: none;
}

.ai-model-card .card-inner {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  transition: var(--transition-fast);
}

.ai-model-card input:checked + .card-inner {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(139, 92, 246, 0.15));
  border-color: var(--accent-cyan);
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.3);
}

.model-badge-top {
  font-size: 0.68rem;
  color: var(--accent-cyan);
  font-weight: 700;
  text-transform: uppercase;
}

.ai-model-card strong {
  display: block;
  font-size: 0.95rem;
  margin: 0.2rem 0;
}

.ai-model-card p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Switch */
.toggle-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
}

.toggle-option strong {
  display: block;
  font-size: 0.9rem;
}

.toggle-option small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input { display: none; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  right: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-emerald);
}

input:checked + .slider:before {
  transform: translateX(-22px);
}

/* Common Buttons */
.btn {
  border: none;
  font-family: var(--font-arabic);
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-normal);
  font-size: 0.9rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-cyan-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--accent-cyan-glow);
}

.btn-admin {
  background: linear-gradient(135deg, var(--accent-purple), #6366f1);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-purple-glow);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0 0.5rem;
}

.full-width {
  width: 100%;
}

/* Visitor Detail Modal Components */
.visitor-meta-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: var(--radius-md);
}

.meta-item {
  display: flex;
  flex-direction: column;
}

.m-label {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.meta-item strong {
  font-size: 0.88rem;
  color: #fff;
}

.complaint-display-box {
  background: rgba(255, 255, 255, 0.04);
  padding: 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: #e2e8f0;
}

.timeline-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  padding-right: 1.5rem;
}

.timeline-container::before {
  content: "";
  position: absolute;
  top: 5px;
  right: 6px;
  bottom: 5px;
  width: 2px;
  background: var(--card-border);
}

.timeline-node {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.timeline-node::before {
  content: "";
  position: absolute;
  top: 6px;
  right: -1.5rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.timeline-time {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.timeline-desc {
  font-size: 0.85rem;
  color: #f1f5f9;
}

/* Media Gallery */
.media-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
}

.media-thumbnail-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.media-thumbnail-card img, .media-thumbnail-card video {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.media-card-info {
  padding: 0.5rem;
}

.media-card-info strong {
  display: block;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-card-info small {
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* Auth Gate Views */
.auth-gate {
  max-width: 480px;
  margin: 3rem auto;
  padding: 2.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 1.25rem;
}

.doctor-icon { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); }
.admin-icon { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); }

.auth-gate h2 {
  font-size: 1.35rem;
  margin-bottom: 0.45rem;
}

.auth-gate p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: right;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  animation: slideInLeft 0.3s ease;
}

.toast.success { border-color: var(--accent-emerald); }
.toast.info { border-color: var(--accent-cyan); }
.toast.warning { border-color: var(--accent-amber); }
.toast.error { border-color: var(--accent-rose); }

@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .patient-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  .doctor-main-split {
    grid-template-columns: 1fr;
    height: auto;
  }
  .patient-sidebar {
    height: auto;
  }
}

@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: stretch;
  }
  .portal-nav {
    overflow-x: auto;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .admin-stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* AI Live Typing / Thinking Indicator */
.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.65rem 1rem;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-md);
  color: var(--accent-cyan);
  font-size: 0.88rem;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.1);
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--accent-cyan);
  border-radius: 50%;
  display: inline-block;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.3);
    opacity: 0.3;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Approval Alert Banner for Admin */
.approval-alert-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.4rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.15);
  animation: slideInDown 0.3s ease;
}

.approval-alert-banner .banner-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.approval-alert-banner .banner-icon {
  width: 42px;
  height: 42px;
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.approval-alert-banner p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

/* Doctor Pending Approval Box */
.pending-approval-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  margin: 1.25rem 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pib-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 0.5rem;
}

.pib-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.pib-label {
  color: var(--text-muted);
}

.pending-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.pulse-glow-amber {
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.35) !important;
  color: var(--accent-amber) !important;
}

.pulse-glow-cyan {
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.35) !important;
  color: var(--accent-cyan) !important;
}

/* Status Tags */
.status-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
}

.status-tag.pending {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-tag.approved {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-tag.rejected {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Auth Mode Switcher */
.auth-mode-toggle button.active {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald)) !important;
  color: #fff !important;
  border-color: transparent !important;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.35);
}

.candidate-summary-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

