* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Light mode colors */
  --primary: #95e0ff;
  --primary-dark: #2bc0ff;
  --primary-light: #caf0ff;
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --border: #e2e8f0;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* Loading screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.loading-logo {
  height: 48px;
  width: auto;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

.container {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.logo {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.logo img {
  max-width: 100%;
  height: auto;
  max-height: 50px;
}

.user-section {
  margin-bottom: 1.5rem;
}

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: 8px;
  font-size: 0.875rem;
}

.patients-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.patients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.patients-header h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0;
}

.btn-add-patient {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-add-patient:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.patients-search {
  margin-bottom: 0.5rem;
  position: relative;
}

.patients-search input {
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.patients-search input:focus {
  outline: none;
  border-color: var(--primary);
}

.patients-search input::placeholder {
  color: var(--text-muted);
}

.btn-clear-search {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: var(--text-muted);
  color: white;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-clear-search:hover {
  opacity: 1;
}

.patients-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.patient-item {
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 0.25rem;
  transition: background 0.2s;
}

.patient-item:hover {
  background: var(--bg-card);
}

.patient-item.active {
  background: var(--primary);
}

.patient-item-name {
  font-weight: 500;
}

.patient-item-id {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.patient-item.active .patient-item-id {
  color: var(--text-muted);
}

/* General chat section */
.general-chat-section {
  margin-bottom: 1rem;
}

/* General chat styling */
.patient-item.general-chat {
  background: var(--bg-input);
}

.general-chat-icon {
  vertical-align: -2px;
  margin-right: 6px;
  color: var(--primary-dark);
}

.patient-item.general-chat:hover {
  background: var(--primary-light);
}

.patient-item.general-chat.active {
  background: var(--primary);
}

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

/* Login screen */
.login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.login-box h2 {
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.login-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 1rem;
  text-align: center;
}

/* Auth views */
.auth-view {
  animation: fadeIn 0.2s ease;
}

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

/* SSO Button */
.btn-sso {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--text);
  color: white;
  border: none;
  padding: 0.875rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-sso:hover {
  background: #374151;
}

.btn-sso:active {
  transform: scale(0.98);
}

.btn-sso svg {
  flex-shrink: 0;
}

/* Auth divider */
.auth-divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  color: var(--text-dim);
  font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  padding: 0 1rem;
}

/* Auth links */
.auth-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.25rem;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Verify icon */
.verify-icon {
  font-size: 3rem;
  text-align: center;
  margin: 1.5rem 0;
}

/* Form loading state */
.btn-primary.loading,
.btn-sso.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn-primary.loading::after,
.btn-sso.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spinner 0.6s linear infinite;
}

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

/* Form error state */
.form-group.error input {
  border-color: var(--error);
}

.form-group .error-message {
  color: var(--error);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Alert box */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.alert.error {
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
}

.alert.success {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
}

.alert.info {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

/* Chat screen */
.chat-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.patient-name-wrapper {
  display: flex;
  align-items: center;
}

.patient-info h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.patient-info h2.editable-name {
  cursor: pointer;
  padding: 0.125rem 0.375rem;
  margin: -0.125rem -0.375rem;
  border-radius: 6px;
  transition: background-color 0.15s;
}

.patient-info h2.editable-name:hover {
  background-color: var(--bg-hover);
}

.patient-name-input {
  font-size: 1.25rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.5rem;
  border: 2px solid var(--primary);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  min-width: 150px;
}

.patient-id {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.welcome-message {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
}

.message {
  margin-bottom: 1rem;
  max-width: 80%;
}

.message.user {
  margin-left: auto;
}

.message-content {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
}

.message.user .message-content {
  background: var(--primary);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
  background: var(--bg-input);
  border-bottom-left-radius: 4px;
}

/* Queued messages */
.message.queued .message-content {
  opacity: 0.7;
}

.queued-indicator {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  font-style: italic;
}

.message-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.message.user .message-meta {
  text-align: right;
}

/* Tool calls */
.tool-call {
  font-size: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-family: monospace;
}

.tool-call-name {
  color: var(--warning);
}

/* Chat input */
.chat-input-container {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.queue-indicator {
  padding: 0.5rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--warning);
  color: white;
  border-radius: 6px;
  font-size: 0.875rem;
  text-align: center;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

#chat-form {
  display: flex;
  gap: 0.75rem;
}

#chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 1rem;
  resize: none;
  min-height: 44px;
  max-height: 200px;
}

#chat-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

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

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  width: 100%;
}

.btn-secondary:hover {
  background: var(--bg-card);
}

.btn-small {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-small:hover {
  background: var(--bg-card);
}

/* Icon buttons */
.btn-icon {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-card);
  color: var(--text);
}

/* Chat header actions */
.chat-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Dropdown container */
.dropdown-container {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 100;
  overflow: hidden;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
}

.dropdown-item:hover {
  background: var(--bg-input);
}

.dropdown-item.danger {
  color: var(--error);
}

.dropdown-item.danger:hover {
  background: #fef2f2;
}

.dropdown-item svg {
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* Context menu (right-click) */
.context-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 1000;
  overflow: hidden;
  padding: 0.25rem 0;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 1rem;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
  transition: background-color 0.15s;
}

.context-menu-item:hover {
  background: var(--bg-hover);
}

.context-menu-item.danger {
  color: var(--error);
}

.context-menu-item.danger:hover {
  background: #fef2f2;
}

.context-menu-item svg {
  flex-shrink: 0;
}

/* SVG icons inherit color */
.btn-icon svg {
  display: block;
}

/* Patient item with context menu */
.patient-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.patient-item-menu {
  opacity: 0;
  transition: opacity 0.2s;
  background: transparent;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
}

.patient-item:hover .patient-item-menu {
  opacity: 1;
}

.patient-item-menu:hover {
  color: var(--text);
}

/* History list */
.history-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
}

.history-item:hover {
  background: var(--bg-input);
}

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

.history-item-info {
  flex: 1;
}

.history-item-date {
  font-weight: 500;
  color: var(--text);
}

.history-item-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.history-item-actions {
  display: flex;
  gap: 0.25rem;
}

.empty-history {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.btn-send {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-send:hover {
  background: var(--primary-dark);
}

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

/* Form elements */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.form-group input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.modal-content h3 {
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions button {
  flex: 1;
}

/* Rename modal */
.modal-rename h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.modal-rename .form-group {
  margin-bottom: 1.5rem;
}

.modal-rename .form-group label {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.modal-rename .form-group input {
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-rename .form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.15);
}

/* Files list */
.files-list {
  max-height: 300px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.file-icon {
  font-size: 1.25rem;
}

.file-name {
  flex: 1;
}

.empty-files {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Loading indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

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

/* Streaming message content wrapper */
.message-content-wrapper {
  background: var(--bg-input);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  line-height: 1.5;
}

.message-content-wrapper .message-content {
  display: inline;
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Thinking indicator wrapper - inline with text, always animating */
.thinking-indicator-wrapper {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.5rem;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.1s ease, width 0.1s ease;
}

.thinking-indicator-wrapper.visible {
  opacity: 1;
  width: auto;
}

.thinking-indicator-wrapper .typing-indicator {
  display: inline-flex;
  padding: 0;
  gap: 3px;
}

.thinking-indicator-wrapper .typing-indicator span {
  width: 6px;
  height: 6px;
}

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

/* Markdown in messages */
.message-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.message-content code {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.875rem;
}

.message-content p {
  margin-bottom: 0.5rem;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* Markdown headers */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
  line-height: 1.3;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
  margin-top: 0;
}

.message-content h1 { font-size: 1.5rem; }
.message-content h2 { font-size: 1.25rem; }
.message-content h3 { font-size: 1.1rem; }
.message-content h4 { font-size: 1rem; }

/* Markdown tables */
.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.875rem;
}

.message-content th,
.message-content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.message-content th {
  background: var(--bg-input);
  font-weight: 600;
}

.message-content tr:hover {
  background: var(--bg-hover);
}

/* Markdown lists */
.message-content ul,
.message-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.message-content li {
  margin-bottom: 0.25rem;
}

.message-content li:last-child {
  margin-bottom: 0;
}

/* Markdown blockquote */
.message-content blockquote {
  border-left: 3px solid var(--primary);
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  background: var(--bg-input);
  border-radius: 0 6px 6px 0;
}

/* Markdown hr */
.message-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* Inline code (not in pre) */
.message-content code:not(pre code) {
  background: var(--bg-input);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Mobile header */
.mobile-header {
  display: none;
  padding: 0.75rem 1rem;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 0.75rem;
}

.mobile-header .logo {
  margin: 0;
  padding: 0;
  border: none;
  flex: 1;
}

.mobile-header .logo img {
  max-height: 32px;
}

.btn-menu {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.btn-menu:hover {
  background: var(--bg-input);
}

.btn-back {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text);
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.btn-back:hover {
  background: var(--bg-input);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

/* Toast notifications (replace alerts) */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg-card);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  pointer-events: auto;
  animation: toast-in 0.3s ease;
  max-width: 90vw;
  text-align: center;
}

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

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

.toast.fade-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(1rem);
  }
}

/* Confirm modal (replace browser confirm) */
.confirm-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 1rem;
}

.confirm-modal .modal-content {
  max-width: 320px;
  text-align: center;
}

.confirm-modal h3 {
  margin-bottom: 0.5rem;
}

.confirm-modal p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.confirm-modal .modal-actions {
  margin-top: 0;
}

/* Mobile breakpoint */
@media (max-width: 768px) {
  /* Show mobile header */
  .mobile-header {
    display: flex;
  }

  /* Container becomes vertical */
  .container {
    flex-direction: column;
  }

  /* Sidebar becomes slide-out drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding-top: 1rem;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar .logo {
    display: none;
  }

  /* Main content takes full width */
  .main-content {
    flex: 1;
    width: 100%;
    min-height: 0;
  }

  /* Login adjustments */
  .login-screen {
    padding: 1rem;
  }

  .login-box {
    padding: 1.5rem;
    max-width: 100%;
  }

  /* Chat header */
  .chat-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .chat-header .patient-info {
    flex: 1;
    min-width: 0;
  }

  .chat-header .patient-info h2 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-header .btn-small {
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
  }

  /* Hide button text on mobile, show only icons */
  .chat-header .btn-small span {
    display: none;
  }

  /* Hide desktop-only elements in header when patient not selected */
  .chat-header .header-actions {
    display: flex;
    gap: 0.5rem;
  }

  /* Chat messages */
  .chat-messages {
    padding: 1rem;
  }

  .message {
    max-width: 90%;
  }

  .welcome-message {
    padding: 2rem 1rem;
  }

  /* Chat input */
  .chat-input-container {
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  #chat-form {
    gap: 0.5rem;
  }

  #chat-input {
    padding: 0.625rem 0.875rem;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .btn-send {
    padding: 0.625rem 1rem;
  }

  .btn-send span {
    display: none;
  }

  .btn-send::after {
    content: "➤";
    font-size: 1rem;
  }

  /* Modals */
  .modal {
    padding: 1rem;
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    padding: 1.25rem;
    max-height: 80vh;
    overflow-y: auto;
  }

  /* User info in sidebar */
  .user-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .user-info #user-email {
    word-break: break-all;
  }

  /* Patient items - larger touch targets */
  .patient-item {
    padding: 1rem 0.75rem;
    margin-bottom: 0.5rem;
  }

  /* Buttons - larger touch targets */
  .btn-primary,
  .btn-secondary {
    padding: 0.875rem 1.5rem;
    min-height: 48px;
  }

  /* Show back button when patient selected */
  .btn-back.visible {
    display: flex;
  }
}

/* Small mobile */
@media (max-width: 380px) {
  .chat-header .patient-info h2 {
    font-size: 0.9rem;
  }

  .modal-content {
    padding: 1rem;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions button {
    width: 100%;
  }
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
  .chat-input-container {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .modal {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ==================== ADMIN DASHBOARD ==================== */

.admin-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.admin-section h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.btn-admin-dashboard {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  transition: all 0.2s;
}

.btn-admin-dashboard:hover {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.btn-admin-dashboard svg {
  flex-shrink: 0;
}

/* Dashboard screen */
.dashboard-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.dashboard-header h2 {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dashboard-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 600px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.stat-card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.stat-card-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-card-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.stat-card-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .dashboard-header {
    padding: 1rem;
  }

  .dashboard-header h2 {
    font-size: 1.25rem;
  }

  .dashboard-content {
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
