/* Dondar — Mobile First PWA */
/* Brand: red #dc2626 for blood, dark #0f172a base */

:root {
  --primary: #dc2626;
  --primary-dark: #991b1b;
  --primary-light: #fca5a5;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-dark: #0f172a;
  --text: #1e293b;
  --text-light: #64748b;
  --text-inverse: #f8fafc;
  --border: #e2e8f0;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
  --header-height: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
  min-height: 100vh;
}
body.nav-hidden {
  padding-bottom: 0;
}
body:not(.nav-hidden) {
  padding-top: var(--header-height);
}

/* Full-page landing for guests */
.guest-landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
}
.guest-landing .brand-icon { font-size: 4rem; margin-bottom: 16px; }
.guest-landing h1 { color: #fff; font-size: 2rem; margin-bottom: 4px; }
.guest-landing p { color: rgba(255,255,255,0.6); margin-bottom: 32px; max-width: 280px; }
.guest-landing .btn-primary {
  max-width: 280px;
  padding: 14px 24px;
  font-size: 1rem;
}
.guest-landing .footer-text {
  margin-top: 48px;
  color: rgba(255,255,255,0.3);
  font-size: 0.75rem;
}

/* Typography */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { font-size: 0.9rem; color: var(--text-light); }
small { font-size: 0.8rem; color: var(--text-light); }

/* Layout */
.container { padding: 16px; max-width: 480px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }

/* SVG Icons */
.icon { display: inline-block; width: 20px; height: 20px; vertical-align: middle; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 40px; height: 40px; }
.icon-nav { width: 24px; height: 24px; }
.icon-white { color: #fff; }
.icon-white svg, .icon-white path { fill: #fff; }
.icon-muted svg, .icon-muted path { fill: var(--text-light); }
.icon-primary svg, .icon-primary path { fill: var(--primary); }

/* Header */
.header {
  background: var(--bg-dark);
  color: var(--text-inverse);
  padding: 16px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 { font-size: 1.1rem; color: var(--text-inverse); }
.header .logo { display: flex; align-items: center; gap: 8px; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions button {
  background: none; border: none; color: var(--text-inverse);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  width: 100%;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 8px 14px; font-size: 0.8rem; width: auto; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* Form Elements */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
}
select.form-control { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 40px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Blood Type Selector */
.blood-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.blood-btn {
  padding: 14px 8px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.2s;
  touch-action: manipulation;
}
.blood-btn:active { transform: scale(0.95); }
.blood-btn.selected { border-color: var(--primary); background: #fef2f2; color: var(--primary); }
.blood-btn .rhesus { font-size: 0.7rem; font-weight: 400; color: var(--text-light); display: block; }
.blood-btn.selected .rhesus { color: var(--primary); }

/* Donor List */
.donor-item {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.donor-item:last-child { border-bottom: none; }
.donor-info { flex: 1; min-width: 0; }
.donor-name { font-weight: 600; font-size: 0.95rem; }
.donor-meta { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.donor-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-a { background: #fef2f2; color: #dc2626; }
.badge-b { background: #eff6ff; color: #2563eb; }
.badge-ab { background: #f0fdf4; color: #16a34a; }
.badge-o { background: #faf5ff; color: #9333ea; }
.badge-empty { opacity: 0.4; }
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 3px;
  border-radius: 9px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(0,0,0,0.1);
}
.badge-total {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--primary);
  color: white;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: var(--safe-bottom);
  z-index: 200;
}
body.nav-hidden .bottom-nav { display: none; }
body.nav-hidden .header { display: none; }
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--text-light);
  font-size: 0.6rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: none;
  transition: color 0.2s;
  touch-action: manipulation;
}
.nav-item .icon { width: 22px; height: 22px; }
.nav-item .icon svg, .nav-item .icon path { fill: var(--text-light); transition: fill 0.2s; }
.nav-item.active { color: var(--primary); }
.nav-item.active .icon svg, .nav-item.active .icon path { fill: var(--primary); }

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}
.status-open { background: #fef3c7; color: #92400e; }
.status-contacted { background: #dbeafe; color: #1e40af; }
.status-resolved { background: #dcfce7; color: #166534; }
.status-closed { background: #f1f5f9; color: #475569; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

/* Toast */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  color: var(--text-inverse);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  z-index: 400;
  display: none;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.toast.show { display: block; animation: fadeInOut 2s ease; }
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* Loading */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}
.empty-state .empty-icon { width: 48px; height: 48px; margin: 0 auto 12px; }

/* Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}
.hero-banner h3 { color: #fff; font-size: 1.2rem; }
.hero-banner p { color: rgba(255,255,255,0.8); font-size: 0.85rem; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-box {
  padding: 16px 12px;
  border-radius: var(--radius-sm);
  text-align: center;
}
.stat-box .stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-box .stat-label { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }

/* Utility */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-light); }
.hidden { display: none !important; }

/* Login Prompt */
.login-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  min-height: 60vh;
}
.login-prompt .icon { width: 64px; height: 64px; margin-bottom: 16px; }
.login-prompt h2 { margin-bottom: 8px; }
.login-prompt p { margin-bottom: 24px; max-width: 300px; }

/* Location badge */
.loc-badge {
  font-size: 0.75rem;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-light);
}

/* RS Select */
.hospital-list { max-height: 300px; overflow-y: auto; }
.hospital-item {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}
.hospital-item:hover { background: #f8fafc; }
.hospital-item.selected { background: #fef2f2; }
.hospital-item:last-child { border-bottom: none; }
.hospital-name { font-weight: 600; font-size: 0.9rem; }
.hospital-addr { font-size: 0.8rem; color: var(--text-light); }

/* Scrollable content */
.scroll-list { max-height: 400px; overflow-y: auto; }

/* Cooldown banner */
.cooldown-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Blood icon in header */
.blood-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.blood-icon svg { width: 20px; height: 20px; }
.blood-icon svg path.red { fill: var(--primary); }
