/* Healthcare Report Automation - Styles */

/* Import design tokens */
@import 'design-tokens.css';

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.6;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

header p {
  opacity: 0.9;
  font-size: 1rem;
}

/* Navigation */
nav {
  background: white;
  padding: 1rem 2rem;
  display: none; /* Hidden by default, shown by JS when authenticated */
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.nav-left {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-right .user-name {
  font-size: 0.9rem;
  color: #666;
}

.nav-right .logout-btn {
  padding: 0.5rem 1rem;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav-right .logout-btn:hover {
  background: #e5e7eb;
}

.nav-btn {
  background: transparent;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  font-weight: 500;
}

.nav-btn:hover {
  background: #f5f5f7;
}

.nav-btn.active {
  background: #667eea;
  color: white;
}

/* Main Content (standalone pages like login) */
main {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Reset main styles when inside app-layout (3-pane layout needs full width) */
.app-layout main,
main:has(.app-layout) {
  max-width: none;
  padding: 0;
  margin: 0;
}

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.card h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #667eea;
}

.card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  color: #333;
}

/* Patient List */
.patient-list {
  display: grid;
  gap: 1rem;
}

.patient-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #f9f9fb;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.patient-card.clickable {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.patient-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  background: #f0f0f5;
}

.patient-info h4 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.patient-info p {
  color: #666;
  font-size: 0.9rem;
}

.patient-stats {
  display: flex;
  gap: 1.5rem;
  text-align: center;
}

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

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: #667eea;
}

.stat-label {
  font-size: 0.85rem;
  color: #666;
}

/* Import Page */
.import-zone {
  border: 2px dashed #667eea;
  border-radius: 12px;
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f9f9fb;
}

.import-zone:hover {
  background: #f0f0f5;
  border-color: #764ba2;
}

.import-zone.dragover {
  background: #e8e8f0;
  border-color: #764ba2;
  border-style: solid;
}

.import-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn:hover {
  background: #5568d3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #6c757d;
}

.btn-secondary:hover {
  background: #5a6268;
}

/* Loading Spinner */
.spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Messages */
.message {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.message.info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.message.warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

/* Hidden file input */
input[type="file"] {
  display: none;
}

/* Status Dashboard - Kanban Layout */
.status-dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.status-column {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.status-column-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border-radius: 8px;
}

.status-column-draft .status-column-header {
  background: #fee;
  border-left: 4px solid #dc3545;
}

.status-column-pending .status-column-header {
  background: #ffe;
  border-left: 4px solid #ffc107;
}

.status-column-ready .status-column-header {
  background: #efe;
  border-left: 4px solid #28a745;
}

.status-column-header .status-icon {
  font-size: 1.5rem;
}

.status-column-header h3 {
  flex: 1;
  font-size: 1.1rem;
  color: #333;
  margin: 0;
}

.status-column-header .status-count {
  background: rgba(0, 0, 0, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.status-column-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 200px;
}

.empty-state {
  text-align: center;
  color: #999;
  padding: 2rem 0;
  font-style: italic;
}

/* Report Card */
.report-card {
  background: #f9f9fb;
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid #667eea;
}

.report-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background: #f0f0f5;
}

.report-card-patient {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #333;
}

.report-card-status {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.report-card-time {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 0.75rem;
}

.report-card-action {
  background: transparent;
  border: 1px solid #667eea;
  color: #667eea;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
  font-weight: 500;
}

.report-card-action:hover {
  background: #667eea;
  color: white;
}

/* Report Timeline */
.report-timeline {
  margin: 1.5rem 0;
  padding: 1rem;
  background: #f9f9fb;
  border-radius: 8px;
}

.timeline-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.timeline-milestone {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.timeline-circle {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.timeline-milestone-complete .timeline-circle {
  color: #28a745;
}

.timeline-milestone-current .timeline-circle {
  color: #667eea;
}

.timeline-milestone-pending .timeline-circle {
  color: #ccc;
}

.timeline-label {
  font-size: 0.85rem;
  color: #666;
  text-align: center;
}

.timeline-date {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.25rem;
}

.timeline-connector {
  flex: 1;
  height: 2px;
  margin: 0 0.5rem 2rem 0.5rem;
}

.timeline-connector-complete {
  background: #28a745;
}

.timeline-connector-pending {
  background: #e0e0e0;
}

/* Responsive */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.5rem;
  }

  nav {
    padding: 0.75rem 1rem;
  }

  main {
    padding: 1rem;
  }

  .patient-card {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .patient-stats {
    width: 100%;
    justify-content: space-around;
  }

  /* Status Dashboard - Stack on mobile */
  .status-dashboard {
    grid-template-columns: 1fr;
  }

  .timeline-label {
    font-size: 0.7rem;
  }

  .timeline-circle {
    font-size: 1.2rem;
  }
}

/* Form Tabs */
.form-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 0;
  padding: 0 1rem;
}

.form-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  color: #666;
  white-space: nowrap;
}

.form-tab:hover {
  color: #667eea;
  background: #f5f5f7;
}

.form-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  background: transparent;
}

/* Navigation Dropdown */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  min-width: 200px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  z-index: 1000;
  padding: 0.5rem 0;
  margin-top: 0.25rem;
}

.nav-dropdown.open .nav-dropdown-content {
  display: block;
}

.nav-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.75rem 1.25rem;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #333;
  transition: background 0.2s;
}

.nav-dropdown-item:hover {
  background: #f5f5f7;
}

.nav-dropdown-item.active {
  background: #667eea;
  color: white;
}

/* Patient Detail Tabs */
.patient-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 1.5rem;
  background: white;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

.patient-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  color: #666;
  white-space: nowrap;
  margin-bottom: -2px;
}

.patient-tab:hover {
  color: #667eea;
  background: #f5f5f7;
}

.patient-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  background: white;
}

.patient-tab-content {
  background: white;
  border-radius: 0 0 12px 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ============================================
   Form Styling (T-1.2)
   ============================================ */

/* Form Group Container */
.form-group {
  margin-bottom: var(--space-6);
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: var(--space-2);
  color: var(--color-gray-700);
}

.form-label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: var(--space-2);
  color: var(--color-gray-700);
}

.required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-help-text {
  font-size: 0.85rem;
  color: var(--color-gray-600);
  margin-top: var(--space-1);
}

/* Form Grid Layout */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

@media (max-width: 768px) {
  .form-grid,
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Inline Form Container */
.inline-form {
  background: var(--color-gray-50, #f9f9fb);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}

.inline-form h4 {
  margin: 0 0 var(--space-4) 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-gray-700);
}

/* Form Inputs */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--color-white);
  transition: var(--transition-fast);
  box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--color-gray-400);
}

.form-group input:disabled,
.form-group textarea:disabled,
.form-group select:disabled {
  background: var(--color-gray-100);
  color: var(--color-gray-400);
  cursor: not-allowed;
}

/* Select Dropdown Arrow */
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px;
  padding-right: 2.5rem;
  appearance: none;
}

/* Textarea */
.form-group textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.form-textarea {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Error State */
.form-group input.error,
.form-group textarea.error,
.form-group select.error {
  border-color: var(--color-danger);
}

.form-group input.error:focus,
.form-group textarea.error:focus,
.form-group select.error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-error {
  font-size: 0.85rem;
  color: var(--color-danger);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ============================================
   Button Variants (T-1.3)
   ============================================ */

/* Enhanced Primary Button */
.btn {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-primary);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled {
  background: var(--color-gray-300);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Secondary Button */
.btn-secondary {
  background: var(--color-white);
  color: var(--color-primary);
  border: 1px solid var(--color-gray-300);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-gray-100);
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
  transform: translateY(-1px);
}

/* Danger Button */
.btn-danger {
  background: var(--color-white);
  color: var(--color-danger);
  border: 1px solid var(--color-gray-300);
}

.btn-danger:hover:not(:disabled) {
  background: #fef2f2;
  border-color: var(--color-danger);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
  transform: translateY(-1px);
}

/* Small Button */
.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: 0.85rem;
  border-radius: var(--radius-md);
}

/* Large Button */
.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: 1.1rem;
}

/* ============================================
   Modal Component (T-1.4)
   ============================================ */

.modal-overlay {
  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: 1000;
  padding: var(--space-4);
  backdrop-filter: blur(2px);
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-gray-900);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--color-gray-600);
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  transition: var(--transition-fast);
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: var(--color-gray-900);
  background: var(--color-gray-100);
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  padding: var(--space-6);
  border-top: 1px solid var(--color-gray-200);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* Responsive Modal */
