/* ==============================================================
   Patients CRM - Claude-inspired Design
   ============================================================== */

/* ⚠️ AI/LLM ARCHITECTURE RULE:
   This file = SHARED styles only (design tokens, common components).
   
   For TAB-SPECIFIC styles (50+ lines, unique components, complex layout):
   → Create: [tab-name]-tab.css (e.g., details-tab.css, calendar-tab.css)
   → Don't bloat this file with tab-specific code!
   
   Use CSS variables below - don't hardcode colors/spacing.
   ============================================================== */

:root {
  /* Colors - Claude-like palette */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-hover: #f0f1f3;
  
  --text-primary: #1a1a1a;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  
  --border-color: #e5e7eb;
  --border-light: #f0f0f0;
  
  --accent-primary: #d97706;
  --accent-hover: #b45309;
  --accent-light: #fef3c7;
  
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  
  /* Spacing */
  --header-height: 64px;
  --tabs-height: 52px;
  
  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
}

/* =========== Reset & Base =========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  direction: rtl;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* =========== Login Screen =========== */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-screen.hidden {
  display: none;
}

.login-box {
  background: var(--bg-primary);
  padding: 48px 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  width: 90%;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 16px;
}

.login-box h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-box p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-box input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 18px;
  text-align: center;
  letter-spacing: 8px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.login-box input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1);
}

.login-box button {
  width: 100%;
  padding: 14px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.login-box button:hover {
  background: var(--accent-hover);
}

.login-error {
  color: var(--error);
  font-size: 14px;
  margin-top: 16px;
  display: none;
}

.login-error.visible {
  display: block;
}

/* =========== App Container =========== */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========== Header =========== */
.app-header {
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  font-size: 28px;
}

.app-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.refresh-all-btn {
  background: none;
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.refresh-all-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-tertiary);
}

/* =========== Patient Search =========== */
.patient-search-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
}

.patient-search {
  position: relative;
  width: 320px;
}

.patient-search input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: all var(--transition-fast);
  background: var(--bg-secondary);
}

.patient-search input:focus {
  background: var(--bg-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1);
}

.patient-search .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}

.search-results.visible {
  display: block;
}

.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-light);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg-hover);
}

.search-result-item .patient-result-name {
  font-weight: 500;
  color: var(--text-primary);
}

.search-result-item .patient-result-phone {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.search-no-results {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.search-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* Selected Patient */
.selected-patient {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--accent-light);
  border-radius: 8px;
  border: 1px solid var(--accent-primary);
}

.selected-patient .patient-name {
  font-weight: 600;
  color: var(--accent-hover);
  font-size: 14px;
}

.selected-patient .clear-patient {
  background: none;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.selected-patient .clear-patient:hover {
  background: rgba(217, 119, 6, 0.2);
}

/* =========== App Launcher - Microsoft 365 Style =========== */
.app-launcher-wrapper {
  position: relative;
}

.app-launcher-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.app-launcher-btn:hover {
  background: var(--bg-tertiary);
}

/* 3x3 Grid of dots - Microsoft style */
.hamburger-icon {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: 18px;
  height: 18px;
}

.hamburger-icon::before,
.hamburger-icon::after,
.hamburger-icon span {
  display: none;
}

/* Create 9 dots using pseudo-elements and background */
.app-launcher-btn .hamburger-icon {
  background-image: 
    radial-gradient(circle, var(--text-secondary) 2px, transparent 2px);
  background-size: 6px 6px;
  background-position: 0 0;
}

/* Dropdown Panel - Microsoft 365 Style */
.app-launcher-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  overflow: hidden;
}

.app-launcher-dropdown.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.app-launcher-header {
  padding: 16px 20px 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}

.app-launcher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 12px;
}

.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.app-item:hover {
  background: var(--bg-tertiary);
}

.app-item:active {
  transform: scale(0.96);
}

.app-item .app-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-radius: 8px;
  color: white;
}

.app-item .app-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.3;
}

/* =========== Main Content =========== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* =========== Empty State =========== */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 16px;
}

