/* ANVION IT SERVICES — shared mobile/tablet responsiveness.
   Loaded after page-level styles so these layout corrections apply consistently. */

html,
body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
  min-width: 0;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

img,
video {
  height: auto;
}

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

input,
select,
textarea {
  font-size: 16px;
}

pre,
code {
  overflow-wrap: anywhere;
}

@media (max-width: 767px) {
  body {
    min-width: 0 !important;
    width: 100% !important;
  }

  main,
  header,
  footer,
  section,
  article,
  .max-w-7xl,
  .max-w-6xl,
  .max-w-5xl,
  .max-w-4xl,
  .max-w-3xl,
  .max-w-2xl {
    max-width: 100%;
  }

  /* Avoid fixed-width glow layers and decorative elements widening the page. */
  .hero-glow,
  .ambient-orb,
  .bg-glow,
  [class*="w-[600px]"],
  [class*="w-[500px]"],
  [class*="w-[450px]"],
  [class*="w-[400px]"],
  [class*="w-[350px]"] {
    width: min(78vw, 24rem) !important;
    height: min(78vw, 24rem) !important;
    max-width: 100vw !important;
    pointer-events: none;
  }

  /* One-column content flow is easier to scan and interact with on phones. */
  main .grid,
  #contentArea .grid,
  #dashboardMain .grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  main .flex:not(.flex-col),
  #contentArea .flex:not(.flex-col),
  #dashboardMain .flex:not(.flex-col) {
    flex-wrap: wrap;
  }

  main h1 {
    font-size: clamp(1.8rem, 7.5vw, 2.5rem) !important;
    line-height: 1.15 !important;
    overflow-wrap: anywhere;
  }

  main h2 {
    font-size: clamp(1.35rem, 5.5vw, 1.9rem);
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  main h3,
  main p,
  main li,
  main a {
    overflow-wrap: anywhere;
  }

  /* Normalize horizontal gutters for page templates with desktop-sized padding. */
  main [class*="px-12"],
  main [class*="px-10"],
  main [class*="px-8"],
  main [class*="px-6"],
  header > div[class*="px-"] {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  main [class*="py-[120px]"] {
    padding-top: 2.5rem !important;
    padding-bottom: 2.5rem !important;
  }

  /* Forms and calls to action should use the available screen width. */
  form,
  form input:not([type="checkbox"]):not([type="radio"]),
  form select,
  form textarea {
    width: 100%;
    max-width: 100%;
  }

  form label {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  button,
  input[type="button"],
  input[type="submit"],
  input[type="reset"] {
    min-height: 42px;
  }

  /* Wide data tables remain readable with intentional horizontal touch scrolling. */
  .table-responsive,
  .overflow-x-auto,
  [class*="overflow-x-auto"] {
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  table {
    max-width: 100%;
  }

  .table-responsive table,
  .overflow-x-auto table,
  [class*="overflow-x-auto"] table {
    min-width: 34rem;
  }

  /* Keep floating actions inside the viewport and clear of the screen edge. */
  .whatsapp-float {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  #toast-container {
    left: 12px;
    right: 12px;
    width: auto;
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }

  /* Universal drawer generated by navbar.js. */
  #anvionMobileDrawer {
    width: 100vw;
    max-width: 100vw;
  }

  #mobileDrawerPanel {
    width: min(20rem, 88vw);
    max-width: 88vw;
    padding: 1rem;
  }

  /* Admin command centre: preserve its scroll area and make the sidebar fit. */
  body:has(#sidebar) {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden !important;
  }

  body:has(#sidebar) > .flex-1 {
    width: 100%;
    min-width: 0;
    height: 100dvh !important;
    padding-left: 0 !important;
  }

  #sidebar {
    width: min(17rem, 88vw);
    max-width: 88vw;
  }

  #contentArea {
    padding: 1rem !important;
    min-width: 0;
  }

  #contentArea .content-section {
    min-width: 0;
  }

  body:has(#sidebar) header {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    gap: 0.5rem;
  }

  /* Client dashboard and authentication layouts. */
  #dashboardMain {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  header .flex.items-center.gap-4,
  header .flex.items-center.gap-3,
  header .flex.items-center.gap-3\.5 {
    min-width: 0;
  }

  /* Prevent long URLs, emails and code samples from stretching cards. */
  [class*="truncate"],
  [class*="break-words"] {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 420px) {
  main [class*="p-8"],
  main [class*="p-10"],
  main [class*="p-12"] {
    padding: 1rem !important;
  }

  header > div {
    gap: 0.5rem;
  }

  .whatsapp-float {
    padding: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