@media (max-width: 768px) {
  .modal-overlay {
    padding: var(--space-2);
  }

  .modal {
    max-height: 95vh;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--space-4);
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

/* ============================================
   Table Styling (Phase 2 - T-1.1)
   ============================================ */

/* Table Container - Enables horizontal scroll on mobile */
.table-container {
  width: 100%;
  overflow-x: auto;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Base Table */
.table-container table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

/* Table Header */
.table-container thead {
  background: var(--color-gray-50);
  border-bottom: 2px solid var(--color-gray-200);
}

.table-container th {
  padding: var(--space-4) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-gray-700);
  white-space: nowrap;
}

/* Table Body */
.table-container tbody tr {
  border-bottom: 1px solid var(--color-gray-200);
  transition: var(--transition-fast);
}

.table-container tbody tr:hover {
  background: var(--color-gray-50);
}

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

.table-container td {
  padding: var(--space-4) var(--space-4);
  color: var(--color-gray-700);
  vertical-align: middle;
}

/* Table Empty State */
.table-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-gray-400);
  font-style: italic;
}

/* Direct .table class (for tables without .table-container wrapper) */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table thead {
  background: var(--color-gray-50);
  border-bottom: 2px solid var(--color-gray-200);
}

.table th {
  padding: var(--space-4) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-gray-700);
  white-space: nowrap;
}

.table tbody tr {
  border-bottom: 1px solid var(--color-gray-200);
  transition: var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--color-gray-50);
}

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

.table td {
  padding: var(--space-4) var(--space-4);
  color: var(--color-gray-700);
  vertical-align: middle;
}

.table-cell--bold {
  font-weight: 600;
  color: var(--color-gray-900);
}

/* Table Alignment Utilities */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

/* Table Action Buttons Container */
.table-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* ============================================
   Badge Styling (Phase 2 - T-1.2, T-1.3, T-1.4)
   ============================================ */

/* Base Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 9999px;
  white-space: nowrap;
  line-height: 1.4;
}

/* Badge Size Variants */
.badge-sm {
  padding: 2px var(--space-2);
  font-size: 0.7rem;
}

.badge-lg {
  padding: var(--space-2) var(--space-4);
  font-size: 0.9rem;
}

/* Badge Status Variants */
.badge-active {
  background: #dcfce7;
  color: #166534;
}

.badge-warning {
  background: #fef9c3;
  color: #854d0e;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-neutral {
  background: var(--color-gray-100);
  color: var(--color-gray-600);
}

/* Report Status Badges (T-1.3) */
.badge-draft {
  background: var(--color-gray-100);
  color: var(--color-gray-600);
}

.badge-pending {
  background: #fef9c3;
  color: #854d0e;
}

.badge-completed {
  background: #dcfce7;
  color: #166534;
}

.badge-submitted {
  background: #dcfce7;
  color: #166534;
}

/* Collaborator Type Badges (T-1.4) */
.badge-psychiatrist {
  background: #f3e8ff;
  color: #6b21a8;
}

.badge-referring {
  background: #dbeafe;
  color: #1e40af;
}

.badge-gp {
  background: #dcfce7;
  color: #166534;
}

/* ============================================
   Card Variants (Phase 2 - T-1.5)
   ============================================ */

/* Card Accent Variants - Left Border Accents */
.card-info {
  border-left: 4px solid var(--color-primary);
}

.card-warning {
  border-left: 4px solid var(--color-warning);
  background: #fffbeb;
}

.card-success {
  border-left: 4px solid var(--color-success);
}

.card-danger {
  border-left: 4px solid var(--color-danger);
}

.card-neutral {
  border-left: 4px solid var(--color-gray-300);
  background: var(--color-gray-50);
}

/* ============================================
   Responsive Styles (Phase 2 - T-1.6)
   ============================================ */

@media (max-width: 768px) {
  /* Table Responsiveness */
  .table-container {
    margin: 0 calc(-1 * var(--space-4));
    border-radius: 0;
  }

  .table-container th,
  .table-container td {
    padding: var(--space-3);
    font-size: 0.85rem;
  }

  /* Ensure table scrolls horizontally without page scroll */
  .table-container table {
    min-width: 600px;
  }

  /* Card Stacking */
  .card-grid {
    grid-template-columns: 1fr;
  }

  /* Badge scaling for touch */
  .badge {
    padding: var(--space-2) var(--space-3);
    font-size: 0.75rem;
  }

  /* Table action buttons stack on mobile */
  .table-actions {
    flex-direction: column;
    gap: var(--space-1);
  }

  .table-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   Navigation (Phase 3 - T-1.1, T-1.2, T-1.3)
   ============================================ */

/* Navigation Container */
.nav {
  display: flex;  /* Override nav { display: none } - Remix uses React conditional rendering */
  background: var(--color-gray-900);
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Navigation Content Wrapper */
.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-8);
}

/* Brand / Logo */
.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  transition: var(--transition-fast);
}

.nav-brand:hover {
  opacity: 0.9;
}

/* Navigation Items Container (Desktop) */
.nav-items {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Individual Navigation Item */
.nav-item {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  font-weight: 400;
  font-size: 0.95rem;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.nav-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 600;
}

/* Logout Button */
.nav-logout {
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  color: white;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.nav-logout:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Logout Form Wrapper - inline in flex container */
.nav-logout-form {
  display: contents;
}

/* ============================================
   Mobile Menu (Phase 3 - T-2.1, T-2.2, T-2.3)
   ============================================ */

/* Hamburger Button - Hidden on desktop */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  gap: 5px;
}

.hamburger-line {
  width: 24px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: var(--transition-fast);
}

/* Hamburger animation when open */
.hamburger.open .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.open .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger.open .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Menu Panel */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  right: -280px;
  width: 280px;
  height: 100vh;
  background: var(--color-gray-900);
  z-index: 1001;
  padding: var(--space-6);
  transition: right 0.3s ease;
  overflow-y: auto;
}

.mobile-menu.open {
  right: 0;
}

/* Mobile Menu Header */
.mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
}

.mobile-menu-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.mobile-menu-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile Menu Items */
.mobile-menu-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mobile-menu-item {
  display: block;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
  font-size: 1rem;
  font-weight: 500;
  transition: var(--transition-fast);
  min-height: 44px;
}

.mobile-menu-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

.mobile-menu-item.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 600;
}

/* Mobile Menu Footer */
.mobile-menu-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Mobile Menu Logout Button */
.mobile-menu-logout {
  width: 100%;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-md);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-menu-logout:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Mobile Backdrop */
.mobile-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

/* Mobile Navigation Responsive */
@media (max-width: 768px) {
  .nav-content {
    padding: var(--space-3) var(--space-4);
  }

  /* Hide desktop nav items and logout, show hamburger */
  .nav-items {
    display: none;
  }

  .nav-logout-form {
    display: none;
  }

  .hamburger {
    display: flex;
  }

  /* Enable mobile menu structure */
  .mobile-menu {
    display: flex;
  }
}

/* ============================================
   Page Layout (Phase 3 - T-3.1, T-3.2, T-3.3)
   ============================================ */

/* Page Container */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-8);
  width: 100%;
}

/* Content Width Variants */
.content-narrow {
  max-width: 800px;
}

.content-wide {
  max-width: 1400px;
}

.content-full {
  max-width: 100%;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* Page Title */
.page-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--color-gray-900);
  margin: 0;
}

/* Page Actions */
.page-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}

/* Page Content */
.page-content {
  background: transparent;
}

/* Responsive Page Layout */
@media (max-width: 768px) {
  .page-container {
    padding: var(--space-4);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

/* ============================================
   Calendar & Events (Phase 4)
   ============================================ */

/* Stats Grid (T-1.1) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  text-align: center;
}

.stat-card--neutral {
  background: var(--color-gray-50);
}

.stat-card--success {
  background: #dcfce7;
}

.stat-card--warning {
  background: #fef3c7;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-card--success .stat-value {
  color: #166534;
}

.stat-card--warning .stat-value {
  color: #92400e;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--color-gray-600);
}

.stat-card--success .stat-label {
  color: #166534;
}

.stat-card--warning .stat-label {
  color: #92400e;
}

/* Event Cards (T-2.1, T-2.2) */
.event-list {
  display: grid;
  gap: var(--space-4);
}

.event-card {
  padding: var(--space-4);
  background: var(--color-gray-50);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-gray-400);
}

.event-card--completed {
  background: #f0fdf4;
}

.event-card--cancelled {
  background: #fef2f2;
  opacity: 0.6;
}

.event-card--in-person {
  border-left-color: #22c55e;
}

.event-card--online {
  border-left-color: #3b82f6;
}

.event-card--private {
  border-left-color: #8b5cf6;
}

.event-card--unknown {
  border-left-color: #6b7280;
}

.event-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.event-content {
  flex: 1;
}

.event-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
  flex-wrap: wrap;
}

.event-title {
  font-weight: 600;
}

.event-time {
  font-size: 0.9rem;
  color: var(--color-gray-600);
}

.event-patient {
  margin-top: var(--space-2);
}

.event-actions {
  margin-top: var(--space-4);
}

