/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #005eb8; /* NHS Blue */
  --primary-dark: #003d78;
  --secondary-color: #41b6e6;
  --success-color: #00703c;
  --warning-color: #ffb81c;
  --danger-color: #d5281b;
  --background: #f0f4f5;
  --card-bg: #ffffff;
  --text-primary: #212b32;
  --text-secondary: #4c6272;
  --text-light: #768692;
  --border-color: #d8dde0;
  --swipe-left-color: #768692;
  --swipe-right-color: #005eb8;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  overflow: hidden;
  touch-action: pan-y;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--primary-color);
  color: white;
  z-index: 100;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.pending-count {
  font-size: 14px;
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
}

/* Card Container */
.card-container {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 12px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Spacers to allow first/last cards to be centered */
.card-container::before,
.card-container::after {
  content: '';
  flex-shrink: 0;
  height: calc(50vh - 150px);
}

/* Lab Result Card */
.lab-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  transition: transform 0.3s ease, box-shadow 0.2s ease, opacity 0.3s ease;
  flex-shrink: 0;
  opacity: 0.5;
}

.lab-card.active {
  box-shadow: 0 4px 20px rgba(0, 94, 184, 0.3);
  opacity: 1;
}

.lab-card.swiping {
  transition: none;
}

.lab-card.swipe-left {
  animation: swipeLeft 0.3s ease-out forwards;
}

.lab-card.swipe-right {
  animation: swipeRight 0.3s ease-out forwards;
}

@keyframes swipeLeft {
  to {
    transform: translateX(-120%);
    opacity: 0;
  }
}

@keyframes swipeRight {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

/* Card Header */
.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.card-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.patient-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.urgency-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--border-color);
  color: var(--text-secondary);
}

.urgency-badge.urgent {
  background: var(--danger-color);
  color: white;
}

.patient-details {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.patient-details span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Test Type */
.test-type {
  padding: 12px 16px;
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  font-size: 14px;
}

/* Results List */
.results-list {
  padding: 12px 16px;
  max-height: 280px;
  overflow-y: auto;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

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

.result-name {
  font-size: 14px;
  color: var(--text-primary);
  flex: 1;
}

.result-value-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-value {
  font-size: 14px;
  font-weight: 600;
  min-width: 50px;
  text-align: right;
}

.result-value.abnormal {
  color: var(--danger-color);
}

.result-value.abnormal-high {
  color: var(--danger-color);
  font-weight: 700;
}

.abnormal-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger-color);
  flex-shrink: 0;
}

.abnormal-indicator.high {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

.result-unit {
  font-size: 12px;
  color: var(--text-light);
  min-width: 60px;
}

.result-range {
  font-size: 11px;
  color: var(--text-light);
  min-width: 70px;
  text-align: right;
}

/* Card Footer */
.card-footer {
  padding: 12px 16px;
  background: #f8fafb;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Swipe Indicators on Card */
.swipe-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.swipe-indicator.left {
  left: 20px;
  background: var(--swipe-left-color);
  color: white;
}

.swipe-indicator.right {
  right: 20px;
  background: var(--swipe-right-color);
  color: white;
}

/* Action Hints */
.action-hints {
  display: flex;
  justify-content: space-between;
  padding: 0 40px 16px;
}

.hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
}

.hint-icon {
  font-size: 16px;
  font-weight: 600;
}

.hint-left .hint-icon {
  color: var(--swipe-left-color);
}

.hint-right .hint-icon {
  color: var(--swipe-right-color);
}

/* Footer Stats */
.app-footer {
  display: flex;
  justify-content: space-around;
  padding: 16px 20px;
  background: white;
  border-top: 1px solid var(--border-color);
}

.stat {
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Action Overlay */
.action-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.action-overlay.active {
  opacity: 1;
  visibility: visible;
}

.action-menu {
  background: white;
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 32px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.action-overlay.active .action-menu {
  transform: translateY(0);
}

.action-menu-title {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.action-patient-info {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.action-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 16px;
  margin-bottom: 10px;
  border: none;
  border-radius: 12px;
  background: #f0f4f5;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.action-btn:hover {
  background: #e8eff2;
}

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

.action-icon {
  font-size: 24px;
  margin-right: 16px;
}

.action-label {
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.action-shortcut {
  font-size: 14px;
  color: var(--text-light);
  margin-left: auto;
}

.action-btn-cancel {
  background: transparent;
  justify-content: center;
  color: var(--text-secondary);
  margin-top: 8px;
  margin-bottom: 0;
}

.action-btn-cancel:hover {
  background: #f0f4f5;
}

/* Empty State */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.empty-state.active {
  opacity: 1;
  visibility: visible;
}

.empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success-color);
  color: white;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

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

.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.reset-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: var(--primary-color);
  color: white;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
  z-index: 300;
  white-space: nowrap;
}

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

/* Active card indicator */
.lab-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: transparent;
  transition: background 0.2s ease;
}

.lab-card.active::before {
  background: var(--primary-color);
}

/* Responsive adjustments */
@media (min-width: 481px) {
  .app-container {
    margin-top: 20px;
    height: calc(100% - 40px);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  }
}

/* Scrollbar styling */
.results-list::-webkit-scrollbar {
  width: 4px;
}

.results-list::-webkit-scrollbar-track {
  background: transparent;
}

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