/* ============================================================
   HemoLinker – Responsive Design
   Mobile-first breakpoints
   ============================================================ */

/* -------------------------------------------------------
   BREAKPOINTS:
   sm:  640px
   md:  768px
   lg:  1024px
   xl:  1280px
   ------------------------------------------------------- */

/* -------------------------------------------------------
   LARGE (max-width: 1280px)
   ------------------------------------------------------- */
@media (max-width: 1280px) {
  .hero-inner {
    gap: var(--space-10);
  }

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

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

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

  .steps-grid::before { display: none; }
}

/* -------------------------------------------------------
   LARGE (max-width: 1024px)
   ------------------------------------------------------- */
@media (max-width: 1024px) {
  /* Nav */
  .nav-links { display: none; }
  .nav-toggle { display: flex; }

  .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    padding: var(--space-4) var(--space-6);
    gap: var(--space-2);
    z-index: 999;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.25s ease;
  }

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

  /* Hero */
  .hero-inner {
    grid-template-columns: 1fr;
    text-align: center;
    padding: var(--space-16) var(--space-6);
  }

  .hero-subtitle { max-width: 100%; margin-inline: auto; }
  .hero-actions  { justify-content: center; }
  .hero-stats    { justify-content: center; }
  .hero-visual   { display: none; }

  /* Grid */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  /* Auth — the story panel is desktop only, so the form takes the full width.
     (.auth-page is the current markup; .auth-container is the older card.) */
  .auth-visual { display: none; }
  .auth-page { grid-template-columns: minmax(0, 1fr); }
  .auth-container { grid-template-columns: 1fr; max-width: 500px; }

  /* Dashboard */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: var(--shadow-2xl);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-close { display: flex; }

  .main-content {
    margin-left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    backdrop-filter: blur(4px);
  }

  .sidebar-overlay.active { display: block; }

  /* Admin grid */
  .admin-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* -------------------------------------------------------
   MEDIUM (max-width: 768px)
   ------------------------------------------------------- */
@media (max-width: 768px) {
  /* Section */
  .section { padding: var(--space-16) var(--space-4); }
  .page-content { padding: var(--space-5); }

  /* Grid */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .steps-grid { grid-template-columns: 1fr; }

  /* Hero */
  .hero-title { font-size: 2rem; }
  .hero-subtitle { font-size: 1rem; }
  .hero-actions { flex-direction: column; align-items: center; }
  .hero-stats   { gap: var(--space-6); }

  /* Auth — the wrapper already provides the side gutter, so the panel only
     adds vertical rhythm; doubling both squeezed the fields on phones. */
  .auth-panel { padding: var(--space-8) 0; }

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

  .admin-stat-grid { grid-template-columns: 1fr 1fr; }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-wrap { min-width: 100%; }

  /* Table */
  .table-wrap { font-size: 0.8rem; }
  th, td { padding: var(--space-2) var(--space-3); }

  /* Profile */
  .profile-header {
    flex-direction: column;
    text-align: center;
    padding: var(--space-6);
  }

  .profile-info .meta { justify-content: center; }

  /* Footer */
  .footer-grid { grid-template-columns: 1fr; gap: var(--space-6); }
  .footer-bottom { flex-direction: column; gap: var(--space-3); text-align: center; }

  /* Page header */
  .page-header-inner { flex-direction: column; }

  /* Buttons */
  .btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: 0.9rem;
  }

  /* Modal */
  .modal {
    max-width: 100%;
    margin: var(--space-4);
    border-radius: var(--radius-lg);
  }

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

  /* Toast */
  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
  }
  .toast { max-width: 100%; }

  /* Chatbot */
  .chatbot-container { height: 420px; }

  /* Inventory */
  .inventory-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Quick actions */
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* -------------------------------------------------------
   SMALL (max-width: 480px)
   ------------------------------------------------------- */
@media (max-width: 480px) {
  html { font-size: 15px; }

  .nav-inner { padding: 0 var(--space-4); }
  .nav-logo-text { display: none; }

  /* Stats */
  .stats-row { grid-template-columns: 1fr; }
  .admin-stat-grid { grid-template-columns: 1fr; }
  .hero-stats { flex-direction: column; align-items: center; gap: var(--space-4); }

  /* Table scroll hint */
  .table-wrap { border-radius: var(--radius-md); }

  /* Inventory */
  .inventory-grid { grid-template-columns: 1fr 1fr; }

  /* Donor card */
  .donor-card-stats { flex-direction: column; gap: var(--space-4); }
  .donor-profile-card { padding: var(--space-6); }

  /* Section titles */
  .section-title { font-size: 1.5rem; }

  /* Auth */
  .auth-panel-wrap {
    padding: var(--space-6) var(--space-4);
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
    padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
  }
  .auth-panel { padding: var(--space-6) 0; }
  .auth-title { font-size: 1.4rem; }

  /* Page title */
  .page-title { font-size: 1.4rem; }

  /* Quick actions */
  .quick-actions { grid-template-columns: 1fr 1fr; }

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

  /* Chat */
  .chatbot-container { height: 380px; }
  .chat-bubble { max-width: 88%; }

  /* CTA */
  .cta-section { padding: var(--space-16) var(--space-4); }
  .cta-title   { font-size: 1.75rem; }
}

/* -------------------------------------------------------
   PRINT STYLES
   ------------------------------------------------------- */
@media print {
  .nav, .sidebar, .toast-container, .btn, footer { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: white; color: black; }
  .card, .stat-card { box-shadow: none; border: 1px solid #ddd; }
}

/* -------------------------------------------------------
   HELPER CLASSES (responsive show/hide)
   ------------------------------------------------------- */
.hide-mobile  { }
.show-mobile  { display: none; }

@media (max-width: 768px) {
  .hide-mobile  { display: none !important; }
  .show-mobile  { display: block !important; }
  .flex-mobile-col { flex-direction: column; }
}

/* Form 2-column grid */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

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