.action-buttons {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Event Type Badges (T-2.3) */
.badge-event-type {
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  color: white;
}

.badge-event-type--in-person {
  background: #22c55e;
}

.badge-event-type--online {
  background: #3b82f6;
}

.badge-event-type--private {
  background: #8b5cf6;
}

.badge-event-type--unknown {
  background: #6b7280;
}

.badge-status {
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  color: white;
}

.badge-status--completed {
  background: #22c55e;
}

.badge-status--cancelled {
  background: #ef4444;
}

/* Patient Status (T-2.4) */
.patient-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.patient-status--matched {
  color: #22c55e;
  font-weight: 500;
}

.patient-status--unmatched {
  color: #f59e0b;
}

/* Patient Search Widget (T-3.1, T-3.2) */
.patient-search {
  position: relative;
  min-width: 200px;
}

.patient-search__input {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.patient-search__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.patient-search__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.patient-search__option {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}

.patient-search__option:hover {
  background: var(--color-gray-100);
}

.patient-search__option--selected {
  background: #eff6ff;
}

.patient-search__locked {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.patient-search__locked-value {
  padding: 0.25rem 0.75rem;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: #166534;
  font-weight: 500;
}

.patient-search__unlock-btn {
  padding: 0.25rem 0.5rem;
  background: var(--color-gray-100);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 0.75rem;
}

.patient-search__unlock-btn:hover {
  background: var(--color-gray-200);
}

/* OAuth Card (T-4.1) */
.oauth-card {
  padding: var(--space-8);
  text-align: center;
  background: var(--color-gray-50);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
}

.oauth-card__title {
  margin: 0 0 var(--space-2);
  font-size: 1.25rem;
  font-weight: 600;
}

.oauth-card__description {
  color: var(--color-gray-600);
  margin-bottom: var(--space-4);
}

/* Empty State (T-4.2) */
.empty-state {
  text-align: center;
  padding: var(--space-8);
  color: var(--color-gray-600);
}

.empty-state--calendar {
  padding: var(--space-8);
}

/* Sync Info */
.sync-info {
  margin-top: var(--space-4);
  font-size: 0.8rem;
  color: var(--color-gray-600);
  text-align: right;
}

/* Page Subtitle */
.page-subtitle {
  color: var(--color-gray-600);
  margin: var(--space-1) 0 0;
}

/* Responsive Calendar (Phase 4) */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .event-header {
    flex-direction: column;
  }

  .event-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* =============================================================================
   PHASE 5: REMAINING ROUTES STYLING
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Patient Detail Page (T-1.1, T-1.2, T-1.3)
   ----------------------------------------------------------------------------- */

/* Patient Header */
.patient-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.patient-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

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

.patient-name {
  margin: 0;
  font-size: 1.5rem;
}

.patient-meta {
  color: #666;
  font-size: 0.9rem;
  margin: 0.25rem 0 0 0;
}

.patient-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.patient-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  background: var(--color-gray-50);
  border-radius: var(--radius-md);
}

.patient-stat__value {
  font-weight: 600;
  color: #667eea;
  font-size: 1.25rem;
}

.patient-stat__label {
  color: #666;
  font-size: 0.875rem;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--color-gray-200);
  margin-bottom: var(--space-4);
  gap: 0;
}

.tab-nav__item {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--color-gray-600);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.tab-nav__item:hover {
  color: var(--color-gray-900);
  background: var(--color-gray-50);
}

.tab-nav__item--active {
  border-bottom-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: 500;
}

/* Data Grid */
.data-grid {
  display: grid;
  gap: var(--space-4);
}

.data-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-gray-100);
}

.data-row:last-child {
  border-bottom: none;
}

.data-label {
  font-weight: 500;
  color: var(--color-gray-700);
}

.data-value {
  color: var(--color-gray-900);
}

/* Edit Form */
.edit-form {
  display: grid;
  gap: 1rem;
}

.edit-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.edit-form__row--single {
  grid-template-columns: 1fr;
}

.edit-form__row--custom {
  grid-template-columns: 200px 1fr;
}

.edit-form__actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
}

/* -----------------------------------------------------------------------------
   Documents Pages (T-2.1, T-2.2, T-2.3)
   ----------------------------------------------------------------------------- */

/* Dropzone */
.dropzone {
  border: 2px dashed var(--color-gray-300);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}

.dropzone:hover {
  border-color: var(--color-primary);
  background: rgba(102, 126, 234, 0.05);
}

.dropzone--active {
  border-color: var(--color-primary);
  background: rgba(102, 126, 234, 0.1);
  border-style: solid;
}

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

.dropzone__icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
}

.dropzone__text {
  color: var(--color-gray-700);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.dropzone__hint {
  font-size: 0.875rem;
  color: var(--color-gray-500);
}

/* Job List & Cards */
.job-list {
  display: grid;
  gap: var(--space-4);
}

.job-card {
  background: white;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.job-card__header {
  padding: var(--space-3) var(--space-4);
  background: var(--color-gray-50);
  border-bottom: 1px solid var(--color-gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.job-card__title {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.job-card__status {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-weight: 500;
}

.job-card__status--pending {
  background: #fef3c7;
  color: #92400e;
}

.job-card__status--processing {
  background: #dbeafe;
  color: #1e40af;
}

.job-card__status--completed {
  background: #dcfce7;
  color: #166534;
}

.job-card__status--confirmed {
  background: #e0e7ff;
  color: #3730a3;
}

.job-card__status--failed {
  background: #fee2e2;
  color: #991b1b;
}

.job-card__body {
  padding: var(--space-4);
}

.job-card__actions {
  padding: var(--space-3) var(--space-4);
  background: var(--color-gray-50);
  border-top: 1px solid var(--color-gray-200);
  display: flex;
  gap: var(--space-2);
}

.job-card__meta {
  font-size: 0.875rem;
  color: var(--color-gray-600);
  margin-top: var(--space-2);
}

/* Document List & Cards (Patient Detail Documents Tab) */
.document-list {
  display: grid;
  gap: var(--space-3);
}

.document-card {
  background: white;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

.document-card:hover {
  border-color: var(--color-gray-300);
  background: var(--color-gray-50);
}

.document-card__info {
  flex: 1;
  min-width: 0;
}

.document-card__name {
  font-weight: 500;
  color: var(--color-gray-900);
  margin-bottom: var(--space-2);
  word-break: break-word;
}

.document-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.875rem;
  color: var(--color-gray-600);
  flex-wrap: wrap;
}

.document-card__meta .badge {
  flex-shrink: 0;
}

/* Progress Bar */
.progress-bar {
  height: 8px;
  background: var(--color-gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--color-primary);
  transition: width 0.3s ease;
}

.progress-bar__fill--success {
  background: #22c55e;
}

.progress-bar__fill--error {
  background: #ef4444;
}

.progress-text {
  font-size: 0.875rem;
  color: var(--color-gray-600);
  margin-top: var(--space-2);
}

.progress-container {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.progress-container .progress-bar {
  width: 200px;
}

/* Document Detail */
.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}

.doc-header__title {
  margin: 0;
}

.doc-header__subtitle {
  color: var(--color-gray-600);
  margin: var(--space-1) 0 0;
}

.doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
}

.doc-preview-frame {
  width: 100%;
  height: 600px;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-lg);
}

/* Document Detail Page - PDF-focused layout */
.document-detail {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-4);
  height: calc(100vh - 180px);
  min-height: 500px;
}

.document-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0 !important;
}

.pdf-iframe {
  width: 100%;
  flex: 1;
  min-height: 400px;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  background: var(--color-gray-100);
}

.document-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow-y: auto;
  padding-right: var(--space-2);
}

/* Compact info sections */
.document-detail .document-info,
.document-detail .linked-patient,
.document-detail .extracted-data,
.document-detail .extracted-kg,
.document-detail .confirm-section {
  background: var(--color-gray-50);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: 0 !important;
}

.document-detail .section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-gray-600);
  margin: 0 0 var(--space-2) 0;
}

.document-detail .info-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.document-detail .info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  gap: var(--space-2);
}

.document-detail .info-label {
  color: var(--color-gray-600);
  flex-shrink: 0;
}

.document-detail .info-value {
  color: var(--color-gray-900);
  text-align: right;
  word-break: break-word;
}

/* Compact form inputs in confirm section */
.document-detail .patient-form .form-group {
  margin-bottom: var(--space-2) !important;
}

.document-detail .patient-form .form-label {
  font-size: 0.8rem;
  margin-bottom: var(--space-1);
}

.document-detail .patient-form .form-input {
  padding: var(--space-2);
  font-size: 0.9rem;
}

.document-detail .patient-form .hint {
  font-size: 0.75rem;
}

.document-detail .confirm-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.document-detail .confirm-options .radio-label {
  font-size: 0.85rem;
}

/* Document actions at bottom */
.document-detail .document-actions {
  display: flex;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-gray-200);
  margin-top: auto;
}

.document-detail .document-actions .btn {
  flex: 1;
  font-size: 0.85rem;
  padding: var(--space-2) var(--space-3);
}

