/* Mangaia admin-only responsive safeguards. */

html,
body,
#root {
  max-width: 100%;
  overflow-x: clip;
}

body > #root main,
body > #root section {
  min-width: 0;
}

/* Every interactive dashboard control must remain comfortably tappable. */
div.grid.min-h-screen.bg-slate-50.text-slate-950 button,
div.grid.min-h-screen.bg-slate-50.text-slate-950 a,
div.grid.min-h-screen.bg-slate-50.text-slate-950 select,
div.grid.min-h-screen.bg-slate-50.text-slate-950 input {
  min-height: 42px;
}

/* Between Tailwind lg and xl, use compact grouped navigation instead of the
   300px desktop sidebar. */
@media (min-width: 1024px) and (max-width: 1279px) {
  div.grid.min-h-screen.bg-slate-50.text-slate-950 {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 > aside {
    display: none !important;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 > section > div.border-b.bg-white {
    display: block !important;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 > section > main {
    padding: 1.25rem !important;
  }

  /* The admin orders table contains 13 columns. Hide secondary detail columns
     on landscape tablets; every hidden field remains available in order detail. */
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] {
    min-width: 880px !important;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] th:nth-child(4),
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] td:nth-child(4),
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] th:nth-child(5),
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] td:nth-child(5),
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] th:nth-child(6),
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] td:nth-child(6),
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] th:nth-child(11),
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] td:nth-child(11),
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] th:nth-child(12),
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] td:nth-child(12) {
    display: none;
  }
}

/* Keep headings readable without taking over most of a tablet screen. */
div.grid.min-h-screen.bg-slate-50.text-slate-950 main h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.2;
}

/* Tables scroll inside their own cards and never widen the whole dashboard. */
div.grid.min-h-screen.bg-slate-50.text-slate-950 main .overflow-x-auto {
  max-width: 100%;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

/* The compact navigation rows are sticky and use snap points so items do not
   stop half-visible after a swipe. */
div.grid.min-h-screen.bg-slate-50.text-slate-950 > section > div.border-b.bg-white {
  position: sticky;
  top: 66px;
  z-index: 20;
}

div.grid.min-h-screen.bg-slate-50.text-slate-950 > section > div.border-b.bg-white .overflow-x-auto {
  scroll-snap-type: inline proximity;
}

div.grid.min-h-screen.bg-slate-50.text-slate-950 > section > div.border-b.bg-white a,
div.grid.min-h-screen.bg-slate-50.text-slate-950 > section > div.border-b.bg-white button {
  scroll-snap-align: start;
}

@media (max-width: 767px) {
  div.grid.min-h-screen.bg-slate-50.text-slate-950 > section > header {
    align-items: center;
    min-height: 64px;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 > section > main {
    padding: 0.875rem !important;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 main h1 {
    font-size: 1.75rem;
  }

  /* The orders list becomes touch-friendly cards instead of a sideways table.
     Full customer, payment, delivery and item details remain on the order page. */
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] {
    display: block;
    min-width: 0 !important;
    width: 100%;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] thead {
    display: none;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody {
    display: grid;
    gap: 0.875rem;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.45rem 0.75rem;
    border: 1px solid rgb(226 232 240);
    border-radius: 1.25rem;
    background: white;
    padding: 1rem;
    box-shadow: 0 8px 25px rgb(15 23 42 / 0.06);
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody td {
    display: none;
    min-width: 0;
    padding: 0 !important;
    border: 0;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Order number */
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody td:nth-child(1) {
    display: block;
    grid-column: 1;
    grid-row: 1;
    overflow-wrap: anywhere;
    color: rgb(180 83 9);
    font-size: 1rem;
  }

  /* Customer */
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody td:nth-child(2) {
    display: block;
    grid-column: 1;
    grid-row: 2;
    font-weight: 800;
  }

  /* Area */
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody td:nth-child(7) {
    display: block;
    grid-column: 1;
    grid-row: 3;
    color: rgb(100 116 139);
    font-size: 0.875rem;
  }

  /* Status */
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody td:nth-child(10) {
    display: flex;
    grid-column: 2;
    grid-row: 1 / span 2;
    align-items: start;
    justify-content: end;
  }

  /* Actions */
  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody td:nth-child(13) {
    position: static !important;
    display: block;
    grid-column: 1 / -1;
    grid-row: 4;
    margin-top: 0.5rem;
    padding-top: 0.75rem !important;
    border-top: 1px solid rgb(241 245 249);
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody td:nth-child(13) > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  div.grid.min-h-screen.bg-slate-50.text-slate-950 main table[class*="min-w-[1320px]"] tbody td:nth-child(13) button {
    width: 100%;
    white-space: normal;
  }
}
