/* GLOBAL */
* {
  box-sizing: border-box;
}

html {
  /* Base font size for better scaling */
  font-size: 16px;
  -webkit-text-size-adjust: 100%; /* Prevents font scaling in landscape */
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: #0f172a;
  color: #e5e7eb;
  margin: 0;
  padding: 16px;
  min-height: 100vh;
  padding-bottom: 80px;
  line-height: 1.5;
}

/* VIEWPORT META - Add this to your HTML head */
/* <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes"> */

/* TYPOGRAPHY SCALING */
h1 {
  font-size: clamp(1.5rem, 5vw, 2rem); /* Responsive font size */
  margin: 0.5rem 0 1rem;
}

h2 {
  font-size: clamp(1.25rem, 4vw, 1.5rem);
}

h3 {
  font-size: clamp(1.1rem, 3vw, 1.25rem);
}

p, li, td, th {
  font-size: clamp(0.875rem, 2.5vw, 1rem);
}

/* DASHBOARD STATS - Mobile First Approach */
.stats-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  background: #1e293b;
  padding: 16px 12px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  border: 1px solid #334155;
  min-height: 90px; /* Consistent height */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat div {
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: bold;
  color: #38bdf8;
  line-height: 1.2;
  margin-bottom: 4px;
}

.stat small {
  font-size: clamp(0.7rem, 2vw, 0.875rem);
  color: #94a3b8;
  display: block;
}

/* CLASS CARDS - Redesigned for mobile */
.classes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.class-card {
  background: #1e293b;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #334155;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.class-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #334155;
}

.class-title {
  font-weight: 600;
  font-size: 1.1rem;
  color: #f1f5f9;
}

.class-type {
  background: #2563eb;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: white;
}

.class-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.detail-label {
  color: #94a3b8;
}

.detail-value {
  color: #e5e7eb;
  font-weight: 500;
}

.class-actions {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  padding-top: 8px;
  border-top: 1px solid #334155;
}

/* Larger touch targets for mobile */
.status-icon {
  font-size: 28px;
  cursor: pointer;
  transition: transform 0.15s;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #2d3a4f;
}

.status-icon:hover {
  transform: scale(1.1);
}

.status-icon.green-dot {
  color: #22c55e;
}

.status-icon.red-dot {
  color: #ef4444;
}

.status-icon.checkbox {
  color: #3b82f6;
}

/* BUTTONS - Mobile optimized */
button {
  background: #2563eb;
  border: none;
  color: white;
  padding: 14px 20px; /* Larger touch target */
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  width: 100%; /* Full width on mobile */
  margin: 4px 0;
  border: 1px solid #3b82f6;
  transition: all 0.2s;
  min-height: 48px; /* Minimum touch target size */
}

/* SELECT DROPDOWNS - Mobile optimized */
select {
  background: #1e293b;
  border: 1px solid #334155;
  color: white;
  padding: 14px; /* Larger touch target */
  border-radius: 10px;
  font-size: 1rem;
  width: 100%;
  margin: 4px 0;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

/* FILTER SECTION */
.filter-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.filter-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* BOTTOM NAVIGATION - Better for thumbs */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #020617;
  display: flex;
  justify-content: space-around; /* Evenly spaced */
  padding: 8px 12px;
  border-top: 1px solid #334155;
  z-index: 1000;
  backdrop-filter: blur(10px);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
}

.bottom-nav a {
  color: white;
  text-decoration: none;
  background: #1e293b;
  padding: 12px 0; /* Vertical padding only */
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  flex: 1; /* Equal width */
  margin: 0 4px;
  max-width: 120px; /* Prevent too wide on tablets */
  border: 1px solid #334155;
  transition: all 0.2s;
}

/* PROGRESS SECTION */
.progress-section {
  margin: 24px 0;
}

.progress-actions {
  display: grid;
  grid-template-columns: 1fr 1fr; /* Two buttons side by side */
  gap: 10px;
  margin: 16px 0;
}