/* Mobile: stack layout */
@media (max-width: 1024px) {
  .document-detail {
    grid-template-columns: 1fr;
    height: auto;
  }

  .document-preview {
    height: 50vh;
    min-height: 300px;
  }

  .pdf-iframe {
    flex: none;
    height: 100%;
  }

  .document-sidebar {
    max-height: none;
    overflow-y: visible;
  }
}

.radio-group {
  display: flex;
  gap: var(--space-4);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.match-suggestion {
  margin-top: var(--space-2);
  color: #15803d;
  font-size: 0.85rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-actions {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.alert {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}

.alert--error {
  background: #fef2f2;
  border: 1px solid #ef4444;
  color: #b91c1c;
}

.alert--success {
  background: #f0fdf4;
  border: 1px solid #22c55e;
  color: #166534;
}

/* -----------------------------------------------------------------------------
   Dashboard (T-3.1, T-3.2, T-3.3)
   ----------------------------------------------------------------------------- */

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

.dashboard-section {
  background: white;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  border: 1px solid var(--color-gray-200);
}

.dashboard-section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.dashboard-section__title {
  margin: 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.dashboard-section__icon {
  font-size: 1.5rem;
}

.dashboard-section__subtitle {
  font-size: 0.875rem;
  color: var(--color-gray-600);
}

/* Calendar Preview */
.calendar-preview {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.calendar-preview__empty {
  color: #666;
  padding: 1rem 0;
  text-align: center;
}

.calendar-preview__event {
  padding: var(--space-3);
  background: var(--color-gray-50);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-primary);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.calendar-preview__time {
  font-weight: 600;
  min-width: 110px;
  color: #374151;
}

.calendar-preview__content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.calendar-preview__title {
  font-weight: 500;
}

.calendar-preview__badge {
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.calendar-preview__badge--matched {
  background: #dcfce7;
  color: #166534;
}

.calendar-preview__badge--unmatched {
  background: #fef3c7;
  color: #92400e;
}

/* Warning Cards */
.warning-card {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.warning-card--urgent {
  background: #fee2e2;
  border-left-color: #ef4444;
}

.warning-card--info {
  background: #dbeafe;
  border-left-color: #3b82f6;
}

.warning-card__icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.warning-card__content {
  flex: 1;
}

.warning-card__title {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.warning-card__message {
  font-size: 0.875rem;
  color: #666;
}

.warning-card__actions {
  margin-top: var(--space-2);
}

.warning-list {
  display: grid;
  gap: var(--space-3);
}

.warning-card--clickable {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.warning-card--clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.warning-card__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.warning-card__content-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.warning-card__patient-name {
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.warning-card__badges {
  text-align: right;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

/* Calendar Preview Variants */
.calendar-preview__event--cancelled {
  background: #fef2f2;
}

.calendar-preview__event--completed {
  background: #f0fdf4;
}

.calendar-preview__patient-link {
  font-weight: 600;
  font-size: 1rem;
  color: #2563eb;
  text-decoration: underline;
}

.calendar-preview__patient-link:hover {
  color: #1d4ed8;
}

/* Report Card Variants */
.report-card--link {
  text-decoration: none;
  color: inherit;
}

/* -----------------------------------------------------------------------------
   Auth Pages (T-4.1 / T-5.4)
   ----------------------------------------------------------------------------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: var(--space-8);
}

.auth-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 450px;
  width: 100%;
  padding: 3rem;
}

.auth-title {
  text-align: center;
  margin-bottom: var(--space-2);
  font-size: 2rem;
  color: #333;
}

.auth-title--small {
  font-size: 1.75rem;
}

.auth-subtitle {
  text-align: center;
  color: var(--color-gray-600);
  margin-bottom: var(--space-8);
}

.auth-error {
  padding: var(--space-4);
  background: #fee;
  border: 1px solid #fcc;
  border-radius: var(--radius-lg);
  color: #c33;
  margin-bottom: var(--space-6);
  font-size: 0.9rem;
}

.auth-error--center {
  text-align: center;
  margin-top: var(--space-6);
  margin-bottom: 0;
}

.auth-success {
  padding: var(--space-4);
  background: #efe;
  border: 1px solid #cec;
  border-radius: var(--radius-lg);
  color: #363;
  margin-bottom: var(--space-6);
  font-size: 0.9rem;
}

.auth-success--center {
  text-align: center;
  margin-top: var(--space-6);
}

.auth-form {
  margin-top: var(--space-6);
}

.auth-form-group {
  margin-bottom: var(--space-6);
}

.auth-label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--space-2);
  color: #333;
}

.auth-input {
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid #ddd;
  font-size: 1rem;
  box-sizing: border-box;
}

.auth-hint {
  color: var(--color-gray-600);
  font-size: 0.85rem;
  margin-top: var(--space-1);
}

.auth-forgot {
  margin-top: var(--space-2);
  text-align: right;
}

.auth-forgot-link {
  font-size: 0.85rem;
  color: var(--color-primary);
  text-decoration: none;
}

.auth-forgot-link:hover {
  text-decoration: underline;
}

.auth-submit {
  width: 100%;
  padding: var(--space-4);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-submit:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.auth-footer {
  margin-top: var(--space-6);
  text-align: center;
}

.auth-footer__link-row {
  margin-top: var(--space-4);
}

.auth-link {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.9rem;
}

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

/* -----------------------------------------------------------------------------
   Import Page (T-5.1)
   ----------------------------------------------------------------------------- */

.import-container {
  max-width: 800px;
}

.import-form {
  display: grid;
  gap: var(--space-4);
}

.import-preview {
  background: var(--color-gray-50);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-4);
}

.import-preview__header {
  font-weight: 500;
  margin-bottom: var(--space-3);
}

.import-preview__content {
  font-family: monospace;
  font-size: 0.875rem;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

.import-result {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-top: var(--space-4);
}

.import-result--success {
  background: #dcfce7;
  color: #166534;
}

.import-result--error {
  background: #fee2e2;
  color: #991b1b;
}

.import-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.import-dropzone {
  border: 2px dashed var(--color-gray-300);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  text-align: center;
  margin-bottom: var(--space-6);
  background: var(--color-gray-50);
  cursor: pointer;
  transition: var(--transition-fast);
}

.import-dropzone:hover {
  border-color: var(--color-primary);
  background: rgba(102, 126, 234, 0.05);
}

.import-dropzone--active {
  border-color: var(--color-primary);
  border-style: solid;
  background: rgba(102, 126, 234, 0.1);
}

.import-dropzone__icon {
  font-size: 2rem;
  margin-bottom: var(--space-2);
}

.import-dropzone__text {
  color: var(--color-gray-600);
  margin: 0;
}

.import-loading {
  text-align: center;
  padding: var(--space-8);
  color: var(--color-gray-600);
}

.import-preview__grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr 1fr;
}

.import-preview__section-title {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
  font-weight: 600;
}

.import-preview__field {
  margin: var(--space-1) 0;
}

.import-preview__field--highlight {
  color: var(--color-success);
}

.import-preview__actions {
  margin-top: var(--space-6);
  border-top: 1px solid var(--color-gray-200);
  padding-top: var(--space-6);
}

.import-preview__options {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.import-preview__option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.import-preview__option + .import-preview__option {
  margin-left: var(--space-4);
}

.import-preview__buttons {
  display: flex;
  gap: var(--space-4);
}

.import-instructions {
  margin-top: var(--space-8);
  padding: var(--space-4);
  background: var(--color-gray-50);
  border-radius: var(--radius-lg);
}

.import-instructions__title {
  margin-top: 0;
  margin-bottom: var(--space-2);
}

.import-instructions__list {
  padding-left: var(--space-6);
  margin: var(--space-2) 0;
}

/* -----------------------------------------------------------------------------
   Collaboration Page (T-5.2)
   ----------------------------------------------------------------------------- */

.collab-container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-6);
}

.collab-header {
  margin-bottom: var(--space-6);
  text-align: center;
}

.collab-section {
  background: white;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-gray-200);
}

.collab-section__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 var(--space-3);
  color: var(--color-gray-900);
}

.collab-readonly {
  background: var(--color-gray-50);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
}

.collab-field {
  margin-bottom: var(--space-3);
}

.collab-field:last-child {
  margin-bottom: 0;
}

.collab-field__label {
  font-weight: 500;
  color: var(--color-gray-700);
  display: block;
  margin-bottom: var(--space-1);
}

.collab-field__value {
  color: var(--color-gray-900);
}

.collab-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-6);
}

.collab-message {
  text-align: center;
  margin-top: var(--space-8);
}

.collab-message__title--error {
  color: var(--color-danger);
}

.collab-message__title--success {
  color: #22c55e;
}

.collab-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.collab-info__label {
  font-size: 0.8rem;
  color: var(--color-gray-600);
  margin-bottom: var(--space-1);
}

.collab-info__value {
  font-weight: 500;
}

.collab-content-box {
  background: var(--color-gray-50);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
}

.collab-form-hint {
  color: var(--color-gray-600);
  font-size: 0.9rem;
  margin-bottom: var(--space-4);
}

/* -----------------------------------------------------------------------------
   Report Editor (T-5.3)
   ----------------------------------------------------------------------------- */

.report-container {
  max-width: 900px;
  margin: 0 auto;
}

.report-form {
  display: grid;
  gap: var(--space-6);
}

.report-section {
  background: var(--color-gray-50);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.report-section__title {
  font-weight: 600;
  margin: 0 0 var(--space-3);
  color: var(--color-gray-900);
}

.report-section__content {
  display: grid;
  gap: var(--space-3);
}

.report-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-gray-200);
}

.report-meta {
  font-size: 0.875rem;
  color: var(--color-gray-600);
}

/* -----------------------------------------------------------------------------
   Utility Classes
   ----------------------------------------------------------------------------- */

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

.flex-center {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.text-muted {
  color: var(--color-gray-600);
}

.text-sm {
  font-size: 0.875rem;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

.hidden { display: none; }

.text-danger { color: #ef4444; }
.text-success { color: #16a34a; }
.text-warning { color: #f59e0b; }
.text-link { color: var(--color-primary); text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.font-medium { font-weight: 500; }
.text-xs { font-size: 0.8rem; }
.text-center { text-align: center; }
.text-inherit { color: inherit; }
.no-underline { text-decoration: none; }

/* -----------------------------------------------------------------------------
   Page Description (Phase 5)
   ----------------------------------------------------------------------------- */

.page-description {
  color: var(--color-gray-600);
  margin: var(--space-1) 0 0;
}

/* -----------------------------------------------------------------------------
   Report Editor Styles (Phase 5)
   ----------------------------------------------------------------------------- */

.report-form-label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.report-form-input {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.95rem;
  font-family: inherit;
}

.report-form-input--disabled {
  background: #f5f5f5;
}

.report-status-row {
  margin-top: var(--space-4);
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.report-status-select {
  padding: var(--space-2);
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.9rem;
}

.report-section {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.report-section--wide {
  gap: var(--space-6);
}

.report-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.report-action-btn {
  flex: 1 1 200px;
  text-align: center;
}

.report-action-btn--pdf {
  background: #10b981;
}

.report-action-btn--pdf:hover {
  background: #059669;
}

/* -----------------------------------------------------------------------------
   Patient List Styles (Phase 5)
   ----------------------------------------------------------------------------- */

.patient-link {
  font-weight: 500;
  color: inherit;
  text-decoration: none;
}

.patient-link:hover {
  color: var(--color-primary);
}

.kg-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.kg-info-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  font-size: 0.9rem;
}

.kg-sessions {
  font-weight: bold;
  color: #333;
}

.kg-sessions--warning {
  color: #ef4444;
}

.kg-label {
  color: var(--color-gray-600);
}

.kg-expiry {
  font-size: 0.8rem;
  color: var(--color-gray-600);
}

.kg-expiry-warning {
  color: #f59e0b;
  margin-left: var(--space-1);
}

.kg-none {
  color: #999;
  font-size: 0.85rem;
}

/* -----------------------------------------------------------------------------
   Empty State Styles (Phase 5)
   ----------------------------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: var(--space-8);
}

.empty-state__text {
  color: var(--color-gray-600);
  margin-bottom: var(--space-6);
}

/* -----------------------------------------------------------------------------
   Form Actions (Phase 5)
   ----------------------------------------------------------------------------- */

.form-actions {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.form-input--search {
  min-width: 250px;
}

/* -----------------------------------------------------------------------------
   Table Cell Variants (Phase 5)
   ----------------------------------------------------------------------------- */

.table-cell__name {
  font-weight: 500;
}

.table-cell__subtitle {
  color: var(--color-gray-600);
  font-size: 0.85rem;
  margin-top: var(--space-1);
}

/* Job Card Variants */
.job-card--success {
  border-color: #22c55e;
  background: #f0fdf4;
}

.job-card--error {
  border-color: #ef4444;
  background: #fef2f2;
}

/* =============================================================================
   PHASE 6: Responsive Design & Polish
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Focus States (T-1.2)
   ----------------------------------------------------------------------------- */

/* Global focus-visible for all interactive elements */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* Remove default focus outline (we use focus-visible instead) */
:focus:not(:focus-visible) {
  outline: none;
}

/* Skip link for accessibility (T-2.4) */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--color-primary);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  z-index: 10000;
  text-decoration: none;
  font-weight: 500;
}

.skip-link:focus {
  top: var(--space-4);
}

/* -----------------------------------------------------------------------------
   Transitions & Micro-interactions (T-1.3)
   ----------------------------------------------------------------------------- */

/* Add transitions to interactive elements */
.btn,
.nav-link,
.badge,
.card,
.table-actions button {
  transition: all var(--transition-fast);
}

.form-input,
.form-textarea,
.form-group input,
.form-group select,
.form-group textarea {
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

/* Modal transitions */
.modal-overlay {
  transition: opacity var(--transition-normal);
}

.modal-content {
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

/* -----------------------------------------------------------------------------
   Loading States (T-1.5)
   ----------------------------------------------------------------------------- */

.btn--loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
  color: transparent !important;
}

.btn--loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1em;
  height: 1em;
  margin: -0.5em 0 0 -0.5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spinner 0.6s linear infinite;
}

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

/* Page loading spinner */
.page-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-gray-200);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spinner 0.8s linear infinite;
}

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

/* -----------------------------------------------------------------------------
   Reduced Motion (T-1.4)
   ----------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* -----------------------------------------------------------------------------
   Mobile Navigation (T-2.5)
   ----------------------------------------------------------------------------- */

/* Hamburger button - hidden on desktop */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-gray-700);
  padding: var(--space-2);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.nav-toggle:hover {
  color: var(--color-primary);
}

/* Mobile navigation menu */
.nav-menu {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* -----------------------------------------------------------------------------
   Responsive Tables (T-2.3)
   ----------------------------------------------------------------------------- */

/* Table to card transformation on mobile */
.table-responsive {
  width: 100%;
}

/* -----------------------------------------------------------------------------
   Responsive Breakpoints (T-2.1, T-2.2)
   ----------------------------------------------------------------------------- */

/* Small desktop (< 1024px) */
@media (max-width: 1024px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .report-grid-2col {
    grid-template-columns: 1fr;
  }
}

/* Tablet (< 768px) - existing styles enhanced */
@media (max-width: 768px) {
  /* Navigation mobile toggle */
  .nav-toggle {
    display: block;
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    border-top: 1px solid var(--color-gray-200);
  }

  .nav-menu.nav-menu--open {
    display: flex;
  }

  .nav-menu .nav-link {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
  }

  .nav-menu .nav-link:hover {
    background: var(--color-gray-50);
  }

  nav {
    position: relative;
  }

  .nav-content {
    justify-content: space-between;
  }

  /* Layout adjustments */
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .edit-form__row {
    grid-template-columns: 1fr;
  }

  .data-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .patient-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }

  .patient-stats {
    width: 100%;
    justify-content: flex-start;
  }

  .tab-nav {
    overflow-x: auto;
  }

  .auth-card {
    padding: var(--space-6);
  }

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

  /* Table responsive - card layout */
  .table-container table {
    display: block;
  }

  .table-container thead {
    display: none;
  }

  .table-container tbody {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  .table-container tr {
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    gap: var(--space-2);
  }

  .table-container td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-1) 0;
    border: none;
  }

  .table-container td::before {
    content: attr(data-label);
    font-weight: 500;
    color: var(--color-gray-600);
    font-size: 0.85rem;
  }

  .table-container td:last-child {
    justify-content: flex-end;
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-gray-100);
    margin-top: var(--space-2);
  }

  .table-actions {
    justify-content: flex-end;
  }

  /* Form responsive */
  .form-grid,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  /* Button groups stack on mobile */
  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }
}

/* Mobile (< 640px) */
@media (max-width: 640px) {
  .page-container {
    padding: var(--space-3);
  }

  .page-title {
    font-size: 1.5rem;
  }

  .card {
    padding: var(--space-4);
  }

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

  .btn {
    padding: var(--space-2) var(--space-4);
    font-size: 0.9rem;
  }

  .btn-sm {
    padding: var(--space-1) var(--space-2);
  }

  /* Touch-friendly targets */
  .nav-link,
  .btn,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  /* Calendar events stacked */
  .event-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .event-card__actions {
    width: 100%;
    margin-top: var(--space-3);
  }
}

/* -----------------------------------------------------------------------------
   Print Styles (T-3.1, T-3.2, T-3.3)
   ----------------------------------------------------------------------------- */

/* Print utility classes */
.no-print {
  /* Elements that should not print */
}

.print-only {
  display: none !important;
}

@media print {
  /* Show print-only elements */
  .print-only {
    display: block !important;
  }

  /* Hide non-printable elements */
  .no-print,
  nav,
  .nav-toggle,
  .nav-menu,
  .btn,
  .form-actions,
  .table-actions,
  .page-actions,
  .skip-link,
  .modal-overlay,
  footer {
    display: none !important;
  }

  /* Reset page background */
  body {
    background: white;
    color: black;
    font-size: 12pt;
    line-height: 1.4;
  }

  /* Remove shadows and backgrounds */
  .card,
  .page-container,
  .table-container {
    box-shadow: none;
    background: white;
  }

  .card {
    border: 1px solid #ccc;
  }

  /* Optimize page container */
  .page-container {
    padding: 0;
    max-width: none;
  }

  /* Print-friendly links */
  a {
    color: black;
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Don't show URL for internal links */
  a[href^="/"]::after,
  a[href^="#"]::after {
    content: none;
  }

  /* Tables print correctly */
  .table-container table {
    display: table;
    width: 100%;
    border-collapse: collapse;
  }

  .table-container thead {
    display: table-header-group;
  }

  .table-container tbody {
    display: table-row-group;
  }

  .table-container tr {
    display: table-row;
    border: none;
    padding: 0;
    page-break-inside: avoid;
  }

  .table-container th,
  .table-container td {
    display: table-cell;
    border: 1px solid #ccc;
    padding: 0.5em;
  }

  .table-container td::before {
    content: none;
  }

  /* Badges print with borders instead of colors */
  .badge {
    border: 1px solid currentColor;
    background: transparent !important;
  }

  /* Page breaks */
  .page-break-before {
    page-break-before: always;
  }

  .page-break-after {
    page-break-after: always;
  }

  .no-page-break {
    page-break-inside: avoid;
  }

  /* Patient detail page optimization */
  .patient-header {
    border-bottom: 2px solid black;
    padding-bottom: 1em;
    margin-bottom: 1em;
  }

  .patient-stats {
    display: none;
  }

  /* Report content fills page */
  .report-section {
    page-break-inside: avoid;
  }

  /* Headers for printed pages */
  h1, h2, h3 {
    page-break-after: avoid;
  }

  /* Ensure adequate contrast */
  .text-muted,
  .table-cell__subtitle,
  .kg-label,
  .kg-expiry {
    color: #333 !important;
  }
}

/* ============================================
   3-Pane Layout System (T-1.7, T-1.8)
   Layout variables defined in design-tokens.css
   ============================================ */

/* App Layout Container */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  background: var(--color-background);
}

.app-layout--sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) 1fr;
}

/* Main Content Area (contains ListPane + DetailPane) */
.app-main {
  display: grid;
  grid-template-columns: var(--list-pane-width) 1fr;
  height: 100vh;
  overflow: hidden;
}

.app-main--full-width {
  grid-template-columns: 1fr;
  overflow-y: auto;
}

/* ============================================
   Sidebar Component
   ============================================ */

.app-sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-gray-900);
  color: var(--color-white);
  position: sticky;
  top: 0;
  overflow-y: auto;
  transition: width var(--transition-normal);
}

