/**
 * Mobile Responsive Design System
 *
 * Breakpoints:
 * - Mobile: 320px - 480px
 * - Tablet: 481px - 768px
 * - Small Desktop: 769px - 1024px
 * - Desktop: 1025px+
 */

/* ─────────────────────────────────────────────────────────────
   MOBILE FIRST - BASE STYLES FOR MOBILE
   ───────────────────────────────────────────────────────────── */

:root {
  --mobile-padding: 12px;
  --tablet-padding: 16px;
  --desktop-padding: 24px;

  --mobile-gap: 8px;
  --tablet-gap: 12px;
  --desktop-gap: 16px;

  --mobile-font: 14px;
  --tablet-font: 14px;
  --desktop-font: 16px;
}

/* ─────────────────────────────────────────────────────────────
   NAVBAR - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .navbar {
    padding: 12px 16px !important;
    flex-direction: column;
    gap: 12px;
    align-items: stretch !important;
  }

  .navbar h1 {
    font-size: 1.2rem !important;
    text-align: center;
  }

  .navbar > div {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  .navbar span {
    text-align: center;
  }

  .logout-btn {
    width: 100%;
  }
}

/* ─────────────────────────────────────────────────────────────
   CONTAINER - RESPONSIVE PADDING
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .container {
    padding: 12px !important;
    max-width: 100% !important;
  }
}

@media (481px) and (max-width: 768px) {
  .container {
    padding: 16px !important;
    max-width: 100% !important;
  }
}

@media (min-width: 769px) {
  .container {
    padding: 24px !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   TABS - RESPONSIVE LAYOUT
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .tabs {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
  }

  .tab-btn {
    padding: 10px 12px !important;
    font-size: 0.85rem !important;
  }
}

@media (481px) and (max-width: 768px) {
  .tabs {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 20px !important;
  }

  .tab-btn {
    padding: 11px 14px !important;
    font-size: 0.9rem !important;
  }
}

@media (min-width: 769px) {
  .tabs {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   METRIC GRID - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .metric-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }

  .metric-card {
    padding: 16px !important;
  }

  .metric-value {
    font-size: 1.5rem !important;
  }
}

@media (481px) and (max-width: 768px) {
  .metric-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    margin-bottom: 20px !important;
  }

  .metric-card {
    padding: 18px !important;
  }

  .metric-value {
    font-size: 1.75rem !important;
  }
}

@media (min-width: 769px) {
  .metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 16px !important;
  }

  .metric-value {
    font-size: 2rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   CHARTS - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .chart-wrapper {
    height: 250px !important;
    margin-bottom: 16px !important;
  }

  .chart-container {
    padding: 16px !important;
    margin-bottom: 16px !important;
  }

  .chart-title {
    font-size: 0.95rem !important;
  }
}

@media (481px) and (max-width: 768px) {
  .chart-wrapper {
    height: 300px !important;
    margin-bottom: 20px !important;
  }

  .chart-container {
    padding: 18px !important;
  }

  .chart-title {
    font-size: 1rem !important;
  }
}

@media (min-width: 769px) {
  .chart-wrapper {
    height: 350px !important;
  }

  .chart-container {
    padding: 20px !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   GRID 2 COLUMN - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    margin-bottom: 16px !important;
  }
}

@media (min-width: 769px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr !important;
    gap: 24px !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   TABLES - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  table {
    font-size: 0.85rem !important;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  th, td {
    padding: 10px !important;
  }

  th {
    font-size: 0.8rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   FILTER SECTION - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .filter-section {
    flex-direction: column !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
  }

  .filter-btn {
    width: 100%;
    padding: 10px 12px !important;
    font-size: 0.85rem !important;
  }
}

@media (481px) and (max-width: 768px) {
  .filter-section {
    gap: 10px !important;
    margin-bottom: 18px !important;
  }

  .filter-btn {
    padding: 8px 14px !important;
    font-size: 0.9rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   MODAL/DIALOG - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .modal-content,
  .assessment-modal,
  .student-progress-modal {
    width: 95vw !important;
    max-height: 90vh !important;
    padding: 16px !important;
  }

  .modal-header {
    padding: 16px !important;
  }

  .modal-body {
    padding: 16px !important;
    max-height: 70vh;
    overflow-y: auto;
  }

  .modal-footer {
    padding: 16px !important;
    flex-direction: column;
    gap: 10px;
  }

  .modal-footer button {
    width: 100%;
  }
}

@media (481px) and (max-width: 768px) {
  .modal-content,
  .assessment-modal,
  .student-progress-modal {
    width: 90vw !important;
    max-height: 85vh !important;
  }

  .modal-footer button {
    flex: 1;
  }
}

/* ─────────────────────────────────────────────────────────────
   BUTTONS - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  button,
  .btn {
    padding: 10px 16px !important;
    font-size: 0.9rem !important;
    min-height: 44px;
  }

  .btn-group {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .btn-group button {
    width: 100%;
  }
}

/* ─────────────────────────────────────────────────────────────
   FORMS - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  input, textarea, select {
    font-size: 16px !important; /* Prevent zoom on iOS */
    padding: 12px !important;
    width: 100%;
  }

  .form-group {
    margin-bottom: 16px !important;
  }

  label {
    font-size: 0.9rem !important;
    margin-bottom: 6px !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   TEXT ADJUSTMENTS - MOBILE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem !important;
  }

  h2 {
    font-size: 1.25rem !important;
  }

  h3 {
    font-size: 1.1rem !important;
  }

  h4 {
    font-size: 1rem !important;
  }

  p {
    font-size: 0.95rem !important;
    line-height: 1.5;
  }

  .text-small {
    font-size: 0.8rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   TOPBAR/NAVBAR - MOBILE HAMBURGER READY
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .topbar {
    padding: 12px 14px !important;
    margin-bottom: 16px !important;
    border-radius: 12px !important;
  }

  .brand-mark {
    width: 38px !important;
    height: 38px !important;
    font-size: 1.1rem !important;
  }

  .brand-title {
    font-size: 1.2rem !important;
  }

  .brand-subtitle {
    display: none; /* Hide on mobile */
  }

  .topbar-meta {
    gap: 6px !important;
  }

  .meta-chip {
    padding: 8px 10px !important;
    font-size: 0.65rem !important;
    min-height: 36px;
  }
}

