/* Safline — Mobile & small-screen polish */

@media (max-width: 767px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    overflow-x: hidden;
  }

  /* Clear the floating dock so the last row of content isn't covered
     (bar 3.5rem + 0.55rem gutter + breathing room + safe-area). */
  .saf-mobile-dock-pad {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Prevent iOS zoom on form focus */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Compact navbar org search: shrink placeholder only.
     Keep the input itself at 16px so iOS does not zoom on focus. */
  input.org-search-input--compact::placeholder {
    font-size: 10px !important;
    line-height: 1.2;
  }

  /* Legacy card / modal system (safline.css) */
  .card {
    padding: 16px;
    margin-bottom: 12px;
  }

  .card-title {
    font-size: 1.1rem;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    margin: 0;
    border-radius: 16px 16px 0 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 16px;
  }

  .modal-title {
    font-size: 1.15rem;
    padding-inline-end: 2rem;
  }

  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Tables — smooth horizontal scroll */
  .overflow-x-auto,
  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }

  .table th,
  .table td {
    padding: 10px 8px;
    white-space: nowrap;
  }

  /* Glass / hero sections */
  .glass-card {
    padding: 1.25rem;
  }

  .hero-section {
    padding: 2rem 1rem;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .content-wrapper {
    padding: 12px;
  }

  .main-header {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
  }

  /* Tailwind modal panels — bottom sheet on phones */
  .saf-modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .saf-modal-panel {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    border-radius: 16px 16px 0 0 !important;
    margin: 0 !important;
  }

  .saf-modal-panel--center {
    align-self: center;
    border-radius: 16px !important;
    margin: 12px !important;
    max-height: calc(100dvh - 24px) !important;
  }

  /* Modal action rows */
  .saf-modal-actions {
    flex-direction: column-reverse !important;
    align-items: stretch !important;
  }

  .saf-modal-actions > * {
    width: 100%;
    justify-content: center;
  }

  /* Card stat grids that stay 3-col on desktop */
  .saf-stat-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .saf-stat-grid-3 > * {
    padding: 0.5rem !important;
    font-size: 0.75rem;
  }

  /* Queue booking date list */
  .saf-date-list {
    max-height: 240px !important;
  }

  /* Admin notification dropdown — fit screen */
  .saf-notif-dropdown {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: none !important;
    top: 4.5rem !important;
  }

  /* KPI numbers — slightly smaller on narrow screens */
  .saf-kpi-value {
    font-size: 1.75rem !important;
  }

  /* Calendar day cells in PersianDatePicker */
  .saf-calendar-grid {
    gap: 0.25rem !important;
  }

  .saf-calendar-day {
    font-size: 0.75rem !important;
    padding: 0.25rem !important;
    min-height: 1.75rem;
    aspect-ratio: auto !important;
  }

  /* Datepicker — fit containing block (Storybook viewport / phone), not raw dvh */
  .saf-datepicker-panel {
    max-height: 100% !important;
    align-self: flex-end !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
  }

  .saf-datepicker-actions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
  }

  .saf-datepicker-actions > button {
    width: 100%;
  }
}

@media (min-width: 640px) {
  .saf-datepicker-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .saf-datepicker-actions > button {
    flex: 1 1 auto;
    width: auto;
  }

  .saf-datepicker-actions > div {
    display: contents;
  }
}

/* Filter bar — desktop baseline removed: SafFilterBar is Tailwind-only (Phase 0 hygiene). */

@media (max-width: 480px) {
  .saf-stat-grid-3 {
    grid-template-columns: 1fr;
  }

  .saf-stat-grid-3 > * {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: start !important;
  }
}

/* Share poster modal — image shrinks to remaining flex space (no body scroll). */
.saf-share-poster-frame {
  flex: 0 1 auto;
  min-height: 0;
  height: min(62dvh, 680px);
  width: auto;
  max-width: 100%;
  aspect-ratio: 9 / 16;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.saf-share-poster-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Safe-area and viewport-unit rules live in css/viewport.css.
   .saf-fixed-top moved there; .saf-fixed-top-offset was unused and was dropped. */