.app-sidebar--collapsed {
  width: var(--sidebar-collapsed-width);
}

.app-sidebar--collapsed .sidebar-brand-text,
.app-sidebar--collapsed .sidebar-nav-label {
  display: none;
}

/* Sidebar Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--color-primary);
}

.sidebar-brand-text {
  font-size: 1.125rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  list-style: none;
  padding: var(--space-2);
  margin: 0;
}

.sidebar-nav li {
  margin-bottom: var(--space-1);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--color-gray-300);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-white);
}

.sidebar-nav-item--active {
  background: var(--color-primary);
  color: var(--color-white);
}

.sidebar-nav-item--active:hover {
  background: var(--color-primary-hover);
}

.sidebar-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-nav-label {
  white-space: nowrap;
}

/* Sidebar Toggle */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--space-4);
  padding: var(--space-2);
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-gray-300);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--color-white);
}

.sidebar-toggle svg {
  transition: transform var(--transition-normal);
}

.sidebar-version {
  display: block;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--color-gray-500);
  text-align: center;
}

/* ============================================
   List Pane Component
   ============================================ */

.app-list-pane {
  display: flex;
  flex-direction: column;
  width: var(--list-pane-width);
  min-width: var(--list-pane-min-width);
  max-width: var(--list-pane-max-width);
  /* Use 100% to inherit from flex parent instead of 100vh to avoid conflicts */
  height: 100%;
  min-height: 0; /* Allow flex shrinking */
  flex-shrink: 0; /* Don't shrink width when detail pane has content */
  background: var(--color-white);
  border-right: 1px solid var(--color-gray-200);
  overflow: hidden;
}

