/* Global mobile-first polish (safe, additive overrides) */

/* Base touch targets and typography */
@media (max-width: 576px) {
  html, body { font-size: 16px; }
  body { -webkit-text-size-adjust: 100%; }

  /* Buttons: improve tap targets */
  .btn { min-height: 44px; line-height: 1.25; }
  .btn-sm { min-height: 38px; }
  .btn-lg { min-height: 48px; }

  /* Form controls */
  .form-control,
  .form-select { min-height: 44px; font-size: 1rem; }
  .form-check-input { width: 1.1rem; height: 1.1rem; }

  /* Tighten containers and gutters */
  .container,
  .container-fluid { padding-left: 1rem; padding-right: 1rem; }

  /* Headings scale slightly down on small screens */
  h1 { font-size: clamp(1.25rem, 4.8vw, 1.75rem); }
  h2 { font-size: clamp(1.125rem, 4.2vw, 1.5rem); }
  h3 { font-size: clamp(1.05rem, 3.8vw, 1.35rem); }
}

/* Images are responsive by default */
img { max-width: 100%; height: auto; }

/* Long words and URLs shouldn't overflow */
.text-wrap,
.content,
p, li { overflow-wrap: anywhere; word-break: break-word; }

/* Tables: ensure horizontal scroll if not stacked */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Utility: stack row/inline layouts on small screens */
@media (max-width: 576px) {
  .stack-sm { display: flex; flex-direction: column !important; gap: .5rem; }
  .stack-sm > * { width: 100% !important; }
  .hide-sm { display: none !important; }
  .show-sm { display: initial !important; }
  /* Buttons in a row become a column on phones */
  .btn-row-sm { display: flex; flex-direction: column; gap: .5rem; width: 100%; }
  .btn-row-sm > .btn,
  .btn-row-sm > a.btn,
  .btn-row-sm > form > .btn,
  .btn-row-sm > * .btn { width: 100%; }
  /* Hide breadcrumbs on phones */
  .breadcrumb { display: none !important; }
  /* Sidebar: declutter on phones */
  .sidebar-title, .sidebar-divider { display: none !important; }
  .sidebar .nav-link { padding: .6rem .75rem; }
  .sidebar .store-item { grid-template-columns: 40px 1fr auto; padding: .5rem .6rem; }
  .sidebar .store-logo { width: 40px; height: 40px; }
}

/* Safe area support for devices with notches */
html, body { background-color: var(--bs-body-bg, #fff); }
@supports (padding: max(0px)) {
  .safe-bottom { padding-bottom: max(env(safe-area-inset-bottom), 1rem); }
  .safe-top { padding-top: max(env(safe-area-inset-top), 0.5rem); }
}

/* Make clickable rows and controls easier to tap */
.list-group-item,
.dropdown-item,
.nav-link { min-height: 40px; display: flex; align-items: center; }

/* Cards and sections breathe on phones */
@media (max-width: 576px) {
  .card { border-radius: .8rem; }
  .card-body { padding: 1rem; }
}

/* Dashboard-specific form polish */
.dashboard-shell .form-label { font-weight: 600; }
.dashboard-shell .form-text { font-size: .875rem; color: #6b7280; }

@media (max-width: 576px) {
  /* Stack inline filter/search forms */
  .dashboard-shell form.d-flex { flex-direction: column !important; align-items: stretch !important; gap: .5rem; }
  .dashboard-shell form.d-flex > * { width: 100% !important; }

  /* Ensure grid forms breathe edge-to-edge */
  .dashboard-shell form .row { margin-left: 0; margin-right: 0; }
  .dashboard-shell form [class*="col-"] { padding-left: 0; padding-right: 0; }

  /* Primary actions are easy to hit */
  .dashboard-shell form button[type="submit"],
  .dashboard-shell form .btn[type="submit"],
  .dashboard-shell .btn-block-sm { width: 100%; }
}

/* File inputs and selects stay readable */
.dashboard-shell input[type="file"].form-control { padding-top: .5rem; padding-bottom: .5rem; }
.dashboard-shell .form-select { min-height: 44px; }

/* Custom file button styling (modern browsers) */
.dashboard-shell input[type="file"]::file-selector-button {
  margin-right: .75rem;
  border: 1px solid var(--bs-primary, #16a34a);
  background: var(--bs-primary, #16a34a);
  color: #fff;
  padding: .45rem .9rem;
  border-radius: .5rem;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.dashboard-shell input[type="file"]:hover::file-selector-button {
  background: var(--bs-primary-hover, #0f7a47);
  border-color: var(--bs-primary-hover, #0f7a47);
}

/* Safari/WebKit fallback */
.dashboard-shell input[type="file"]::-webkit-file-upload-button {
  margin-right: .75rem;
  border: 1px solid var(--bs-primary, #16a34a);
  background: var(--bs-primary, #16a34a);
  color: #fff;
  padding: .45rem .9rem;
  border-radius: .5rem;
  cursor: pointer;
}

/* File preview area */
.dashboard-shell .file-preview img {  border-radius: .5rem; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.dashboard-shell .file-preview .file-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .5rem; border-radius: .5rem; background: #f3f4f6; color: #374151; font-size: .875rem; }