/* ─────────────────────────────────────────────────────────────
   EMPTY STATE - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .empty-state {
    padding: 24px 16px !important;
  }

  .empty-state h3 {
    font-size: 1rem !important;
  }

  .empty-state p {
    font-size: 0.9rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   LIST ITEMS - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .student-risk-item,
  .student-list-item,
  .assessment-list-item {
    padding: 12px !important;
    flex-direction: column;
    gap: 8px;
  }

  .student-name {
    font-size: 0.95rem !important;
  }

  .risk-score,
  .status-badge {
    align-self: flex-start;
  }
}

@media (481px) and (max-width: 768px) {
  .student-risk-item,
  .student-list-item {
    padding: 14px !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   INSIGHT/WARNING BOXES - RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .insight-box,
  .warning-box,
  .risk-box {
    padding: 12px !important;
    margin-bottom: 12px !important;
    border-left-width: 3px !important;
  }

  .insight-title,
  .warning-title,
  .risk-title {
    font-size: 0.95rem !important;
    margin-bottom: 6px !important;
  }

  .insight-text {
    font-size: 0.9rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   LANDSCAPE MODE - TABLET
   ───────────────────────────────────────────────────────────── */

@media (max-height: 500px) and (orientation: landscape) {
  .navbar {
    padding: 8px 12px;
  }

  .container {
    padding: 12px;
  }

  .chart-wrapper {
    height: 250px !important;
  }

  h1 {
    font-size: 1.3rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   UTILITY CLASSES
   ───────────────────────────────────────────────────────────── */

.hide-mobile {
  display: none !important;
}

@media (min-width: 769px) {
  .hide-mobile {
    display: block !important;
  }

  .hide-desktop {
    display: none !important;
  }
}

.show-mobile {
  display: block !important;
}

@media (min-width: 769px) {
  .show-mobile {
    display: none !important;
  }
}

/* Touch-friendly targets */
@media (max-width: 768px) {
  button,
  a,
  input[type="checkbox"],
  input[type="radio"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Prevent iOS zoom on input focus */
@media (max-width: 768px) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Responsive text alignment */
@media (max-width: 480px) {
  .text-center-mobile {
    text-align: center;
  }
}

/* Scroll improvements for mobile */
@media (max-width: 768px) {
  html {
    scroll-behavior: auto;
  }
}
