/* Phone / portrait layout for the admin panel (loaded after the other stylesheets) */
@media (max-width: 1100px) {
  /* grid children must be allowed to shrink below their table's min-content width */
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-grid > * { min-width: 0; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 10px; }
  .topbar-left, .topbar-right { gap: 8px; }
  .topbar .flag { display: none; }
  .topbar .search-box { min-width: 0; width: 36px; padding: 0; justify-content: center; }
  .topbar .search-box span { display: none; }
  .topbar .user-menu { padding: 2px; }

  .content { padding-left: 10px; padding-right: 10px; padding-bottom: 80px; }
  .card { border-radius: 16px; margin-bottom: 12px; }
  .card-header { padding-left: 14px; padding-right: 14px; }
  .card-body { padding: 14px; }
  .card-footer { padding: 10px 14px; }
  .page-title-bar h2 { font-size: 18px; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
  .stat-card .stat-icon { width: 42px; height: 42px; font-size: 17px; }
  .stat-card .stat-value { font-size: 21px; }

  .filter-panel .fp-head, .filter-panel .fp-body, .filter-panel .fp-foot { padding-left: 14px; padding-right: 14px; }
  .dt-toolbar .dt-search { flex: 1 1 100%; }
  .dt-toolbar .dt-search input { width: 100%; }
  .tabs .tab { flex: 1 1 50%; padding: 10px 6px; }
  .tabs-nav { overflow-x: auto; scrollbar-width: thin; overscroll-behavior-x: contain; }
  .tabs-nav::-webkit-scrollbar { height: 5px; }
  .tabs-nav .tab { white-space: nowrap; }

  /* dialogs become bottom sheets */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal.lg, .modal.xl, .modal.sm { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; overflow-y: auto; }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .modal-footer { flex-wrap: wrap; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }

  .right-panel { width: 88vw; right: -92vw; }
  .net-status { right: 10px; bottom: 10px; padding: 7px 12px; font-size: 12px; border-radius: 20px; }
  .fab-islemler { right: 10px; bottom: 56px; }
  #toast-root { top: auto; bottom: 60px; left: 10px; right: 10px; }
}

/* Content that was wider than its card on phones (found by sweeping every panel page at 380px) */
@media (max-width: 768px) {
  .form-row { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .form-row > *, .form-field { min-width: 0; max-width: 100%; }
  .card-header > * { min-width: 0; max-width: 100%; }
  .fin-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .fin-card { padding: 12px 10px; }
  .fin-card .fc-value { font-size: 19px; overflow-wrap: anywhere; }
  .tile-grid { grid-template-columns: minmax(0, 1fr); }
  /* income / expense entry: summary column moves under the form */
  .card > div[style*="grid-template-columns:1fr 280px"] { grid-template-columns: minmax(0, 1fr) !important; }
  .summary-side { border-left: 0; border-top: 1px solid var(--smoke); }
  .content .d-flex.gap-1 { flex-wrap: wrap; }
  .content .d-flex.gap-1 > * { min-width: 0; max-width: 100%; }
  /* inline grids set by some pages (muhasebe summary, online payment, report tiles) */
  .dash-grid[style] { grid-template-columns: minmax(0, 1fr) !important; }
  .fin-cards[style] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .tile-grid[style] { grid-template-columns: minmax(0, 1fr) !important; }
  /* tables placed straight into a card body (no .table-wrap) scroll sideways instead of being cut */
  .card-body:has(> table) { overflow-x: auto; }
  /* agenda: calendar toolbar wraps onto two rows */
  .fc .fc-header-toolbar { flex-wrap: wrap; gap: 8px; }
  .fc .fc-toolbar-title { font-size: 17px; }
}

/* Touch phones: 16px fields stop iOS Safari from zooming in on focus */
@media (max-width: 768px) and (pointer: coarse) {
  input, select, textarea, .form-control, .form-select, .dt-toolbar .dt-search input { font-size: 16px !important; }
}