.list-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-gray-200);
  flex-shrink: 0;
}

.list-pane-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-gray-900);
  margin: 0;
}

.list-pane-actions {
  display: flex;
  gap: var(--space-2);
}

.list-pane-search {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-gray-200);
  flex-shrink: 0;
}

.list-pane-content {
  flex: 1;
  min-height: 0; /* Required for flex-based scrolling */
  overflow-y: auto;
  overflow-x: hidden;
}

.list-pane-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
}

.list-pane-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--color-gray-400);
  text-align: center;
  gap: var(--space-3);
}

.list-pane-empty .empty-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-gray-600);
  margin: 0;
}

.list-pane-empty .empty-description {
  font-size: var(--font-size-sm);
  color: var(--color-gray-500);
  margin: 0;
  max-width: 20rem;
}

.list-pane-empty .empty-action {
  margin-top: var(--space-2);
}

/* List pane count badge */
.list-pane-count {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  color: var(--color-gray-500);
  margin-left: var(--space-2);
}

/* Loading Spinner Animation */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ============================================
   Detail Pane Component
   ============================================ */

.app-detail-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100vh;
  background: var(--color-gray-50);
  overflow: hidden;
}

.detail-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-gray-200);
  flex-shrink: 0;
}

.detail-pane-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-gray-900);
  margin: 0;
}

.detail-pane-actions {
  display: flex;
  gap: var(--space-2);
}

/* Detail Pane Tabs */
.detail-pane-tabs {
  display: flex;
  gap: var(--space-1);
  padding: 0 var(--space-6);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-gray-200);
  flex-shrink: 0;
}

.detail-pane-tab {
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.detail-pane-tab:hover {
  color: var(--color-gray-900);
}

.detail-pane-tab--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.detail-pane-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

/* Detail pane stretches full width - content handles its own width constraints */

/* ============================================
   Empty State Component
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;
  min-height: 300px;
}

.empty-state-icon-wrapper {
  margin-bottom: var(--space-4);
  color: var(--color-gray-300);
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-gray-700);
  margin: 0 0 var(--space-2) 0;
}

.empty-state-description {
  font-size: 0.875rem;
  color: var(--color-gray-400);
  margin: 0 0 var(--space-4) 0;
  max-width: 300px;
}

.empty-state-action {
  margin-top: var(--space-4);
}

/* ============================================
   Responsive Breakpoints (T-1.8, 037)
   ============================================ */

/* Desktop: Full 3-pane layout (>= 1440px) is the default above */

/* Laptop: Auto-collapse sidebar, medium list (1200px - 1440px) */
@media (max-width: 1440px) {
  .app-layout {
    grid-template-columns: var(--sidebar-collapsed-width) 1fr;
  }

  .app-sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .app-sidebar .sidebar-brand-text,
  .app-sidebar .sidebar-nav-label {
    display: none;
  }

  .app-list-pane {
    width: var(--list-pane-width-laptop);
    min-width: var(--list-pane-width-small);
  }

  .app-main {
    grid-template-columns: var(--list-pane-width-laptop) 1fr;
  }

  /* Full-width routes stay full-width at all breakpoints */
  .app-main--full-width {
    grid-template-columns: 1fr;
  }
}

/* Small Laptop: Narrower list (1024px - 1200px) */
@media (max-width: 1200px) {
  .app-list-pane {
    width: var(--list-pane-width-small);
  }

  .app-main {
    grid-template-columns: var(--list-pane-width-small) 1fr;
  }

  /* Full-width routes stay full-width at all breakpoints */
  .app-main--full-width {
    grid-template-columns: 1fr;
  }
}

/* Tablet: Single pane toggle (768px - 1024px) */
@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: var(--sidebar-collapsed-width) 1fr;
  }

  .app-sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .app-sidebar .sidebar-brand-text,
  .app-sidebar .sidebar-nav-label {
    display: none;
  }

  .app-main {
    grid-template-columns: 1fr;
  }

  .app-list-pane {
    width: 100%;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--color-gray-200);
  }

  /* Show only one pane at a time based on route */
  .app-main--show-detail .app-list-pane {
    display: none;
  }

  .app-main--show-list .app-detail-pane {
    display: none;
  }
}

