/* =========================================================
   READY SET DRIVE - MOBILE STYLES
   RSD v0.23
========================================================= */

/* =========================================
   STUDENT REGISTRATION
========================================= */

@media (max-width: 900px) {

  #student-form {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-field.wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {

  .student-modal-overlay {
    padding: 12px;
  }

  .student-form-card {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
  }

  .student-form-header {
    position: relative;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    padding-right: 42px;
    padding-bottom: 12px;
  }

  .student-form-header h3 {
    font-size: 18px;
  }

  .student-form-header p {
    line-height: 1.4;
  }

  .student-modal-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
  }

  #student-form {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .form-field,
  .form-field.wide,
  .form-field.full-width {
    grid-column: 1 / -1;
  }

  .form-section-title {
    margin-top: 4px;
  }

  #student-form input,
  #student-form select,
  #student-form textarea {
    min-height: 44px;
    font-size: 16px;
  }

  #student-form textarea {
    min-height: 90px;
  }

  .student-form-actions {
    flex-direction: column-reverse;
    gap: 10px;
    padding-top: 8px;
  }

  #student-form button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }
}

/* =========================================
   DASHBOARD
========================================= */
@media (max-width: 768px) {

  .container {
    padding: 20px 14px;
  }

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

  .dashboard-card {
    padding: 16px;
    border-radius: 12px;
  }

  .dash-top {
    align-items: flex-start;
  }

  /* Up Next header wrap */
  .upnext-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .upnext-controls {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  .upnext-controls select {
    min-width: 60px;
  }

  .dash-value {
    font-size: 26px;
  }

  .today-list {
    max-height: 200px;
  }

  .today-item {
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 0;
    gap: 2px;
    font-size: 14px;
  }

  .today-time {
    font-size: 13px;
  }

  .today-name {
    font-size: 13px;
  }

  /* =========================================
    MOBILE TOUCH POLISH
  ========================================= */

  /* Make dropdown easier to tap */
  .upnext-controls select {
    height: 32px;
    font-size: 14px;
  }

  /* Improve readability */
  .dash-label {
    font-size: 12px;
  }

}

/* ==========================
   MOBILE NAVIGATION
========================== */

@media (max-width: 768px) {

  .app-nav {
    height: auto;
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .nav-brand {
    text-align: center;
  }

  .nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-links button {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
    padding: 10px;
  }

  #logoutBtn {
    flex: 0 0 100%;
    max-width: 180px;
    margin: 0 auto;
    }

}

/* =========================================
   STUDENTS PAGE
========================================= */

@media (max-width: 768px) {

  .page-header {
    padding-right: 0;
    margin-bottom: 16px;
  }

  #toggle-student-form {
    margin-bottom: 0;
  }

  .student-controls {
    gap: 12px;
  }

  .student-top-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .student-filters {
    width: 100%;
    gap: 8px;
  }

  .student-filters .filter-btn {
    flex: 1;
    min-height: 40px;
  }

  .student-search {
    width: 100%;
    margin-left: 0;
  }

  .student-search input {
    width: 100%;
    margin: 0;
    min-height: 42px;
    box-sizing: border-box;
  }

  .student-toolbar {
    width: 100%;
    justify-content: space-between;
    margin-bottom: 0;
    white-space: normal;
  }

  .student-limit-control {
    font-size: 13px;
  }

  .student-limit-control select {
    min-height: 34px;
  }

  .student-count {
    text-align: right;
    font-size: 13px;
  }

  .priority-filters {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .priority-btn {
    flex: 0 0 auto;
    min-height: 40px;
    margin-right: 0;
    white-space: nowrap;
    border-radius: 6px;
  }

  .student-section-title {
    margin-top: 20px;
  }

  .students-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .student-card {
    padding: 14px;
  }
}

/* =========================================
   STUDENT PROFILE
========================================= */

@media (max-width: 768px) {

  #student-detail {
    width: 100%;
  }

  .back-btn {
    min-height: 40px;
    margin-bottom: 12px;
    padding: 6px 0;
    text-align: left;
  }

  .student-profile-header {
    margin-bottom: 16px;
  }

  .student-profile-header h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.25;
  }

  .student-top-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
  }

  .student-top-grid .dashboard-card {
    padding: 14px;
  }

  .notes-card {
    grid-column: auto;
    margin-top: 0;
  }

  .status-row,
  .finance-row,
  .progress-row {
    gap: 12px;
  }

  #studentRating {
    width: auto;
    max-width: 170px;
    min-height: 40px;
  }

  #student-notes {
    min-height: 110px;
    font-size: 16px;
  }

  #save-notes {
    width: 100%;
    min-height: 42px;
  }

  #toggle-test-history {
    min-height: 40px;
  }

  #test-history-wrap,
  #student-lessons {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tests-table,
  .lesson-table {
    min-width: 620px;
  }

  .lesson-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
  }

  .lesson-filters button {
    flex: 1;
    min-height: 40px;
    margin-right: 0;
  }

  .lesson-table th,
  .lesson-table td {
    padding: 10px 8px;
    white-space: nowrap;
  }

  .lesson-table button {
    min-width: 38px;
    min-height: 38px;
    padding: 6px;
  }
}

/* =========================================
   WEEKLY CALENDAR
========================================= */

@media (max-width: 768px) {

  .weekly-calendar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .weekly-header,
  .weekly-body {
    min-width: 800px;
  }
}

/* =========================================
   STUDENT OPERATIONS
========================================= */

@media (max-width: 768px) {

  .operations-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .operations-toolbar > div {
    max-width: none;
  }

  #downloadReportBtn {
    width: 100%;
    min-height: 40px;
  }

  .operations-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #operationsTable {
    min-width: 620px;
  }

  #operationsTable th,
  #operationsTable td {
    padding: 10px 8px;
    white-space: nowrap;
  }

}

/* =========================================
   OPERATIONS TOOLBAR
========================================= */

@media (max-width: 768px) {

  .operations-toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .operations-selection {
    text-align: center;
  }

  .operations-actions {
    display: flex;
    gap: 10px;
  }

  .operations-actions button {
    flex: 1;
    min-height: 40px;
  }

}

/* ========================================
   INVOICE OPTIONS — MOBILE
   ======================================== */

@media (max-width: 600px) {
  .invoice-options-overlay {
    padding: 12px;
  }

  .invoice-options-card {
    width: 100%;
    margin: 0;
    padding: 16px;
    border-radius: 12px;
  }

  .invoice-options-header {
    padding-right: 42px;
    position: relative;
  }

  .invoice-options-header .student-modal-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
  }

  #invoiceOptionsForm input,
  #invoiceOptionsForm select,
  #invoiceOptionsForm textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .invoice-options-actions {
    flex-direction: column-reverse;
  }

  .invoice-options-actions button {
    width: 100%;
    min-height: 44px;
  }
}