/* =========== Patient Portal =========== */
.patient-portal {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

/* =========== Tabs Navigation =========== */
.tabs-nav {
  display: flex;
  gap: 4px;
  padding: 12px 24px 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: var(--bg-primary);
}

.tab-btn .tab-icon {
  font-size: 16px;
}

/* =========== Tab Panels =========== */
.tab-panels {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.refresh-btn {
  background: none;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.refresh-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* =========== Summaries Container =========== */
.summaries-container {
  display: flex;
  gap: 24px;
  height: 100%;
}

.session-tabs {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  padding-left: 24px;
  overflow-y: auto;
}

.session-tab-item {
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.session-tab-item:hover {
  background: var(--bg-hover);
}

.session-tab-item.active {
  background: var(--accent-light);
  border-color: var(--accent-primary);
}

.session-tab-item .session-date {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 2px;
}

.session-tab-item .session-type {
  font-size: 12px;
  color: var(--text-secondary);
}

.session-content {
  flex: 1;
  min-width: 0;
}

.select-session-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  text-align: center;
}

.select-session-prompt .prompt-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.summary-display {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 24px;
}

.summary-display .summary-header {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.summary-display .summary-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.summary-display .summary-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.summary-display .summary-body {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* =========== Markdown Content Styling =========== */
.markdown-content {
  white-space: normal;
}

.markdown-content h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 24px 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.markdown-content h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 20px 0 12px 0;
}

.markdown-content h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 16px 0 10px 0;
}

.markdown-content p {
  margin: 0 0 12px 0;
}

.markdown-content ul,
.markdown-content ol {
  margin: 12px 0;
  padding-right: 24px;
}

.markdown-content li {
  margin: 6px 0;
}

.markdown-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-content em {
  font-style: italic;
}

.markdown-content blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-right: 3px solid var(--accent-primary);
  border-radius: 4px;
  color: var(--text-secondary);
}

.markdown-content code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.markdown-content pre {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 16px 0;
}

.markdown-content pre code {
  background: none;
  padding: 0;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 24px 0;
}

.markdown-content a {
  color: var(--accent-primary);
  text-decoration: underline;
}

.markdown-content a:hover {
  color: var(--accent-hover);
}

/* =========== Padlet Container =========== */
.padlet-container {
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.iframe-wrapper {
  width: 100%;
  flex: 1;
  min-height: 0; /* Important for flex children */
  position: relative;
}

/* Force padlet embed to fill container - FIXED with calc instead of 100% */
.iframe-wrapper .padlet-embed,
.iframe-wrapper > div {
  width: 100% !important;
  height: calc(100vh - 220px) !important;
  min-height: 400px !important;
}

.iframe-wrapper .padlet-embed p {
  height: 100% !important;
  margin: 0 !important;
}

.iframe-wrapper iframe {
  width: 100% !important;
  height: 100% !important;
  border: none;
}

/* Hide Padlet footer */
.iframe-wrapper .padlet-embed > div:last-child {
  display: none !important;
}

/* Expand Button */
.panel-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.expand-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 18px;
}

.expand-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.expand-btn .expand-icon {
  transition: transform 0.2s ease;
}

/* New Tab Button */
.new-tab-btn {
  background: none;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.new-tab-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

/* Copy Link Button */
.copy-link-btn {
  background: none;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.copy-link-btn:hover {
  background: var(--accent-light);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Expanded Mode */
.padlet-expanded {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: var(--bg-primary);
  padding: 0 !important;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.padlet-expanded .iframe-wrapper {
  flex: 1;
  height: auto !important;
  min-height: auto !important;
}

.padlet-expanded .iframe-wrapper .padlet-embed,
.padlet-expanded .iframe-wrapper > div,
.padlet-expanded .iframe-wrapper .padlet-embed p,
.padlet-expanded .iframe-wrapper iframe {
  height: 100% !important;
  min-height: 100% !important;
}

.padlet-expanded-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.padlet-expanded-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.padlet-close-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.padlet-close-btn:hover {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

/* ============== Reminders Container ============== */
.reminders-container {
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.reminders-container .iframe-wrapper {
  width: 100%;
  flex: 1;
  min-height: 0;
  position: relative;
}

.reminders-container .iframe-wrapper iframe {
  width: 100% !important;
  height: calc(100vh - 220px) !important;
  min-height: 400px !important;
  border: none;
  border-radius: 8px;
}

/* Reminders Expanded Mode */
.reminders-expanded {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: var(--bg-primary);
  padding: 0 !important;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.reminders-expanded .iframe-wrapper {
  flex: 1;
  height: auto !important;
  min-height: auto !important;
}

.reminders-expanded .iframe-wrapper iframe {
  height: 100% !important;
  min-height: 100% !important;
}

.reminders-expanded-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.reminders-expanded-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.reminders-close-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.reminders-close-btn:hover {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

/* ============== Files Container ============== */
.files-container {
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.files-container .iframe-wrapper {
  width: 100%;
  flex: 1;
  min-height: 0;
  position: relative;
}

.files-container .iframe-wrapper iframe {
  width: 100% !important;
  height: calc(100vh - 220px) !important;
  min-height: 400px !important;
  border: none;
  border-radius: 8px;
}

/* Files Expanded Mode */
.files-expanded {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: var(--bg-primary);
  padding: 0 !important;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.files-expanded .iframe-wrapper {
  flex: 1;
  height: auto !important;
  min-height: auto !important;
}

.files-expanded .iframe-wrapper iframe {
  height: 100% !important;
  min-height: 100% !important;
}

.files-expanded-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.files-expanded-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.files-expanded-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.files-close-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.files-close-btn:hover {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

/* =========== Loading & Placeholders =========== */
.loading-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-tertiary);
  font-size: 14px;
}

.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-tertiary);
}

.coming-soon span {
  font-size: 48px;
  margin-bottom: 12px;
}

/* =========== Toast Notifications =========== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

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

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

/* =========== Responsive =========== */
@media (max-width: 768px) {
  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 12px;
  }
  
  .patient-search-wrapper {
    order: 3;
    width: 100%;
  }
  
  .patient-search {
    width: 100%;
  }
  
  .tabs-nav {
    padding: 8px 16px 0;
    overflow-x: auto;
  }
  
  .tab-btn {
    padding: 10px 14px;
    white-space: nowrap;
  }
  
  .tab-btn .tab-label {
    display: none;
  }
  
  .tab-btn .tab-icon {
    font-size: 20px;
  }
  
  .summaries-container {
    flex-direction: column;
  }
  
.session-tabs {
    width: 100%;
    border-left: none;
    border-bottom: 1px solid var(--border-color);
    padding-left: 0;
    padding-bottom: 16px;
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
  }
  
  .session-tab-item {
    flex-shrink: 0;
  }

  .app-launcher-dropdown {
    width: 260px;
    left: auto;
    right: 0;
  }
}

/* =========== RAG Query Tab =========== */
.rag-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0 !important;
}

.rag-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.rag-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  min-height: 300px;
}

.rag-welcome.hidden {
  display: none;
}

.rag-welcome-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent-primary), #b45309);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}

.rag-welcome h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.rag-welcome p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.rag-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 500px;
}

.rag-example {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.rag-example:hover {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

/* RAG Messages */
.rag-message {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease;
}

.rag-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.rag-message.user .rag-message-avatar {
  background: var(--bg-tertiary);
}

.rag-message.assistant .rag-message-avatar {
  background: linear-gradient(135deg, var(--accent-primary), #b45309);
  color: white;
}

.rag-message-content {
  flex: 1;
  min-width: 0;
}

.rag-message-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.rag-message-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
}

.rag-message.user .rag-message-text {
  background: var(--bg-tertiary);
  padding: 12px 16px;
  border-radius: 12px;
  border-top-right-radius: 4px;
  white-space: pre-wrap;
}

/* RAG Sources */
.rag-sources {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.rag-sources-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.rag-sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rag-source-tag {
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.rag-source-tag .patient-name {
  font-weight: 600;
  color: var(--accent-primary);
}

/* RAG Loading */
.rag-loading {
  display: flex;
  gap: 6px;
  padding: 8px 0;
}

.rag-loading span {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: ragBounce 1.4s infinite ease-in-out both;
}

.rag-loading span:nth-child(1) { animation-delay: -0.32s; }
.rag-loading span:nth-child(2) { animation-delay: -0.16s; }

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

/* RAG Input Area */
.rag-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.rag-input-container {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.rag-input-container textarea {
  flex: 1;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  min-height: 60px;
  max-height: 150px;
  transition: border-color 0.2s;
}

.rag-input-container textarea:focus {
  border-color: var(--accent-primary);
}

.rag-send-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.rag-send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.rag-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