/* Mobile: Hide sidebar, use drawer */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: fixed;
    left: -100%;
    width: var(--sidebar-width);
    z-index: var(--z-sidebar);
    transition: left var(--transition-normal);
  }

  .app-sidebar--open {
    left: 0;
  }

  .app-sidebar .sidebar-brand-text,
  .app-sidebar .sidebar-nav-label {
    display: block;
  }

  /* Overlay when sidebar is open */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-sidebar-overlay);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
  }

  .sidebar-overlay--visible {
    opacity: 1;
    visibility: visible;
  }

  /* Mobile header with menu button */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-white);
    border-bottom: 1px solid var(--color-gray-200);
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-gray-700);
    cursor: pointer;
  }

  .mobile-menu-btn:hover {
    background: var(--color-gray-100);
  }

  .list-pane-header {
    padding: var(--space-3);
  }

  .detail-pane-content {
    padding: var(--space-4);
  }
}

/* Hide on mobile utility */
/* Note: Don't set display for desktop - let original styles apply */

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

/* Show on mobile utility */
.show-mobile {
  display: none;
}

@media (max-width: 768px) {
  .show-mobile {
    display: block;
  }
}

/* Hide on tablet utility */
.hide-tablet {
  display: block;
}

@media (max-width: 1024px) {
  .hide-tablet {
    display: none !important;
  }
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   List Pane Content Styles (Phase 4 - T-2.1+)
   ============================================ */

/* Pane container for list + detail layout */
.pane-container {
  display: flex;
  flex: 1;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  /* Span all grid columns when inside app-main grid */
  grid-column: 1 / -1;
}

/* When banner is present, stack vertically */
.pane-container--with-banner {
  flex-direction: column;
}

/* Pane content wrapper (list + detail side by side) */
.pane-content {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Test Mode Banner */
.test-mode-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-bottom: 1px solid #f59e0b;
  color: #92400e;
  font-size: var(--font-size-sm);
  font-weight: 500;
  flex-shrink: 0;
}

.test-mode-banner-icon {
  font-size: 1rem;
}

.test-mode-banner-text {
  flex: 1;
}

.test-mode-banner-close {
  padding: var(--space-1) var(--space-3);
  background: #fbbf24;
  border: 1px solid #f59e0b;
  border-radius: var(--radius-md);
  color: #78350f;
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.test-mode-banner-close:hover {
  background: #f59e0b;
}

/* Detail container */
.detail-container {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--color-gray-50);
}

/* List search input */
.list-search {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  background: white;
  color: var(--color-gray-900);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.list-search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.list-search::placeholder {
  color: var(--color-gray-400);
}

/* List items container */
.list-items {
  display: flex;
  flex-direction: column;
}

/* Individual list item (NavLink) */
.list-item {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-gray-200);
  text-decoration: none;
  color: var(--color-gray-900);
  transition: background-color 0.15s;
  cursor: pointer;
}

.list-item:hover {
  background-color: var(--color-gray-50);
}

.list-item--active {
  background-color: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
}

.list-item--active:hover {
  background-color: var(--color-primary-light);
}

/* List item content structure */
.list-item-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.list-item-title {
  font-weight: 500;
  color: var(--color-gray-900);
}

.list-item-meta {
  font-size: var(--font-size-sm);
  color: var(--color-gray-600);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* List item badges */
.list-item-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: 9999px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  background-color: var(--color-gray-100);
  color: var(--color-gray-600);
}

.list-item-badge--warning {
  background-color: #fef3c7;
  color: #92400e;
}

.list-item-badge--success {
  background-color: #d1fae5;
  color: #065f46;
}

.list-item-badge--muted {
  background-color: var(--color-gray-100);
  color: var(--color-gray-500);
}

/* Empty list state */
.list-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--color-gray-500);
  font-style: italic;
}

/* List item error state */
.list-item-badge--error {
  background-color: #fee2e2;
  color: #991b1b;
}

/* List item cancelled/completed states */
.list-item--cancelled {
  opacity: 0.6;
}

.list-item--completed {
  background-color: #d1fae5;
}

/* List item with action button */
.list-item--with-action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.list-item--with-action .list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-action {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-gray-100);
  border: 1px solid var(--color-gray-300);
  border-radius: 50%;
  color: var(--color-gray-500);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0;
}

.list-item:hover .list-item-action,
.list-item--active .list-item-action {
  opacity: 1;
}

.list-item-action:hover {
  background: var(--color-gray-200);
  border-color: var(--color-gray-400);
  color: var(--color-gray-700);
}

.list-item-action:active {
  transform: scale(0.9);
}

/* Event type badges */
.list-item-badge--in_person {
  background-color: #dcfce7;
  color: #166534;
}

.list-item-badge--online {
  background-color: #dbeafe;
  color: #1e40af;
}

.list-item-badge--private {
  background-color: #ede9fe;
  color: #5b21b6;
}

.list-item-badge--unknown {
  background-color: var(--color-gray-100);
  color: var(--color-gray-500);
}

.list-item-badge--free {
  background-color: #d1fae5;
  color: #047857;
}

.list-item-badge--provisional {
  background-color: #fef3c7;
  color: #b45309;
}

/* Collaborator type badges */
.list-item-badge--psychiatrist {
  background-color: #fce7f3;
  color: #9d174d;
}

.list-item-badge--referring {
  background-color: #dbeafe;
  color: #1e40af;
}

.list-item-badge--gp {
  background-color: #dcfce7;
  color: #166534;
}

/* List footer */
.list-footer {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--color-gray-500);
  border-top: 1px solid var(--color-gray-200);
  text-align: center;
}

/* List section headers */
.list-section {
  margin-top: var(--space-4);
}

.list-section:first-child {
  margin-top: 0;
}

.list-section-header {
  padding: var(--space-1) var(--space-4);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-gray-600);
  background-color: var(--color-gray-50);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* List filter dropdown */
.list-filter {
  appearance: auto;
  cursor: pointer;
}

/* Calendar controls */
.calendar-controls {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.calendar-controls .list-search {
  flex: 1;
}

.calendar-controls .btn {
  flex-shrink: 0;
}

/* Date navigator with arrows */
.date-navigator {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  flex: 1;
}

.date-navigator-input {
  flex: 1;
  min-width: 0;
  padding: var(--spacing-xs) var(--spacing-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.date-navigator-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.2);
}

.date-navigator .btn-ghost {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-sm);
}

/* Upload dropzone */
.upload-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.upload-dropzone:hover {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.upload-dropzone--active {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.upload-dropzone-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* List uploading state */
.list-uploading {
  padding: var(--spacing-md);
  text-align: center;
  color: var(--color-primary);
  font-weight: 500;
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* List item progress */
.list-item-progress {
  font-size: var(--font-size-xs);
  color: var(--color-primary);
  font-weight: 500;
}

/* List item email */
.list-item-email {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

/* ============================================
   Batch 5: Polish Features (T-6.1 - T-6.4)
   ============================================ */

/* T-6.1: List Item Keyboard Navigation & Focus States */
.list-item-focused {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  background-color: var(--bg-hover);
}

.list-item-selected {
  background-color: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
}

/* Focus ring for keyboard navigation */
.list-pane-content:focus {
  outline: none;
}

.list-pane-content:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* T-6.2: Skeleton Loading Animation */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.list-pane-skeleton {
  padding: var(--spacing-md);
}

.skeleton-item {
  display: flex;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--bg-secondary) 0px, var(--bg-tertiary) 40px, var(--bg-secondary) 80px);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.skeleton-line {
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-secondary) 0px, var(--bg-tertiary) 40px, var(--bg-secondary) 80px);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-line-title {
  width: 60%;
  height: 16px;
}

.skeleton-line-subtitle {
  width: 40%;
}

/* T-6.3: Transition Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

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

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

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

/* Detail pane transition */
.app-detail-pane {
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

.detail-pane-enter {
  animation: fadeIn 0.2s ease-out forwards;
}

.detail-pane-exit {
  animation: fadeOut 0.2s ease-out forwards;
}

/* Mobile slide transitions */
@media (max-width: 768px) {
  .detail-pane-enter {
    animation: slideInRight 0.25s ease-out forwards;
  }

  .detail-pane-exit {
    animation: slideOutRight 0.25s ease-out forwards;
  }
}

/* Content fade in */
.content-fade-in {
  animation: fadeIn 0.2s ease-out forwards;
}

.content-slide-up {
  animation: slideInUp 0.3s ease-out forwards;
}

/* T-6.4: Mobile Gesture Support */

/* Swipe indicator during drag */
.swipe-indicator {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  color: white;
  z-index: var(--z-popover);
  transition: opacity 0.1s;
}

/* Swiping state prevents scroll */
.detail-pane-swiping {
  overflow: hidden;
  touch-action: pan-x;
}

/* Mobile back button */
.detail-pane-back {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-right: var(--spacing-sm);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.15s;
}

.detail-pane-back:hover {
  background-color: var(--bg-hover);
}

.detail-pane-back:active {
  background-color: var(--bg-active);
}

/* Show back button on mobile/tablet */
@media (max-width: 1024px) {
  .detail-pane-back {
    display: flex;
  }

  .detail-pane-header {
    gap: var(--spacing-xs);
  }

  .detail-pane-title {
    flex: 1;
    font-size: 1.25rem;
  }
}

/* Swipe hint indicator (edge glow) */
@media (max-width: 768px) {
  .app-detail-pane::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.05), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
  }

  .app-detail-pane:hover::before {
    opacity: 1;
  }
}

/* ============================================
   Settings Page Styles (T-3.2, T-3.7)
   ============================================ */

.settings-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100vh;
  background: var(--color-background);
}

