/* Shared responsive refinements for authentication, scanner, and dashboards. */

html {
  overflow-x: clip;
}

body {
  min-width: 320px;
  overflow-x: clip;
}

.dashboard-layout,
.main-wrapper,
.main-content,
.dashboard-section,
.card,
.chart-card {
  min-width: 0;
}

.dashboard-layout {
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
}

.dashboard-layout > .main-wrapper {
  width: 100%;
  max-width: 100%;
}

.dashboard-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dashboard-card-grid > .card {
  min-width: 0;
}

.table-responsive {
  max-width: 100%;
  overscroll-behavior-x: contain;
}

.table-responsive > .table {
  min-width: 560px;
}

.chart-container-wrapper {
  min-width: 0;
}

.chart-container-wrapper canvas {
  max-width: 100%;
}

.member-profile-card,
.member-meals-card,
.member-history-card {
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.member-id-badge {
  display: grid;
  gap: 0.2rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  background: rgba(245, 158, 11, 0.08);
}

.member-id-badge strong {
  color: var(--accent);
  font-size: 1.15rem;
}

.member-section-heading,
.member-section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.member-section-heading {
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.member-section-title {
  font-size: 1.1rem;
  margin: 0;
}

.member-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.member-details dt {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.member-details dd {
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
}

.member-meal-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.member-meal-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}

.top-bar-left,
.top-bar-right,
.top-bar > form,
.card-header,
.card-body,
.card-footer,
.filter-card,
.filter-inputs-group,
.input-group {
  min-width: 0;
}

.top-bar > form {
  margin: 0;
}

.card-header {
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-header > * {
  min-width: 0;
  max-width: 100%;
}

.card-header .card-title {
  overflow-wrap: anywhere;
}

.filter-inputs-group > * {
  min-width: 0;
  max-width: 100%;
}

.filter-inputs-group .input-group .form-control {
  min-width: 0;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .staff-cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  }
}

@media (max-width: 768px) {
  .dashboard-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-layout > .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(270px, calc(100vw - 2.5rem));
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    transform: translateX(-105%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xl);
  }

  .dashboard-layout > .sidebar.open {
    left: 0;
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .hamburger {
    flex: 0 0 auto;
  }

  .dashboard-layout .main-wrapper,
  .dashboard-layout .main-content {
    width: 100%;
    max-width: 100%;
  }

  .main-content {
    padding: 1.25rem;
  }

  .top-bar {
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .top-bar-left,
  .top-bar-right {
    min-width: 0;
  }

  .top-bar-left {
    flex: 1 1 auto;
  }

  .top-bar-right {
    flex: 0 1 auto;
    gap: 0.5rem;
  }

  .user-chip {
    max-width: min(48vw, 240px);
  }

  .user-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .welcome-banner {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
  }

  .welcome-title {
    font-size: clamp(1.2rem, 5vw, 1.6rem);
    overflow-wrap: anywhere;
  }

  .filter-card,
  .filter-inputs-group {
    align-items: stretch;
  }

  .dashboard-card-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .card-header {
    align-items: flex-start;
  }

  .card-header .btn {
    white-space: normal;
  }

  .chart-container-wrapper {
    height: 260px;
  }

  .scanner-top-bar {
    gap: 0.75rem;
    padding: 0.85rem 1rem;
  }

  .scanner-top-actions {
    gap: 0.5rem;
  }
}

@media (max-width: 576px) {
  .auth-page {
    min-height: 100svh;
    padding: 1rem 0.75rem;
  }

  .auth-wrapper {
    padding: 0;
  }

  .auth-card {
    padding: 1.75rem 1.25rem;
  }

  .auth-title {
    font-size: clamp(1.35rem, 6vw, 1.65rem);
  }

  .form-grid,
  .auth-row-2col,
  .role-selector-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-layout .main-content {
    padding: 1rem 0.75rem;
  }

  .dashboard-layout .top-bar {
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .top-bar {
    padding: 0.65rem 0.75rem;
  }

  .top-bar-left {
    flex: 1 1 auto;
    gap: 0.6rem;
  }

  .top-bar-left > div {
    min-width: 0;
  }

  .top-bar-right,
  .top-bar > form {
    flex: 0 0 auto;
  }

  .page-title {
    font-size: 1.15rem;
  }

  .top-bar-right .user-chip {
    padding-right: 0.5rem;
  }

  .top-bar-right .user-chip-info,
  .top-bar-right > .user-chip > i {
    display: none;
  }

  .top-bar-right .user-chip {
    max-width: none;
    margin: 0;
  }

  .top-bar-right .avatar {
    width: 30px;
    height: 30px;
  }

  .stats-grid,
  .staff-cards-grid,
  .timing-grid,
  .member-meal-status {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.85rem;
  }

  .stat-card,
  .settings-section-card,
  .chart-card,
  .member-profile-card,
  .member-meals-card,
  .member-history-card {
    padding: 1rem;
  }

  .member-details {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-card,
  .filter-inputs-group {
    width: 100%;
    flex-direction: column;
  }

  .filter-card .form-control,
  .filter-card .form-select,
  .filter-card .btn {
    width: 100%;
  }

  .filter-inputs-group .input-group {
    width: 100%;
    max-width: none !important;
  }

  .filter-inputs-group .form-select {
    max-width: none !important;
  }

  .filter-card > :last-child {
    width: 100%;
  }

  .member-section-heading {
    align-items: flex-start;
  }

  .member-section-title {
    font-size: 1rem;
  }

  .modal-overlay {
    padding: 0.75rem;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }

  .scanner-main {
    margin: 1rem auto;
    padding: 0 0.75rem;
    gap: 1rem;
  }

  .scanner-brand {
    font-size: 1.05rem;
  }

  .scanner-top-actions {
    width: 100%;
    justify-content: center;
  }

  .chart-container-wrapper {
    height: 220px;
  }
}

@media (max-width: 380px) {
  .dashboard-layout .main-content {
    padding-right: 0.65rem;
    padding-left: 0.65rem;
  }

  .welcome-banner {
    padding: 1rem;
  }

  .stat-card {
    gap: 0.5rem;
    padding: 0.9rem;
  }

  .stat-card-value {
    font-size: 1.7rem;
  }

  .stat-card-icon {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .top-bar-clock,
  .meal-indicator {
    font-size: 0.75rem;
  }

  .auth-card {
    padding: 1.5rem 1rem;
  }
}
