/* Core Styling Variables */
:root {
  --bg-color: #f4f6f8;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --accent-color: #0f172a;
  --border-color: #e2e8f0;
  --blood-pos: #ef4444;
  --blood-neg: #f97316;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
}

.dashboard-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.dashboard-header {
  margin-bottom: 32px;
}

.dashboard-header h1 {
  margin: 0 0 8px 0;
  font-size: 2rem;
  font-weight: 700;
}

.dashboard-header p {
  margin: 0;
  color: var(--text-secondary);
}

/* Dynamic Grid Architecture */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  min-height: 200px;
}

/* Card Card Styles */
.card-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.card-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Header Context Within Card */
.card-header {
  padding: 20px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.avatar {
  width: 48px;
  height: 48px;
  background-color: var(--border-color);
  color: #475569;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.1rem;
  margin-right: 14px;
}

.card-meta {
  flex: 1;
}

.card-name {
  margin: 0 0 4px 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.card-id {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Dynamic Data Badges */
.blood-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: bold;
  background-color: #fee2e2;
  color: var(--blood-pos);
}

/* Body Content Structure */
.card-body {
  padding: 20px;
  flex: 1;
}

.info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.info-row:last-child {
  margin-bottom: 0;
}

.label {
  color: var(--text-secondary);
}

.value {
  font-weight: 500;
}

/* Pin Display Security Area */
.card-footer {
  padding: 16px 20px;
  background-color: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

.pin-display {
  font-family: monospace;
  font-weight: bold;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.pin-display.revealed {
  color: #16a34a;
  background-color: #dcfce7;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: normal;
}

.view-pin-btn {
  background: none;
  border: none;
  color: #2563eb;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.view-pin-btn:hover {
  background-color: #eff6ff;
}

/* Interactive States & Indicators */
.loading-state,
.error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px;
  color: var(--text-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--border-color);
  border-top-color: #2563eb;
  border-radius: 50%;
  margin: 0 auto 16px auto;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================
   Card Page Specific Styles
   ========================================== */

.profile-wrapper {
  max-width: 600px; /* Narrower container for a clean focused look */
  margin: 60px auto;
  padding: 0 20px;
}

/* Elegant Back Navigation Button */
.back-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 24px;
  transition:
    color 0.2s,
    transform 0.2s;
}

.back-btn:hover {
  color: var(--accent-color);
  transform: translateX(-4px); /* Subtle shift left on hover */
}

/* Master Profile Card Container */
.profile-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
  text-align: center;
}

.profile-card h1 {
  margin: 0 0 8px 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Structured Key-Value Grid for Details */
.profile-card .details {
  margin-top: 32px;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  text-align: left; /* Align rows cleanly to the left */
}

.profile-card .details p {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  margin: 0;
  border-bottom: 1px dashed var(--border-color);
  font-size: 1rem;
}

.profile-card .details p:last-child {
  border-bottom: none; /* Clean finish on the final item */
}

/* Distinguish Labels from Values */
.profile-card .details strong {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Styling for loading and error messages on the profile page */
#profile-content > p {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-top: 40px;
}

#profile-content h2 {
  text-align: center;
  color: var(--blood-pos);
  font-size: 1.5rem;
  margin-top: 40px;
}

#profile-content h2 > span {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 32px 0;
}

.profile-card .details strong {
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px; /* Pushes the emoji slightly away from the text label */
}

/* ==========================================
   Landing Page / Portal Styles
   ========================================== */

/* The animated gradient background */
.landing-body {
  margin: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    -45deg,
    var(--accent-color),
    var(--text-primary),
    #3b82f6,
    #1d4ed8
  );
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Background animation keyframes */
@keyframes gradientBG {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* The central card */
.landing-container {
  width: 100%;
  padding: 20px;
  display: flex;
  justify-content: center;
}

.access-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px); /* Frosted glass effect */
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: 400px;
  width: 100%;

  /* The load-in animation */
  opacity: 0;
  transform: translateY(30px);
  animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Entry animation keyframes */
@keyframes slideUpFade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Decorative Icon */
.icon-ring {
  width: 64px;
  height: 64px;
  background: #eff6ff;
  color: #3b82f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px auto;
  box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.1);
}

.access-card h1 {
  margin: 0 0 12px 0;
  color: var(--text-primary);
  font-size: 1.75rem;
}

.access-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 32px 0;
}

/* Input Form Styling */
.access-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.access-form input {
  padding: 16px 20px;
  font-size: 1.1rem;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  outline: none;
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
  text-align: center;
  letter-spacing: 1px;
}

.access-form input::placeholder {
  color: #cbd5e1;
  letter-spacing: normal;
}

/* Glowing effect when typing */
.access-form input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.access-btn {
  background-color: #3b82f6;
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 16px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition:
    background-color 0.2s,
    transform 0.1s;
}

.access-btn:hover {
  background-color: #2563eb;
}

.access-btn:active {
  transform: scale(0.98); /* Satisfying button click squish */
}

.hidden {
  display: none !important;
}

/* Call buttons list */
.phone-call-btn {
  display: block;
  background-color: #065b9c;
  color: white;
  text-decoration: none;
  padding: 10px;
  border-radius: 6px;
  margin-top: 8px;
  text-align: center;
  font-weight: bold;
}