.settings-header {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-gray-200);
  padding: var(--space-6) var(--space-8);
}

.settings-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--color-gray-900);
  margin-bottom: var(--space-4);
}

.settings-tabs {
  display: flex;
  gap: var(--space-2);
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-gray-600);
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--transition-fast);
}

.settings-tab:hover {
  background: var(--color-gray-100);
  color: var(--color-gray-900);
}

.settings-tab--active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.settings-tab--active:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.settings-tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-tab-label {
  white-space: nowrap;
}

.settings-content {
  flex: 1;
  padding: var(--space-8);
  overflow-y: auto;
}

/* Settings Card */
.settings-card {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  max-width: 800px;
}

.settings-card-header {
  margin-bottom: var(--space-6);
}

.settings-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-gray-900);
  margin-bottom: var(--space-2);
}

.settings-card-description {
  color: var(--color-gray-600);
  font-size: 0.875rem;
}

/* Color Mapping Grid */
.color-mapping-grid {
  display: grid;
  gap: var(--space-4);
}

.color-mapping-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-gray-50);
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-white);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.color-name {
  flex: 1;
  font-weight: 500;
  color: var(--color-gray-700);
}

.color-mapping-select {
  min-width: 150px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-gray-300);
  background: var(--color-white);
  font-size: 0.875rem;
  cursor: pointer;
}

.color-mapping-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 var(--focus-ring-width) rgba(102, 126, 234, 0.2);
}

/* Settings Actions */
.settings-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-gray-200);
}

/* Responsive Settings */
@media (max-width: 768px) {
  .settings-header {
    padding: var(--space-4);
  }

  .settings-content {
    padding: var(--space-4);
  }

  .settings-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .settings-tabs::-webkit-scrollbar {
    display: none;
  }

  .color-mapping-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .color-mapping-select {
    width: 100%;
  }
}

/* ============================================
   Session Notes Styles
   ============================================ */

.session-notes-section {
  border-top: 1px solid var(--color-gray-200);
  padding-top: var(--space-4);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.note-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 80px;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.note-item {
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  transition: background 0.15s ease;
}

.note-item:hover {
  background: var(--color-gray-100);
}

.note-item--expanded {
  background: white;
  border-color: var(--color-primary);
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-1);
}

.note-date {
  font-size: var(--font-size-xs);
  color: var(--color-gray-500);
  font-weight: 500;
}

.note-preview {
  font-size: var(--font-size-sm);
  color: var(--color-gray-700);
  line-height: 1.5;
  white-space: pre-wrap;
}

.note-item--expanded .note-preview {
  color: var(--color-gray-900);
}

/* Patient detail notes - larger cards with full content */
.note-item--patient {
  background: white;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  cursor: default;
}

.note-item--patient:hover {
  background: white;
  border-color: var(--color-gray-300);
}

.note-item--patient .note-header {
  margin-bottom: var(--space-3);
}

.note-item--patient .note-date {
  font-size: var(--font-size-sm);
  color: var(--color-gray-600);
  font-weight: 600;
}

.note-actions {
  display: flex;
  gap: var(--space-1);
}

.note-content {
  font-size: var(--font-size-base);
  color: var(--color-gray-800);
  line-height: 1.6;
  white-space: pre-wrap;
}

.note-item--editing {
  background: var(--color-gray-50);
  border-color: var(--color-primary);
}

.note-edit-form {
  width: 100%;
}

.delete-confirm {
  text-align: center;
  padding: var(--space-4);
}

.delete-confirm .form-actions {
  justify-content: center;
}

/* -----------------------------------------------------------------------------
   Detail View Info Display (Collaborators & Krankenkassen)
   ----------------------------------------------------------------------------- */

.info-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.info-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.info-label {
  font-weight: 500;
  color: var(--color-gray-600);
  flex-shrink: 0;
}

/* Add space after colon in labels */
.info-label::after {
  content: " ";
}

.info-value {
  color: var(--color-gray-900);
}

/* Multi-line address display */
.info-value.whitespace-pre-line {
  white-space: pre-line;
  line-height: 1.6;
}

/* Action buttons layout - horizontal inline */
.collaborator-actions,
.krankenkasse-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.collaborator-actions form,
.krankenkasse-actions form {
  display: inline-flex;
}

/* -----------------------------------------------------------------------------
   Address Components
   ----------------------------------------------------------------------------- */

.address-display {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  line-height: 1.5;
}

.address-line {
  color: var(--color-gray-900);
}

.address-input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.address-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-3);
}

@media (max-width: 640px) {
  .address-row {
    grid-template-columns: 1fr;
  }
}

.address-autocomplete {
  position: relative;
}

.address-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--color-gray-300);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.address-suggestion {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-bottom: 1px solid var(--color-gray-100);
}

.address-suggestion:last-child {
  border-bottom: none;
}

.address-suggestion:hover,
.address-suggestion--selected {
  background: var(--color-gray-100);
}

.address-suggestion--loading {
  color: var(--color-gray-500);
  font-style: italic;
}

.address-suggestion-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-bottom: 1px solid var(--color-gray-100);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.address-suggestion-item:last-child {
  border-bottom: none;
}

.address-suggestion-item:hover {
  background: var(--color-gray-100);
}

.suggestion-street {
  font-weight: 500;
  color: var(--color-gray-900);
}

.suggestion-location {
  font-size: 0.875rem;
  color: var(--color-gray-500);
}

.address-plz {
  flex: 0 0 6rem;
}

.address-city {
  flex: 1;
}

.address-loading {
  font-size: 0.875rem;
  color: var(--color-gray-500);
  font-style: italic;
  padding: var(--space-1) 0;
}

.address-error {
  font-size: 0.875rem;
  color: var(--color-red-600);
  background: var(--color-red-50);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.address-error .dismiss {
  font-weight: bold;
  opacity: 0.7;
}

.address-error:hover .dismiss {
  opacity: 1;
}

/* ========================================
   Patient Search Dropdown
   ======================================== */

.patient-search-dropdown {
  position: relative;
  width: 100%;
}

.patient-search-input-wrapper {
  position: relative;
}

.patient-search-input {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  font-size: 0.875rem;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  -webkit-appearance: none;
  appearance: none;
}

.patient-search-input:disabled {
  background: var(--color-gray-100);
  cursor: not-allowed;
}

.patient-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.patient-search-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--color-white);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  min-height: 2.5rem;
}

.patient-search-selected-name {
  font-weight: 500;
  color: var(--color-gray-900);
}

.patient-search-clear {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--color-gray-400);
  cursor: pointer;
  padding: 0 var(--space-1);
  line-height: 1;
  transition: color 0.15s;
}

.patient-search-clear:hover {
  color: var(--color-gray-600);
}

.patient-search-clear:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.patient-search-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--color-white);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  margin-top: var(--space-1);
  list-style: none;
}

.patient-search-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: background-color 0.15s;
}

.patient-search-item:hover,
.patient-search-item--highlighted {
  background: var(--color-gray-100);
}

.patient-search-item--selected {
  background: var(--color-primary-light);
  font-weight: 500;
}

.patient-search-item--selected.patient-search-item--highlighted {
  background: var(--color-primary-light);
}

.patient-search-empty {
  padding: var(--space-3);
  color: var(--color-gray-500);
  text-align: center;
  font-style: italic;
}

.patient-search-item--clear {
  color: var(--color-gray-500);
  font-style: italic;
  border-bottom: 1px solid var(--color-gray-200);
}

.patient-search-item--empty {
  color: var(--color-gray-400);
  text-align: center;
  cursor: default;
}

.patient-search-item--empty:hover {
  background: transparent;
}

.patient-search-item-birthdate {
  color: var(--color-gray-400);
  margin-left: var(--space-2);
  font-size: 0.8rem;
}

/* ==========================================================================
   Document Confirm Section
   ========================================================================== */

.confirm-section {
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.confirm-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  transition: background-color 0.15s;
}

.radio-label:hover {
  background: var(--color-gray-100);
}

.radio-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.radio-hint {
  color: var(--color-gray-500);
  font-size: var(--font-size-sm);
  margin-left: var(--space-1);
}

.patient-select {
  margin-left: var(--space-6);
}

.alert-error {
  background: var(--color-red-50);
  border: 1px solid var(--color-red-200);
  color: var(--color-red-700);
  padding: var(--space-3);
  border-radius: var(--radius-md);
}
