/* ============================================================
   File Inbox - Same design language as Patients CRM
   ============================================================ */

:root {
  /* Colors - Same as CRM */
  --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;
  
  /* 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;
}

html, body {
  height: 100%;
  overflow: hidden;
}

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

/* App Container */
.app-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============ 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;
}

/* ============ 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;
  flex-shrink: 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;
}

/* Source Toggle */
.source-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: 10px;
}

.source-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.source-btn:hover {
  color: var(--text-primary);
}

.source-btn.active {
  background: var(--bg-primary);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

/* ============ 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,
.search-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  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);
}

/* ============ Main Content ============ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

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

.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;
}

/* ============ Source Picker (Small Dropdown) ============ */
.source-picker {
  position: relative;
}

.source-picker-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition-fast);
}

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

.source-picker-icon {
  font-size: 14px;
}

.source-picker-arrow {
  font-size: 10px;
  color: var(--text-tertiary);
}

.source-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  min-width: 160px;
  display: none;
  z-index: 300;
}

.source-picker-dropdown.visible {
  display: block;
}

.source-picker-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.source-picker-option:first-child {
  border-radius: 8px 8px 0 0;
}

.source-picker-option:last-child {
  border-radius: 0 0 8px 8px;
}

.source-picker-option:hover {
  background: var(--bg-hover);
}

.source-picker-option.active {
  background: var(--accent-light);
  color: var(--accent-primary);
}

/* ============ Action Panel ============ */
.action-panel {
  display: flex;
  justify-content: center;
  padding: 40px 24px;
  width: 100%;
}

