/* Responsive Design Framework - Mobile-First Approach */

/* ===== RESPONSIVE GRID SYSTEM ===== */

/* Container System */
.container-responsive {
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

/* Mobile First - Base styles */
.container-responsive {
  max-width: 100%;
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
  .container-responsive {
    max-width: 540px;
  }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
  .container-responsive {
    max-width: 720px;
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
  .container-responsive {
    max-width: 960px;
  }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
  .container-responsive {
    max-width: 1140px;
  }
}

/* Extra extra large devices (larger desktops, 1400px and up) */
@media (min-width: 1400px) {
  .container-responsive {
    max-width: 1320px;
  }
}

/* ===== FLEXIBLE GRID SYSTEM ===== */

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 calc(-1 * var(--spacing-md));
}

.col {
  flex: 1 0 0%;
  padding: 0 var(--spacing-md);
}

/* Column sizing - Mobile first */
.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* Small devices (576px and up) */
@media (min-width: 576px) {
  .col-sm-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
  .col-sm-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-sm-3 { flex: 0 0 25%; max-width: 25%; }
  .col-sm-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-sm-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
  .col-sm-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
  .col-sm-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-sm-9 { flex: 0 0 75%; max-width: 75%; }
  .col-sm-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
  .col-sm-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
  .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
}

/* Medium devices (768px and up) */
@media (min-width: 768px) {
  .col-md-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
  .col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-md-3 { flex: 0 0 25%; max-width: 25%; }
  .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
  .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-md-9 { flex: 0 0 75%; max-width: 75%; }
  .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
  .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
  .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}

/* Large devices (992px and up) */
@media (min-width: 992px) {
  .col-lg-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
  .col-lg-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
  .col-lg-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-lg-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
  .col-lg-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
  .col-lg-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-lg-9 { flex: 0 0 75%; max-width: 75%; }
  .col-lg-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
  .col-lg-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
  .col-lg-12 { flex: 0 0 100%; max-width: 100%; }
}

/* Extra large devices (1200px and up) */
@media (min-width: 1200px) {
  .col-xl-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
  .col-xl-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-xl-3 { flex: 0 0 25%; max-width: 25%; }
  .col-xl-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-xl-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-xl-6 { flex: 0 0 50%; max-width: 50%; }
  .col-xl-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
  .col-xl-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-xl-9 { flex: 0 0 75%; max-width: 75%; }
  .col-xl-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
  .col-xl-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
  .col-xl-12 { flex: 0 0 100%; max-width: 100%; }
}

/* ===== RESPONSIVE NAVIGATION ===== */

.navbar-responsive {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg) var(--spacing-xl);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.navbar-brand {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--primary-color);
  text-decoration: none;
  margin-right: auto;
}

.class-context-nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: var(--text-light);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  margin-right: var(--spacing-lg);
}

.class-context-nav .class-name {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
}

.class-context-nav .teacher-info {
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--font-size-base);
}

@media (max-width: 768px) {
  .class-context-nav {
    font-size: var(--font-size-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    margin-right: var(--spacing-sm);
  }
  
  .class-context-nav .teacher-info {
    display: none;
  }
}

.navbar-toggler {
  display: none;
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.navbar-toggler:hover {
  background-color: var(--gray-100);
}

.navbar-toggler-icon {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--text-primary);
  position: relative;
  transition: all var(--transition-fast);
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  background-color: var(--text-primary);
  transition: all var(--transition-fast);
}

.navbar-toggler-icon::before {
  top: -8px;
}

.navbar-toggler-icon::after {
  bottom: -8px;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  position: relative;
}

.nav-link-responsive {
  display: block;
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-link-responsive:hover,
.nav-link-responsive.active {
  color: var(--primary-color);
  background-color: rgba(74, 137, 220, 0.1);
  text-decoration: none;
}

/* Mobile Navigation */
@media (max-width: 768px) {
  .navbar-toggler {
    display: block;
  }
  
  .navbar-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--gray-200);
  }
  
  .navbar-nav.show {
    display: flex;
  }
  
  .nav-link-responsive {
    padding: var(--spacing-md);
    border-radius: 0;
    border-bottom: 1px solid var(--gray-100);
  }
  
  .nav-link-responsive:last-child {
    border-bottom: none;
  }
}

/* ===== RESPONSIVE COMPONENTS ===== */

/* Responsive Cards */
.card-responsive {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  transition: all var(--transition-normal);
  margin-bottom: var(--spacing-lg);
}

@media (min-width: 768px) {
  .card-responsive {
    padding: var(--spacing-2xl);
  }
}

.card-responsive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Responsive Tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive .table {
  min-width: 600px;
}

@media (max-width: 768px) {
  .table-responsive .table {
    font-size: var(--font-size-sm);
  }
  
  .table-responsive .table th,
  .table-responsive .table td {
    padding: var(--spacing-sm);
    white-space: nowrap;
  }
}

/* Responsive Forms */
.form-responsive .form-group {
  margin-bottom: var(--spacing-lg);
}

@media (min-width: 768px) {
  .form-responsive .form-row {
    display: flex;
    gap: var(--spacing-lg);
  }
  
  .form-responsive .form-row .form-group {
    flex: 1;
  }
}

/* Responsive Buttons */
.btn-responsive {
  width: 100%;
  justify-content: center;
}

@media (min-width: 576px) {
  .btn-responsive {
    width: auto;
    min-width: 120px;
  }
}

