/**
 * TinkerToli — mobile & tablet layout (presentation only).
 * Pair with #tt-nav-toggle in dashboard layout for off-canvas sidebar.
 */

/* —— Base mobile polish —— */
html {
  -webkit-text-size-adjust: 100%;
}

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

/* —— Off-canvas sidebar (dashboard) —— */
.tt-nav-toggle {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.tt-nav-scrim {
  display: none;
}

.tt-nav-menu-btn {
  display: none;
}

@media (max-width: 767px) {
  body:has(#tt-nav-toggle:checked) {
    overflow: hidden;
  }

  .tt-nav-scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.45);
    -webkit-tap-highlight-color: transparent;
  }

  #tt-nav-toggle:checked ~ .tt-nav-scrim {
    display: block;
  }

  .tt-nav-menu-btn {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
    padding: 0;
    border: 1px solid var(--tt-border, #e2e8f0);
    border-radius: 0.5rem;
    background: #fff;
    color: #334155;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    -webkit-tap-highlight-color: transparent;
  }

  .tt-nav-menu-btn:active {
    background: #f8fafc;
  }

  .tt-nav-menu-icon {
    display: block;
    width: 1.25rem;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
  }

  .tt-app-shell {
    flex-direction: row;
  }

  .tt-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    width: min(18rem, 88vw);
    max-width: 88vw;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }

  #tt-nav-toggle:checked ~ .tt-app-shell .tt-sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
  }

  .tt-main-header {
    padding: 0.75rem 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .tt-page-title {
    font-size: 1.125rem;
    line-height: 1.5rem;
  }

  .tt-main-content {
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .tt-header-row {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
    gap: 0.75rem;
  }

  .tt-header-row .tt-page-title {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tt-main-header > .flex.flex-wrap.items-center.justify-between {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .tt-main-header > .flex.flex-wrap.items-center.justify-between > .flex.flex-wrap.gap-2 {
    width: 100%;
  }

  .tt-main-header > .flex.flex-wrap.items-center.justify-between > .flex.flex-wrap.gap-2 .tt-btn {
    flex: 1 1 auto;
    min-width: 0;
  }

  .tt-back-link--header {
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
  }

  /* Filters & forms */
  .tt-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.875rem;
  }

  .tt-filter-bar > *,
  .tt-filter-bar .flex {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
  }

  .tt-filter-bar .tt-btn {
    width: 100%;
  }

  .min-w-\[200px\],
  .min-w-\[220px\],
  .min-w-\[10rem\] {
    min-width: 0 !important;
  }

  .w-40 {
    width: 100% !important;
  }

  #center-filter-root .tt-select,
  #center-filter-root .min-w-\[200px\] {
    width: 100%;
    min-width: 0;
  }

  /* Tables */
  .tt-table-wrap {
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    border-radius: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .tt-table-wrap .overflow-x-auto,
  .overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tt-table {
    font-size: 0.8125rem;
  }

  .tt-table td,
  .tt-table th {
    padding: 0.625rem 0.75rem;
  }

  /* Cards & stats */
  .tt-card-pad {
    padding: 1rem;
  }

  .tt-stat-card {
    padding: 1rem;
  }

  .tt-stat-card .text-3xl {
    font-size: 1.5rem;
    line-height: 2rem;
  }

  .tt-pager {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .tt-pager__actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .tt-center-section__head {
    flex-direction: column;
    align-items: flex-start;
  }

  .tt-main-content section > .flex.flex-wrap.items-center.justify-between,
  .tt-main-content section > .mb-4.flex.flex-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .tt-main-content section .flex.flex-wrap.items-end.gap-4 {
    flex-direction: column;
    align-items: stretch;
  }

  .tt-main-content section .flex.flex-wrap.items-end.gap-4 .tt-btn,
  .tt-main-content section .flex.flex-wrap.items-end.gap-4 button {
    width: 100%;
  }

  /* Notifications in sidebar */
  .tt-notif-dropdown {
    position: fixed;
    left: 50%;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(20rem, calc(100vw - 2rem));
    max-height: min(70vh, 24rem);
    margin: 0;
  }

  #notifications-panel.relative {
    position: static;
  }

  /* Modals / dialogs (attendance etc.) */
  [role="dialog"],
  .fixed.inset-0 {
    padding: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .fixed.inset-0 > div,
  .fixed.inset-0 > form {
    max-width: 100% !important;
    width: 100% !important;
    margin: auto;
  }

  /* Login */
  .tt-login-page {
    padding: 1rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .tt-login-card {
    padding: 1.5rem;
    border-radius: 0.75rem;
  }

  /* Home */
  main.flex.min-h-screen {
    padding: 1.5rem 1rem;
    text-align: center;
  }

  main.flex.min-h-screen h1 {
    font-size: 1.5rem;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .tt-table td,
  .tt-table th {
    padding: 0.5rem 0.5rem;
    font-size: 0.75rem;
  }

  .tt-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
}

/* Tablet: slightly tighter than desktop */
@media (min-width: 768px) and (max-width: 1023px) {
  .tt-sidebar {
    width: 14rem;
  }

  .tt-main-content {
    padding: 1.25rem;
  }
}
