/**
 * DZTECH DPDP CMS — shared responsive layout helpers
 * CSS/layout only. Does not change branding tokens or page-local colors.
 */

/* -------------------------------------------------------------------------- */
/* Base                                                                       */
/* -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
}

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

/* Prefer flexible inputs on narrow screens */
input,
select,
textarea,
button {
  max-width: 100%;
}

/* -------------------------------------------------------------------------- */
/* Auth / setup cards                                                         */
/* -------------------------------------------------------------------------- */

body:has(.login-card),
body.min-h-screen.flex {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.login-card,
.card {
  max-width: 100%;
}

@media (max-width: 639px) {
  .login-card {
    padding: 1.25rem !important;
    margin: 0.75rem;
  }
}

/* -------------------------------------------------------------------------- */
/* Console shell — sidebar drawer + mobile header                             */
/* -------------------------------------------------------------------------- */

.mobile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background-color: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
}

.mobile-header button,
#menu-toggle {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Default off-canvas when page uses transform pattern */
.sidebar {
  max-width: min(280px, 85vw);
  -webkit-overflow-scrolling: touch;
}

body.sidebar-open {
  overflow: hidden;
}

.main-content,
main {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 1023px) {
  main {
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
  }

  /* Soften large desktop paddings on phone */
  main.p-8,
  main.flex-1.p-8 {
    padding-top: 1rem !important;
    padding-bottom: 1.5rem !important;
  }
}

@media (min-width: 1024px) {
  .mobile-header {
    display: none;
  }

  body.sidebar-open {
    overflow: auto;
  }
}

/* -------------------------------------------------------------------------- */
/* Tables                                                                     */
/* -------------------------------------------------------------------------- */

.table-scroll,
.overflow-x-auto {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-scroll table,
.overflow-x-auto table {
  width: 100%;
}

/* -------------------------------------------------------------------------- */
/* Modals / overlays                                                          */
/* -------------------------------------------------------------------------- */

.modal-overlay {
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
}

.modal-content {
  width: 100% !important;
  max-width: min(600px, calc(100vw - 2rem)) !important;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  margin: auto;
}

/* Tour credentials / fixed-width modals (override hard 420px) */
.credentials-modal {
  width: min(420px, calc(100vw - 2rem)) !important;
  max-width: calc(100vw - 2rem) !important;
}

@media (max-width: 639px) {
  .credentials-modal {
    width: calc(100vw - 2rem) !important;
    max-width: calc(100vw - 2rem) !important;
    margin: 1rem auto !important;
  }
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 24px;
  }
}

/* -------------------------------------------------------------------------- */
/* Forms & touch targets                                                      */
/* -------------------------------------------------------------------------- */

.nav-link {
  min-height: 44px;
}

@media (max-width: 639px) {
  button,
  .animated-button,
  input[type="submit"],
  input[type="button"] {
    min-height: 44px;
  }

  /* Stack common header toolbars */
  header.flex,
  .flex.justify-between.items-center.mb-8 {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
}

/* -------------------------------------------------------------------------- */
/* Tour / portal containers                                                   */
/* -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: 100%;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

@media (max-width: 639px) {
  .grid.grid-cols-1.md\:grid-cols-4,
  .grid.grid-cols-1.md\:grid-cols-3 {
    gap: 1rem;
  }
}
