/* ============================================================
   KOS v5 — Responsive Adjustments
   Desktop-first (per Section 21: Mac ~80%, iPhone ~20%).
   ============================================================ */

/* Tablet: tighten spacing, drop dashboard to 2 columns */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid--secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile: collapse sidebar to a slim icon rail, stack cards */
@media (max-width: 720px) {
  :root {
    --sidebar-width: 64px;
  }

  .sidebar-logo,
  .sidebar-logo-subtitle,
  .nav-item span.nav-label {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: var(--space-3);
  }

  .nav-section-label {
    display: none;
  }

  .dashboard-command-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .dashboard-grid--primary {
    grid-template-columns: 1fr;
  }

  .dashboard-grid--secondary {
    grid-template-columns: 1fr;
  }

  .schedule-tabs {
    flex-wrap: wrap;
  }

  .app-header {
    padding: 0 var(--space-4);
  }

  .app-content {
    padding: var(--space-4);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .header-user .user-email {
    display: none;
  }
}

/* ============================================================
   Phase 5 additions — Students module
   ============================================================ */

/* Tablet: profile overview drops to a single column */
@media (max-width: 1024px) {
  .profile-overview-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile: stacked controls, card-style table rows, stacked profile header */
@media (max-width: 720px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .students-controls {
    flex-direction: column;
  }

  .students-controls select,
  .students-search {
    width: 100%;
  }

  .profile-heading {
    flex-direction: column;
  }

  .profile-actions {
    width: 100%;
  }

  .profile-actions .btn {
    flex: 1;
  }

  .modal-dialog {
    max-height: 100vh;
    border-radius: 0;
  }

  /* Responsive table -> card list */
  .data-table thead {
    position: absolute;
    left: -9999px;
    top: -9999px;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    margin-bottom: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border: none;
  }

  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
  }

  .data-table td.col-actions {
    justify-content: flex-end;
  }
}

/* ============================================================
   Phase 6 additions — Schedule and Lesson Engine
   ============================================================ */

@media (max-width: 720px) {
  .schedule-event-row {
    flex-wrap: wrap;
  }

  .schedule-event-time {
    min-width: 0;
  }

  .schedule-event-status {
    width: 100%;
    justify-content: flex-start;
    margin-top: var(--space-2);
  }
}

/* ============================================================
   Phase 7 additions — Lesson Workspace
   ============================================================ */

@media (max-width: 1024px) {
  .workspace-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace-header-top {
    flex-direction: column;
  }

  .workspace-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .notes-editor-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .notes-save-state {
    justify-content: space-between;
  }
}

/* ============================================================
   Phase 8 additions — Lesson Notes Delivery Milestone
   ============================================================ */

@media (max-width: 720px) {
  .rich-editor-toolbar {
    gap: 4px;
  }

  .toolbar-btn {
    min-width: 34px; /* larger tap targets on mobile, per Section I */
    padding: 6px 8px;
  }

  .rich-editor-content {
    min-height: 150px;
  }

  .image-thumb {
    width: 72px;
  }

  .image-thumb img,
  .image-thumb-broken {
    width: 72px;
    height: 54px;
  }

  .workspace-actions {
    /* Save/Preview/Share stay reachable without excessive scrolling */
    gap: var(--space-2);
  }
}

/* ============================================================
   Phase 8.6 additions — Teacher Workflow / UX refinement
   ============================================================ */

@media (max-width: 1024px) {
  .lesson-overview-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .lesson-overview-form {
    grid-template-columns: 1fr;
  }

  .legacy-import-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-btn--section {
    min-width: 44px; /* keep tap targets usable alongside the existing mobile toolbar rule */
  }
}
/* Dashboard 2.0 mobile — Quick Actions stay near top, timeline stacks */
@media (max-width: 1024px) {
  .dashboard-grid--snapshot { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-main-grid { grid-template-columns: 1fr; }
  .dashboard-quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .dashboard-grid--snapshot { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .card--snapshot { min-height: 88px; padding: var(--space-3); }
  .snapshot-value { font-size: var(--font-size-xl); }
  .dashboard-quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .dashboard-panel { padding: var(--space-3); }

  .timeline-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  .timeline-avatar { display: none; }
  .timeline-time { font-size: var(--font-size-sm); }
  .timeline-actions { flex-wrap: wrap; }
  .timeline-actions .btn { flex: 1; }
}

/* Memo Center + sidebar identity, mobile */
@media (max-width: 1024px) {
  .memo-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    height: auto;
  }
  .memo-sidebar { flex-direction: row; flex-wrap: wrap; }
  .memo-folder-list { flex-direction: row; flex-wrap: wrap; }
  .memo-list-pane { max-height: 240px; }
  .memo-editor-pane { min-height: 400px; }
}

@media (max-width: 720px) {
  .sidebar-logo-mark { width: 28px; height: 28px; font-size: var(--font-size-base); }
  .sidebar-logo-row > div { display: none; }
  .header-user { padding-left: var(--space-2); border-left: none; }
  .user-email { display: none; }
}

/* Final Completion Sprint — genuine mobile gap: historical-shared-grid
   (used across Leave, Payments, Akanon, and other modals) had no
   mobile breakpoint, forcing cramped 2-column fields on phones. */
@media (max-width: 720px) {
  .historical-shared-grid {
    grid-template-columns: 1fr;
  }
}
