/* Mobile-first responsive overrides — SEAG Success */

/* ── Bottom-sheet modals on mobile ── */
@media (max-width: 767px) {
  /* Convert center-aligned modals to bottom-sheets */
  [role="dialog"].fixed {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  [role="dialog"].fixed > div:first-child {
    border-radius: 1.25rem 1.25rem 0 0 !important;
    max-height: 90vh !important;
    width: 100% !important;
    max-width: 100% !important;
    animation: slideUp 0.2s ease-out;
  }

  /* Bottom-sheet drag handle indicator */
  [role="dialog"].fixed > div:first-child::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 4px;
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* Larger tap targets on mobile */
  button, a, [role="button"], .cursor-pointer {
    min-height: 44px;
    min-width: 44px;
  }
  /* Exception: inline links and tiny icon buttons */
  a.text-xs, a.text-sm, .text-xs button, .text-sm button {
    min-height: auto;
    min-width: auto;
  }

  /* Form inputs: taller on mobile */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  textarea,
  select {
    min-height: 44px !important;
    font-size: 16px !important; /* Prevent iOS zoom on focus */
  }

  /* Checkbox / radio rows: taller tap area */
  label.cursor-pointer,
  label:has(input[type="checkbox"]),
  label:has(input[type="radio"]) {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Student checkboxes in assignment modal: more padding */
  .student-cb-row {
    padding: 6px 4px !important;
    min-height: 44px;
  }

  /* School nav: larger items */
  nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ── Custom Paper Builder mobile layout ── */
@media (max-width: 1023px) {
  /* Stack browser and selected panel vertically */
  .builder-grid {
    grid-template-columns: 1fr !important;
  }

  /* Selected panel collapses to a sticky bottom bar on mobile */
  .selected-panel-mobile {
    position: sticky;
    bottom: 0;
    z-index: 20;
    border-top: 2px solid #3c1053;
    max-height: 40vh;
    overflow-y: auto;
  }
}

/* ── Touch-friendly cards ── */
@media (max-width: 767px) {
  /* Assignment cards: full-width with more padding */
  .assignment-card {
    padding: 1rem !important;
  }

  /* Question cards in builder */
  .question-card {
    padding: 0.75rem !important;
  }
  .question-card .flex {
    gap: 0.5rem;
  }

  /* Tab buttons in paper builder: full-width on mobile */
  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 0.625rem 0.5rem !important;
    font-size: 0.75rem !important;
  }

  /* Sticky action bar for paper builder save */
  .builder-actions {
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 0.75rem;
    z-index: 10;
  }
}

/* ── Touch gesture support ── */
@media (pointer: coarse) {
  /* Larger drag handles on touch devices */
  .drag-handle {
    width: 32px !important;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Remove hover states that don't make sense on touch */
  .hover\:bg-gray-50:hover { background-color: inherit; }
  .hover\:bg-gray-100:hover { background-color: inherit; }
}

/* ── Responsive assignment table ── */
@media (max-width: 639px) {
  /* Convert assignment table to card layout on small screens */
  table.assignment-table thead {
    display: none;
  }
  table.assignment-table tr {
    display: block;
    margin-bottom: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.75rem;
    background: white;
  }
  table.assignment-table td {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0 !important;
    border: none !important;
  }
  table.assignment-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
  }
}

/* ── Safe area support for notched phones ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  [role="dialog"].fixed > div:first-child {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)) !important;
  }
}
/* Touch action: prevent 300ms tap delay */
html { touch-action: manipulation; }