.fetch-card {
  background: var(--bg-primary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  max-width: 500px;
  width: 100%;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.card-icon {
  font-size: 24px;
}

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

/* Mode Toggle */
.mode-toggle {
  display: flex;
  padding: 16px 24px;
  gap: 8px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn:hover {
  border-color: var(--text-tertiary);
}

.mode-btn.active {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Mode Content */
.mode-content {
  display: none;
  padding: 24px;
}

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

.mode-description {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.fetch-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* ============ View Topbar ============ */
.view-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

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

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

.view-topbar h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Keep old selectors for compatibility */
.quick-action-card,
.manual-action-card {
  display: none;
}

.card-content {
  padding: 24px;
}

.card-content p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.quick-action-controls,
.manual-action-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.message-count-select {
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-primary);
  cursor: pointer;
  outline: none;
}

.message-count-select:focus {
  border-color: var(--accent-primary);
}

/* LLM Toggle */
.llm-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.llm-toggle input {
  display: none;
}

.toggle-slider {
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition-fast);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  right: 3px;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.llm-toggle input:checked + .toggle-slider {
  background: var(--accent-primary);
}

.llm-toggle input:checked + .toggle-slider::after {
  transform: translateX(-20px);
}

.toggle-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.llm-toggle.small .toggle-slider {
  width: 36px;
  height: 20px;
}

.llm-toggle.small .toggle-slider::after {
  width: 14px;
  height: 14px;
}

.llm-toggle.small input:checked + .toggle-slider::after {
  transform: translateX(-16px);
}

/* Buttons */
.primary-btn,
.secondary-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.primary-btn {
  background: var(--accent-primary);
  color: white;
}

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

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

.secondary-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition-fast);
}

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

/* ============ Manual Selection View (Split Screen) ============ */
.manual-selection-view {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 400px;
  grid-template-rows: auto 1fr;
  gap: 0;
  min-height: 0;
}

.manual-selection-view .view-topbar {
  grid-column: 1 / -1;
}

.timeline-panel,
.files-panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.timeline-panel {
  border-radius: 0 0 0 16px;
  margin: 16px 8px 16px 16px;
}

.files-panel {
  border-radius: 0 0 16px 0;
  margin: 16px 16px 16px 8px;
}

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

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

.timeline-controls {
  display: flex;
  gap: 8px;
}

/* Timeline Messages */
.timeline-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.timeline-message {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  transition: background var(--transition-fast);
}

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

.timeline-message.outgoing {
  flex-direction: row-reverse;
}

.timeline-message.outgoing .message-content {
  align-items: flex-end;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.message-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.message-text {
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  padding: 10px 14px;
  border-radius: 12px;
  border-top-right-radius: 4px;
  max-width: 80%;
  word-wrap: break-word;
}

.timeline-message.outgoing .message-text {
  background: var(--accent-light);
  border-top-right-radius: 12px;
  border-top-left-radius: 4px;
}

/* File Message */
.message-file {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
  max-width: 300px;
}

.message-file:hover {
  border-color: var(--accent-primary);
  background: var(--accent-light);
}

.message-file.selected {
  border-color: var(--accent-primary);
  background: var(--accent-light);
}

.file-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.message-file.selected .file-checkbox {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.file-thumbnail {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  overflow: hidden;
  flex-shrink: 0;
}

.file-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Files Panel */
.selected-files-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

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

.no-files-selected span {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.selected-file-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 10px;
  margin-bottom: 8px;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.selected-file-item:hover {
  background: var(--bg-hover);
}

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

.selected-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.selected-file-item .file-thumbnail {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.selected-file-item .file-info {
  flex: 1;
  min-width: 0;
}

.selected-file-item .file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file-item .file-meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

.selected-file-item .remove-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.selected-file-item .remove-btn:hover {
  background: var(--error);
  color: white;
}

/* Name edit in selected file */
.selected-file-name-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.selected-file-name-edit label {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.selected-file-name-edit input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.selected-file-name-edit input:focus {
  border-color: var(--accent-primary);
}

.selected-file-item .file-info {
  flex: 1;
}

.remove-file-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.remove-file-btn:hover {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.files-panel-footer {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  gap: 12px;
}

/* ============ Processing View ============ */
.processing-view {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 0;
  min-height: 0;
}

.processing-view .view-topbar {
  grid-column: 1 / -1;
}

.files-review-panel,
.preview-panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.files-review-panel {
  border-radius: 0 0 0 16px;
  margin: 16px 8px 16px 16px;
}

.preview-panel {
  border-radius: 0 0 16px 0;
  margin: 16px 16px 16px 8px;
}

/* Selection Controls */
.files-selection-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-tertiary);
}

.selection-btn {
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.selected-count-label {
  margin-right: auto;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.files-review-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.file-review-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}

.file-review-item:hover {
  background: var(--bg-hover);
}

.file-review-item.active {
  border-color: var(--accent-primary);
}

.file-review-item.unchecked {
  opacity: 0.5;
}

.file-review-item.unchecked:hover {
  opacity: 0.8;
}

/* Checkbox in review item */
.file-checkbox {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent-primary);
  margin-top: 4px;
}

.file-review-item .file-thumbnail {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.file-review-info {
  flex: 1;
  min-width: 0;
}

.file-original-name {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.file-new-name-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.file-new-name-input:focus {
  border-color: var(--accent-primary);
}

.file-suggested-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.file-suggested-name span {
  font-size: 12px;
  color: var(--text-tertiary);
}

.use-suggestion-btn {
  font-size: 11px;
  padding: 4px 8px;
  background: var(--accent-light);
  color: var(--accent-primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.use-suggestion-btn:hover {
  background: var(--accent-primary);
  color: white;
}

/* File Name Row */
.file-name-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.file-name-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* File Actions Row */
.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Panel Header Actions */
.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.suggest-all-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-light);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.suggest-all-btn:hover {
  background: var(--accent-primary);
  color: white;
}

/* Suggest Name Button */
.suggest-name-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: 8px;
}

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

/* Reset Name Button */
.reset-name-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 8px;
  background: none;
  color: var(--text-tertiary);
  border: none;
  cursor: pointer;
  margin-right: 8px;
}

.reset-name-btn:hover {
  color: var(--text-secondary);
}

/* Loading Suggestion */
.file-loading-suggestion {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
  animation: pulse 1.5s infinite;
}

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

/* Preview Panel */
.preview-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
}

.no-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-tertiary);
  text-align: center;
}

.no-preview span {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.preview-image {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.preview-pdf {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
}

/* ============ Lightbox ============ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 40px;
}

.lightbox.visible {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  left: 0;
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
}

#lightboxImage {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
}

/* ============ 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);
}

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

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .manual-selection-view {
    grid-template-columns: 1fr;
  }
  
  .processing-view {
    grid-template-columns: 1fr;
  }
  
  .files-panel,
  .preview-panel {
    max-height: 400px;
  }
}

@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%;
  }
  
  .action-panel {
    grid-template-columns: 1fr;
  }
  
  .source-toggle {
    order: 2;
  }
}


/* ============ Email Messages ============ */
.email-message {
  background: linear-gradient(135deg, #e8f4fc 0%, #f0f8ff 100%);
  border-right: 3px solid #2196F3;
}

.email-subject {
  font-weight: 600;
  color: #1565C0;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.email-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.1);
}

.email-attachment {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.email-attachment:hover {
  background: #e3f2fd;
  border-color: #2196F3;
}

.email-attachment.selected {
  background: #bbdefb;
  border-color: #1976D2;
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.3);
}

.attachment-icon {
  font-size: 1rem;
}

.attachment-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-size {
  color: #666;
  font-size: 0.75rem;
}



/* ============ Email Attachments Header ============ */
.email-attachments-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.1);
}

.attachments-label {
  font-size: 0.85rem;
  color: #666;
  font-weight: 500;
}

.select-all-email-btn {
  padding: 4px 10px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.select-all-email-btn:hover {
  background: #e3f2fd;
  border-color: #2196F3;
}

.select-all-email-btn.all-selected {
  background: #c8e6c9;
  border-color: #4CAF50;
  color: #2E7D32;
}

/* ============ Email Attachment Checkbox ============ */
.attachment-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid #ccc;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
  background: white;
  transition: all 0.2s;
}

.email-attachment.selected .attachment-checkbox {
  background: #4CAF50;
  border-color: #4CAF50;
}

.email-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.email-attachment:hover {
  background: #e3f2fd;
  border-color: #2196F3;
  transform: translateY(-1px);
}

.email-attachment.selected {
  background: #e8f5e9;
  border-color: #4CAF50;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* ============ Email without attachments ============ */
.email-message.no-attachments {
  opacity: 0.8;
  background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
  border-right-color: #9e9e9e;
}

.email-message.has-attachments {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border-right-color: #4CAF50;
}



/* ============ Filter Panel (in timeline) ============ */
.filter-btn {
  position: relative;
}

.filter-btn.active {
  background: #1976D2;
  color: white;
}

.filter-panel {
  background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
  border-bottom: 1px solid #ddd;
  padding: 12px 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-label {
  font-size: 0.85rem;
  color: #666;
  min-width: 60px;
  font-weight: 500;
}

.filter-buttons {
  display: flex;
  gap: 8px;
}

.filter-option {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.filter-option:hover {
  background: #e3f2fd;
  border-color: #2196F3;
}

.filter-option.active {
  background: #1976D2;
  color: white;
  border-color: #1976D2;
}

.filter-select {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  background: white;
}

.filter-select.small {
  max-width: 150px;
}

.filter-input {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  flex: 1;
  direction: ltr;
  text-align: left;
}

.filter-input:disabled {
  background: #f5f5f5;
  color: #999;
}

.additional-email-row {
  display: flex;
  gap: 8px;
  flex: 1;
}

.filter-actions {
  justify-content: space-between;
  margin-top: 5px;
  padding-top: 10px;
  border-top: 1px solid #ddd;
}

.filter-apply-btn {
  padding: 8px 16px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

.filter-apply-btn:hover {
  background: #43A047;
}

.filter-stats {
  font-size: 0.85rem;
  color: #666;
}


/* ============ Filter Button with Text ============ */
.filter-btn-with-text {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.filter-btn-with-text:hover {
  background: #e3f2fd;
  border-color: #2196F3;
}

.filter-btn-with-text.active {
  background: #1976D2;
  color: white;
  border-color: #1565C0;
}

.filter-btn-with-text .filter-icon {
  font-size: 1rem;
}

.filter-btn-with-text .filter-text {
  font-weight: 500;
}


/* ============ Email Preview Placeholder ============ */
.no-preview.email-preview {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border: 2px dashed #1976D2;
}

.no-preview.email-preview span {
  font-size: 4rem;
  margin-bottom: 15px;
}

.no-preview .file-name {
  font-weight: 600;
  color: #1565C0;
  margin: 10px 0;
  word-break: break-all;
}

.no-preview .preview-note {
  font-size: 0.85rem;
  color: #666;
  margin-top: 15px;
  line-height: 1.5;
}


/* ============ Preview Loading ============ */
.preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
  color: #666;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e0e0e0;
  border-top-color: #1976D2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.no-preview.error {
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
  border-color: #f44336;
}

.no-preview.error span {
  color: #d32f2f;
}

.download-btn {
  display: inline-block;
  margin-top: 15px;
  padding: 10px 20px;
  background: #1976D2;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: background 0.2s;
}

.download-btn:hover {
  background: #1565C0;
}