.btn-group-responsive {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

@media (min-width: 576px) {
  .btn-group-responsive {
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }
}

/* ===== RESPONSIVE UTILITIES ===== */

/* Display utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

@media (max-width: 575px) {
  .d-xs-none { display: none !important; }
  .d-xs-block { display: block !important; }
  .d-xs-flex { display: flex !important; }
}

@media (min-width: 576px) {
  .d-sm-none { display: none !important; }
  .d-sm-block { display: block !important; }
  .d-sm-flex { display: flex !important; }
}

@media (min-width: 768px) {
  .d-md-none { display: none !important; }
  .d-md-block { display: block !important; }
  .d-md-flex { display: flex !important; }
}

@media (min-width: 992px) {
  .d-lg-none { display: none !important; }
  .d-lg-block { display: block !important; }
  .d-lg-flex { display: flex !important; }
}

@media (min-width: 1200px) {
  .d-xl-none { display: none !important; }
  .d-xl-block { display: block !important; }
  .d-xl-flex { display: flex !important; }
}

/* Text alignment utilities */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

@media (max-width: 575px) {
  .text-xs-center { text-align: center !important; }
  .text-xs-left { text-align: left !important; }
  .text-xs-right { text-align: right !important; }
}

@media (min-width: 576px) {
  .text-sm-center { text-align: center !important; }
  .text-sm-left { text-align: left !important; }
  .text-sm-right { text-align: right !important; }
}

@media (min-width: 768px) {
  .text-md-center { text-align: center !important; }
  .text-md-left { text-align: left !important; }
  .text-md-right { text-align: right !important; }
}

/* Responsive spacing */
@media (max-width: 575px) {
  .p-xs-0 { padding: 0 !important; }
  .p-xs-1 { padding: var(--spacing-xs) !important; }
  .p-xs-2 { padding: var(--spacing-sm) !important; }
  .p-xs-3 { padding: var(--spacing-md) !important; }
  .p-xs-4 { padding: var(--spacing-lg) !important; }
  
  .m-xs-0 { margin: 0 !important; }
  .m-xs-1 { margin: var(--spacing-xs) !important; }
  .m-xs-2 { margin: var(--spacing-sm) !important; }
  .m-xs-3 { margin: var(--spacing-md) !important; }
  .m-xs-4 { margin: var(--spacing-lg) !important; }
}

/* ===== RESPONSIVE IMAGES & MEDIA ===== */

.img-responsive {
  max-width: 100%;
  height: auto;
  display: block;
}

.video-responsive {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  overflow: hidden;
}

.video-responsive iframe,
.video-responsive video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ===== RESPONSIVE LAYOUT PATTERNS ===== */

/* Sidebar Layout */
.layout-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.layout-sidebar .sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--gray-200);
  padding: var(--spacing-lg);
  order: 2;
}

.layout-sidebar .main-content {
  flex: 1;
  padding: var(--spacing-lg);
  order: 1;
}

@media (min-width: 768px) {
  .layout-sidebar {
    flex-direction: row;
  }
  
  .layout-sidebar .sidebar {
    width: 250px;
    flex-shrink: 0;
    order: 1;
  }
  
  .layout-sidebar .main-content {
    order: 2;
  }
}

/* Dashboard Layout */
.dashboard-grid {
  display: grid;
  gap: var(--spacing-lg);
  grid-template-columns: 1fr;
}

@media (min-width: 576px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Content Layout */
.content-layout {
  display: grid;
  gap: var(--spacing-2xl);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .content-layout {
    grid-template-columns: 2fr 1fr;
  }
}

/* ===== RESPONSIVE TYPOGRAPHY ===== */

.responsive-text {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

@media (min-width: 576px) {
  .responsive-text {
    font-size: var(--font-size-base);
  }
}

@media (min-width: 768px) {
  .responsive-text {
    font-size: var(--font-size-lg);
    line-height: var(--line-height-relaxed);
  }
}

.responsive-heading {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-tight);
}

@media (min-width: 576px) {
  .responsive-heading {
    font-size: var(--font-size-2xl);
  }
}

@media (min-width: 768px) {
  .responsive-heading {
    font-size: var(--font-size-3xl);
  }
}

@media (min-width: 992px) {
  .responsive-heading {
    font-size: var(--font-size-4xl);
  }
}

/* ===== RESPONSIVE ANIMATIONS ===== */

@media (prefers-reduced-motion: reduce) {
  .card-responsive,
  .nav-link-responsive,
  .btn-responsive {
    transition: none;
  }
  
  .card-responsive:hover {
    transform: none;
  }
}

/* ===== RESPONSIVE SCROLLBARS ===== */

.scrollable-content {
  overflow-y: auto;
  max-height: 400px;
}

@media (min-width: 768px) {
  .scrollable-content {
    max-height: 600px;
  }
}

.scrollable-content::-webkit-scrollbar {
  width: 6px;
}

@media (min-width: 768px) {
  .scrollable-content::-webkit-scrollbar {
    width: 8px;
  }
}

.scrollable-content::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: var(--radius-full);
}

.scrollable-content::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: var(--radius-full);
}

.scrollable-content::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

/* ===== RESPONSIVE PRINT STYLES ===== */

@media print {
  .navbar-responsive,
  .btn-responsive,
  .navbar-toggler {
    display: none !important;
  }
  
  .container-responsive {
    max-width: none !important;
    padding: 0 !important;
  }
  
  .card-responsive {
    box-shadow: none !important;
    border: 1px solid var(--gray-300) !important;
    break-inside: avoid;
  }
  
  .layout-sidebar {
    flex-direction: column !important;
  }
  
  .layout-sidebar .sidebar {
    width: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--gray-300) !important;
  }
}