/* Shared phone/tablet layout overrides. Loaded after page-specific styles. */

@media (max-width: 768px) {
  html,
  body {
    overflow-x: hidden;
  }

  .container {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
  }

  header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }

  .header-content,
  .header-actions {
    align-items: stretch;
  }

  .header-content {
    gap: 1rem;
  }

  .header-actions {
    width: 100%;
    gap: 0.75rem;
  }

  .language-switch {
    align-self: flex-end;
  }

  .nav-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.35rem;
  }

  .nav-link,
  .nav-dropdown-toggle {
    min-height: 44px;
    width: 100%;
    padding: 0.65rem 0.55rem;
    justify-content: center;
    text-align: center;
    font-size: 0.88rem;
  }

  .nav-dropdown {
    min-width: 0;
  }

  .nav-dropdown-menu {
    left: 0;
    right: 0;
    top: calc(100% + 0.35rem);
    min-width: 0;
    transform: none;
  }

  .hero-title,
  .calendar-title,
  .fundraiser-title {
    overflow-wrap: anywhere;
  }

  .hero-actions,
  .fundraiser-hero-actions,
  .calendar-hero-actions,
  .calendar-inline-actions,
  .calendar-detail-actions,
  .fundraiser-inline-actions,
  .fundraiser-modal-actions,
  .wishlist-toolbar-actions,
  .wishlist-modal-actions,
  .group-settings-actions,
  .santa-actions,
  .santa-hero-actions {
    width: 100%;
  }

  .hero-actions > *,
  .fundraiser-hero-actions > *,
  .calendar-hero-actions > *,
  .calendar-inline-actions > *,
  .calendar-detail-actions > *,
  .fundraiser-inline-actions > *,
  .fundraiser-modal-actions > *,
  .wishlist-toolbar-actions > *,
  .wishlist-modal-actions > *,
  .group-settings-actions > *,
  .santa-actions > *,
  .santa-hero-actions > * {
    flex: 1 1 100%;
    min-width: 0;
  }

  .calendar-button,
  .fundraiser-link,
  .wishlist-btn,
  .users-sync-button,
  .santa-button {
    min-height: 44px;
  }

  input,
  select,
  textarea,
  button {
    max-width: 100%;
  }

  .form-row,
  .fundraiser-form-grid,
  .calendar-form-grid,
  .santa-form-grid,
  .profile-form-grid {
    grid-template-columns: 1fr;
  }

  .profile-form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .fundraiser-modal,
  .calendar-modal {
    width: min(100%, 42rem);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
  }

  .table-container,
  .fundraiser-table-container {
    max-width: 100%;
  }

  .mobile-card-table {
    width: 100%;
  }

  .mobile-card-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .mobile-card-table,
  .mobile-card-table tbody,
  .mobile-card-table tr,
  .mobile-card-table td {
    display: block;
  }

  .mobile-card-table tbody {
    padding: 0.65rem;
  }

  .mobile-card-table tr {
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
  }

  .mobile-card-table tr:last-child {
    margin-bottom: 0;
  }

  .mobile-card-table td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 0.7fr) minmax(0, 1.3fr);
    gap: 0.6rem;
    align-items: start;
    padding: 0.55rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    overflow-wrap: anywhere;
  }

  .mobile-card-table td:last-child {
    border-bottom: 0;
  }

  .mobile-card-table td::before {
    content: attr(data-label);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .mobile-card-table td[colspan] {
    display: block;
    border-bottom: 0;
    text-align: center;
  }

  .mobile-card-table td[colspan]::before {
    content: none;
  }

  .fundraiser-table-goal {
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .fundraiser-table-progress {
    min-width: min(100%, 10rem);
  }

  .users-sync-table-wrap {
    overflow-x: visible;
  }

  .calendar-layout,
  .group-settings-layout {
    grid-template-columns: 1fr;
  }

  .calendar-hero,
  .fundraiser-hero,
  .santa-hero {
    align-items: stretch;
    flex-direction: column;
    padding: 1rem;
  }

  .calendar-panel-header,
  .calendar-event-row-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-date-input-row {
    flex-wrap: wrap;
  }

  .calendar-date-input-row > input[type="text"] {
    flex: 1 1 100%;
    min-width: 0;
  }

  .calendar-date-picker-btn {
    flex: 1 1 auto;
  }

  .santa-tabs {
    flex-direction: column;
  }

  .santa-tab {
    width: 100%;
    min-height: 44px;
  }

  .santa-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .santa-roster-row {
    grid-template-columns: 1fr;
  }

  .santa-role-label {
    text-align: left;
  }

  .group-card,
  .member-card {
    padding: 1.15rem;
  }

  .group-icon,
  .member-icon {
    width: 72px;
    height: 72px;
  }

  .profile-date-input-row {
    flex-wrap: wrap;
  }

  .profile-date-input-row > input[type="text"] {
    flex: 1 1 100%;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0.75rem;
  }

  .logo {
    font-size: 1.3rem;
  }

  h1 {
    font-size: 1.65rem;
  }

  .stats-grid,
  .cards-grid,
  .santa-stats,
  .santa-money-pair {
    grid-template-columns: 1fr;
  }

  .mobile-card-table td {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .mobile-card-table td::before {
    font-size: 0.68rem;
  }

  .fundraiser-table-goal {
    align-items: flex-start;
    flex-direction: column;
  }

  .fundraiser-table-progress {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