.progress-actions button {
  margin: 0;
}

/* TABLES - Horizontal scroll on mobile */
.table-responsive {
  overflow-x: auto;
  margin: 16px -8px; /* Negative margin for edge-to-edge */
  padding: 0 8px;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px; /* Forces horizontal scroll on mobile */
  font-size: 0.9rem;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap; /* Prevents text wrapping */
}

/* CALENDAR - Mobile friendly */
.calendar-wrapper {
  margin: 20px 0;
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
  text-align: center;
  font-size: 0.8rem;
  color: #94a3b8;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  aspect-ratio: 1 / 1; /* Square cells */
  background: #1e293b;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.8rem, 3vw, 1rem);
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 40px; /* Minimum touch target */
}

/* CHART AREA */
.chart-container {
  margin: 20px 0;
  background: #1e293b;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #334155;
}

canvas {
  max-width: 100%;
  height: auto !important;
}

/* FLEX UTILITIES */
.flex-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.flex-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* SPACING UTILITIES */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 12px;
}

/* Tablet Breakpoint (768px and up) */
@media (min-width: 768px) {
  body {
    padding: 24px;
  }
  
  /* Stats grid - back to horizontal */
  .stats-container {
    grid-template-columns: repeat(7, 1fr);
  }
  
  /* Class cards - switch to list view */
  .class-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
  }
  
  .class-header {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
    min-width: 120px;
  }
  
  .class-details {
    flex-direction: row;
    margin-bottom: 0;
    gap: 24px;
  }
  
  .detail-row {
    gap: 8px;
  }
  
  .class-actions {
    border-top: none;
    padding-top: 0;
  }
  
  /* Buttons - not full width anymore */
  button {
    width: auto;
    padding: 10px 20px;
  }
  
  select {
    width: auto;
    min-width: 180px;
  }
  
  /* Filter section - horizontal layout */
  .filter-section {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  
  .filter-row {
    flex-direction: row;
    align-items: center;
  }
  
  /* Bottom nav - centered buttons */
  .bottom-nav {
    justify-content: center;
    gap: 20px;
  }
  
  .bottom-nav a {
    flex: 0 1 auto;
    padding: 10px 24px;
  }
  
  .progress-actions {
    grid-template-columns: repeat(4, 1fr); /* More buttons in a row */
  }
  
  .calendar-day {
    min-height: 50px;
  }
}

/* Desktop Breakpoint (1024px and up) */
@media (min-width: 1024px) {
  body {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
  }
  
  .stats-container {
    gap: 16px;
  }
  
  .class-details {
    gap: 40px;
  }
  
  .calendar-day {
    min-height: 60px;
    font-size: 1rem;
  }
}

/* Landscape mode for mobile */
@media (max-height: 600px) and (orientation: landscape) {
  .bottom-nav {
    position: static;
    margin-top: 20px;
  }
  
  body {
    padding-bottom: 20px;
  }
  
  .calendar-day {
    min-height: 45px;
  }
}

/* Fix for very small devices */
@media (max-width: 360px) {
  .stats-container {
    grid-template-columns: 1fr; /* Single column for very small screens */
  }
  
  .class-actions {
    gap: 10px;
  }
  
  .status-icon {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
}

/* High-resolution screens with large text */
@media (min-width: 1440px) {
  html {
    font-size: 18px; /* Slightly larger base font */
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  button, select, .calendar-day, .status-icon {
    cursor: default;
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.3);
  }
  
  button:active, .calendar-day:active, .status-icon:active {
    transform: scale(0.97);
    background: #2d3a4f;
  }
  
  /* Remove hover effects on touch devices */
  .stat:hover, .class-card:hover {
    transform: none;
  }
}

/* Loading states */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.class-card, .stat {
  animation: fadeIn 0.3s ease-out;
}
