/* Lab Portal - Main Styles */
/* Matches HealthCockpit design system */

:root {
  --color-primary: #32535F;
  --color-primary-light: #5A8FA0;
  --color-background: #f8f9fa;
  --color-surface: #ffffff;
  --color-text: #333333;
  --color-text-light: #666666;
  --color-border: #e0e0e0;
  --color-success: #28a745;
  --color-warning: #ffc107;
  --color-error: #dc3545;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
  font-family: var(--font-family);
  background: var(--color-background);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
.header {
  background: var(--color-primary);
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
}

.header-logo img {
  height: 28px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.header-user .role-badge {
  background: rgba(255,255,255,0.2);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.btn-logout {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.25);
}

/* Main content */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 18px;
  color: var(--color-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

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

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

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

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-success:hover {
  opacity: 0.9;
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

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

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.form-group label .required {
  color: var(--color-error);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-family);
  transition: border-color 0.15s;
}

.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(50, 83, 95, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group .error {
  color: var(--color-error);
  font-size: 13px;
  margin-top: 4px;
}

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

/* Checkbox / Radio groups */
.checkbox-group {
  margin-bottom: 16px;
}

.checkbox-group h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--color-primary);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-background);
  font-size: 14px;
}

.checkbox-item:hover {
  background: var(--color-background);
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
}

.checkbox-item .price {
  margin-left: auto;
  color: var(--color-text-light);
  font-size: 13px;
  white-space: nowrap;
}

.total-price {
  font-weight: 600;
  font-size: 15px;
  padding: 12px;
  background: var(--color-background);
  border-radius: var(--radius);
  text-align: right;
  margin-top: 8px;
}

.price-disclaimer {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 4px;
  font-style: italic;
}

/* Toggle (ja/nee) */
.toggle-group {
  display: flex;
  gap: 12px;
}

.toggle-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-weight: 400;
}

.toggle-group input[type="radio"] {
  width: auto;
  accent-color: var(--color-primary);
}

/* Table */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

th {
  font-weight: 600;
  color: var(--color-text-light);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:hover {
  background: var(--color-background);
}

.tests-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tests-list li {
  padding: 1px 0;
  font-size: 13px;
  line-height: 1.4;
}

.tests-list li::before {
  content: "\2022";
  color: var(--color-primary-light);
  margin-right: 6px;
}

.tests-extra {
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-text-light);
  font-style: italic;
  white-space: pre-wrap;
}

.tests-cell {
  max-width: 280px;
}

tr.clickable {
  cursor: pointer;
}

/* Status badges */
.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-wacht_op_patient { background: #fff3cd; color: #856404; }
.status-ingediend { background: #cce5ff; color: #004085; }
.status-in_behandeling { background: #d4edda; color: #155724; }
.status-klaar_voor_patient { background: #d1ecf1; color: #0c5460; }
.status-resultaten_klaar { background: #d4edda; color: #155724; }
.status-afgerond { background: #e2e3e5; color: #383d41; }

/* Status bar (patient view) */
.status-bar {
  display: flex;
  justify-content: space-between;
  margin: 24px 0;
  position: relative;
}

.status-bar::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-border);
  z-index: 0;
}

.status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  flex: 1;
}

.status-step .circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
}

.status-step.completed .circle {
  background: var(--color-success);
}

.status-step.active .circle {
  background: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(50, 83, 95, 0.2);
}

.status-step .label {
  font-size: 12px;
  text-align: center;
  color: var(--color-text-light);
  max-width: 100px;
}

.status-step.completed .label,
.status-step.active .label {
  color: var(--color-text);
  font-weight: 500;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--color-text-light);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(50, 83, 95, 0.03);
  color: var(--color-primary);
}

.upload-zone svg {
  margin-bottom: 8px;
}

/* Document list */
.doc-list {
  list-style: none;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-background);
}

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

.doc-item .doc-name {
  flex: 1;
  font-size: 14px;
}

.doc-item .doc-size {
  color: var(--color-text-light);
  font-size: 13px;
}

.doc-item .doc-date {
  color: var(--color-text-light);
  font-size: 13px;
}

/* Login page */
.login-container {
  max-width: 400px;
  margin: 80px auto;
  padding: 0 24px;
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 32px;
}

.login-card h1 {
  text-align: center;
  color: var(--color-primary);
  margin-bottom: 24px;
  font-size: 22px;
}

.login-card .logo {
  text-align: center;
  margin-bottom: 20px;
}

.login-card .logo img {
  height: 40px;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.filter-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.filter-btn:hover:not(.active) {
  background: var(--color-background);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 18px;
  color: var(--color-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--color-text-light);
  padding: 4px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-error); }
.toast-warning { background: var(--color-warning); color: #333; }

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

/* Detail view */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-item {
  padding: 8px 0;
}

.detail-item .detail-label {
  font-size: 12px;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.detail-item .detail-value {
  font-size: 14px;
}

.detail-item.full-width {
  grid-column: 1 / -1;
}

/* Patient data compact list */
.patient-data-compact {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: 14px;
}

.patient-data-compact .pd-label {
  color: var(--color-text-light);
  white-space: nowrap;
}

.patient-data-compact .pd-value {
  font-weight: 500;
}

/* Rich content (TinyMCE output) */
.rich-content {
  line-height: 1.6;
}

.rich-content p {
  margin: 0 0 8px 0;
}

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

.rich-content ul, .rich-content ol {
  margin: 0 0 8px 0;
  padding-left: 24px;
}

.rich-content a {
  color: var(--color-primary);
}

/* TinyMCE overrides */
.tox-tinymce {
  border-radius: var(--radius) !important;
  border-color: var(--color-border) !important;
}

/* Responsive */
@media (max-width: 768px) {
  .main { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .header { padding: 12px 16px; }

  .status-bar {
    flex-direction: column;
    gap: 16px;
  }

  .status-bar::before {
    top: 0;
    bottom: 0;
    left: 16px;
    right: auto;
    width: 3px;
    height: auto;
  }

  .status-step {
    flex-direction: row;
    gap: 12px;
  }

  .status-step .label {
    text-align: left;
    max-width: none;
  }

  table { font-size: 13px; }
  th, td { padding: 8px; }

  .modal { margin: 16px; padding: 16px; }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-light);
}

.empty-state svg {
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 15px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--color-text-light);
}

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

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

/* Privacy notice */
.privacy-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  margin-top: 16px;
  background: #f0f7f4;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--color-text-light);
  line-height: 1.5;
}

.privacy-notice svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--color-success);
}
