/* ==========================================================================
   TEACHER DASHBOARD - DEDICATED CSS COMPONENTS
   Using BEM methodology + Design tokens from main dashboard.css
   ========================================================================== */

/* ==========================================================================
   1. TEACHER DASHBOARD HEADER
   ========================================================================== */

/* Teacher Dashboard Header Container */
.gn-teacher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--gn-space-6) 0;
  gap: var(--gn-space-4);
}

/* Teacher Header Content (Left side) */
.gn-teacher-header__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--gn-space-1);
}

/* Teacher Header Title */
.gn-teacher-header__title {
  font-family: var(--gn-font-family-heading);
  font-size: var(--gn-font-size-2xl);
  font-weight: 700;
  color: var(--gn-color-gray-900);
  margin: 0;
}

/* Teacher Header Subtitle */
.gn-teacher-header__subtitle {
  font-size: var(--gn-font-size-sm);
  color: var(--gn-color-gray-600);
  margin: 0;
}

/* Teacher Header Actions (Right side) */
.gn-teacher-header__actions {
  display: flex;
  align-items: center;
  gap: var(--gn-space-3);
  margin-left: auto;
}

/* ==========================================================================
   2. TEACHER SEARCH BAR (Enhanced from main dashboard)
   ========================================================================== */

/* Teacher Search Bar Container */
.gn-teacher-search-bar {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 320px;
  background: var(--gn-color-white);
  border: 2px solid var(--gn-color-gray-200);
  border-radius: var(--gn-radius-md);
  transition: all var(--gn-transition-base);
  box-shadow: var(--gn-shadow-sm);
}

.gn-teacher-search-bar:focus-within {
  border-color: var(--gn-color-primary);
  box-shadow: 0 0 0 3px var(--gn-color-primary-light);
}

/* Teacher Search Input */
.gn-teacher-search-bar__input {
  flex: 1;
  padding: var(--gn-space-3) var(--gn-space-4);
  border: none;
  background: transparent;
  font-size: var(--gn-font-size-sm);
  color: var(--gn-color-gray-900);
  outline: none;
}

.gn-teacher-search-bar__input::placeholder {
  color: var(--gn-color-gray-400);
  font-weight: 400;
}

/* Teacher Search Icon */
.gn-teacher-search-bar__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gn-space-3);
  color: var(--gn-color-gray-400);
  pointer-events: none;
  transition: color var(--gn-transition-base);
}

.gn-teacher-search-bar__icon-svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.gn-teacher-search-bar:focus-within .gn-teacher-search-bar__icon {
  color: var(--gn-color-primary);
}

/* ==========================================================================
   3. RANKED LIST COMPONENT
   ========================================================================== */

/* Ranked List Container */
.gn-ranked-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--gn-color-white);
  border-radius: var(--gn-radius-lg);
  border: 1px solid var(--gn-color-gray-100);
  padding: 10px;
}

/* Ranked List Header */
.gn-ranked-list__header {
  padding: var(--gn-space-4) var(--gn-space-6);
  background: var(--gn-color-gray-50);
  border-bottom: 1px solid var(--gn-color-gray-100);
}

.gn-ranked-list__header-title {
  font-family: var(--gn-font-family-heading);
  font-size: var(--gn-font-size-lg);
  font-weight: 600;
  color: var(--gn-color-gray-900);
  margin: 0;
}

/* Ranked List Body */
.gn-ranked-list__body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Ranked List Item */
.gn-ranked-list__item {
  display: flex;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--gn-color-gray-100);
  transition: all var(--gn-transition-fast);
  cursor: pointer;
  background: var(--gn-color-white);
}

.gn-ranked-list__item:last-child {
  border-bottom: none;
}

.gn-ranked-list__item:hover {
  background: var(--gn-color-gray-50);
  transform: translateX(2px);
}

.gn-ranked-list__item:active {
  background: var(--gn-color-primary-50);
  transform: translateX(0);
}

/* Ranked List Item - Rank */
.gn-ranked-list__rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--gn-radius-full);
  background: var(--gn-color-gray-100);
  color: var(--gn-color-gray-600);
  font-family: var(--gn-font-family-heading);
  font-size: var(--gn-font-size-sm);
  font-weight: 600;
  flex-shrink: 0;
  margin-right: var(--gn-space-4);
}

/* Top 3 rank styling */
.gn-ranked-list__rank--top {
  background: var(--gn-color-secondary);
  color: var(--gn-color-gray-900);
  font-weight: 700;
}

.gn-ranked-list__rank--second {
  background: var(--gn-color-gray-300);
  color: var(--gn-color-gray-700);
  font-weight: 600;
}

.gn-ranked-list__rank--third {
  background: var(--gn-color-warning);
  color: var(--gn-color-white);
  font-weight: 600;
}

/* Ranked List Item - Content */
.gn-ranked-list__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gn-space-2);
  min-width: 0; /* Allows text truncation */
}

.gn-ranked-list__name {
  font-family: var(--gn-font-family-base);
  font-size: var(--gn-font-size-base);
  font-weight: 600;
  color: var(--gn-color-gray-900);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gn-ranked-list__subtitle {
  font-size: var(--gn-font-size-sm);
  color: var(--gn-color-gray-600);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Ranked List Item - Progress */
.gn-ranked-list__progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--gn-space-1);
  flex-shrink: 0; 
}

.gn-ranked-list__percentage {
  font-family: var(--gn-font-family-base);
  font-size: var(--gn-font-size-xs);
  font-weight: 600;
  color: var(--gn-color-gray-700);
}

.gn-ranked-list__progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gn-color-gray-200);
  border-radius: var(--gn-radius-full);
  overflow: hidden;
}

.gn-ranked-list__progress-fill {
  height: 100%;
  background: var(--gn-color-primary);
  border-radius: var(--gn-radius-full);
  transition: width var(--gn-transition-base);
}

/* Progress fill color variants */
.gn-ranked-list__progress-fill--high {
  background: var(--gn-color-success);
}

.gn-ranked-list__progress-fill--medium {
  background: var(--gn-color-warning);
}

.gn-ranked-list__progress-fill--low {
  background: var(--gn-color-danger);
}

/* Ranked List Item - Chevron */
.gn-ranked-list__chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gn-color-gray-400);
  margin-left: var(--gn-space-3);
  transition: all var(--gn-transition-fast);
}

.gn-ranked-list__chevron-svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.gn-ranked-list__item:hover .gn-ranked-list__chevron {
  color: var(--gn-color-primary);
  transform: translateX(2px);
}

/* Fix: Override transforms when in activity tabs context to prevent expansion */
.gn-dashboard-panel--with-tabs .gn-ranked-list__item:hover {
  background: var(--gn-color-gray-50);
  transform: none; /* Remove translateX to prevent weird expansion */
}

.gn-dashboard-panel--with-tabs .gn-ranked-list__item:hover .gn-ranked-list__chevron {
  color: var(--gn-color-primary);
  transform: none; /* Remove translateX to prevent weird expansion */
}

/* ==========================================================================
   4. RANKED LIST VARIANTS
   ========================================================================== */

/* Classes List Variant */
.gn-ranked-list--classes .gn-ranked-list__rank {
  background: linear-gradient(135deg, var(--gn-color-primary), var(--gn-color-primary-dark));
  color: var(--gn-color-white);
}

/* Students List Variant */
.gn-ranked-list--students .gn-ranked-list__subtitle {
  color: var(--gn-color-primary);
  font-weight: 500;
}

/* Subjects List Variant */
.gn-ranked-list--subjects .gn-ranked-list__progress-bar {
  width: 100%;
}

/* ==========================================================================
   5. EMPTY STATES
   ========================================================================== */

/* Empty State for Ranked Lists */
.gn-ranked-list__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--gn-space-12) var(--gn-space-6);
  text-align: center;
  color: var(--gn-color-gray-500);
}

.gn-ranked-list__empty-icon {
  width: 4rem;
  height: 4rem;
  color: var(--gn-color-gray-300);
  margin-bottom: var(--gn-space-4);
}

.gn-ranked-list__empty-title {
  font-family: var(--gn-font-family-heading);
  font-size: var(--gn-font-size-lg);
  font-weight: 600;
  color: var(--gn-color-gray-600);
  margin: 0 0 var(--gn-space-2) 0;
}

.gn-ranked-list__empty-text {
  font-size: var(--gn-font-size-sm);
  color: var(--gn-color-gray-500);
  max-width: 300px;
  line-height: 1.5;
  margin: 0;
}

/* Empty State for Students List */

.gn-students-list, .gn-classes-list {
  min-height: 25rem; /* Match activity tabs panel height (400px) */
}

.gn-students-list__empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  min-height: 25rem; /* Ensure empty state fills the container height (400px) */
}

.gn-students-list__empty-icon {
  font-size: 3rem;
  margin-bottom: var(--gn-space-4);
  color: var(--gn-color-gray-300);
}

.gn-students-list__empty-title {
  font-family: var(--gn-font-family-heading);
  font-size: var(--gn-font-size-lg);
  font-weight: 600;
  color: var(--gn-color-gray-600);
  margin: 0 0 var(--gn-space-2) 0;
}

.gn-students-list__empty-description {
  font-size: var(--gn-font-size-sm);
  color: var(--gn-color-gray-500);
  max-width: 300px;
  line-height: 1.5;
  margin: 0;
}

/* ==========================================================================
   6. LOADING STATES
   ========================================================================== */

/* Loading State for Ranked Lists */
.gn-ranked-list__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gn-space-8) var(--gn-space-6);
}

.gn-ranked-list__loading-spinner {
  width: var(--gn-space-6);
  height: var(--gn-space-6);
  border: 2px solid var(--gn-color-gray-200);
  border-top: 2px solid var(--gn-color-primary);
  border-radius: var(--gn-radius-full);
  animation: gn-spin 1s linear infinite;
}

.gn-ranked-list__loading-text {
  margin-left: var(--gn-space-3);
  font-size: var(--gn-font-size-sm);
  color: var(--gn-color-gray-600);
}

/* ==========================================================================
   7. RESPONSIVE DESIGN
   ========================================================================== */

/* Mobile Adjustments */
@media (max-width: 640px) {
  /* Teacher Header */
  .gn-teacher-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--gn-space-4);
  }

  .gn-teacher-header__actions {
    width: 100%;
    margin-left: 0;
  }

  /* Teacher Search Bar */
  .gn-teacher-search-bar {
    max-width: 100%;
  }

  .gn-teacher-search-bar__input {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Ranked List */
  .gn-ranked-list__item {
    padding: 10px;
  }

  .gn-ranked-list__rank {
    width: 1.75rem;
    height: 1.75rem;
    margin-right: var(--gn-space-3);
    font-size: var(--gn-font-size-xs);
  }

  .gn-ranked-list__name {
    font-size: var(--gn-font-size-sm);
  }

  .gn-ranked-list__subtitle {
    font-size: var(--gn-font-size-xs);
  } 

  .gn-ranked-list__percentage {
    font-size: var(--gn-font-size-xs);
  }
}

/* Tablet Adjustments */
@media (min-width: 641px) and (max-width: 1023px) {
  .gn-teacher-search-bar {
    max-width: 280px;
  } 
}

/* Desktop Optimizations */
@media (min-width: 1024px) {
  .gn-ranked-list__item {
    padding: 10px;
  } 
}

/* ==========================================================================
   8. ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */

/* Focus States */
.gn-ranked-list__item:focus {
  outline: 2px solid var(--gn-color-primary);
  outline-offset: -2px;
  background: var(--gn-color-primary-50);
}

.gn-teacher-search-bar__input:focus {
  outline: none;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .gn-ranked-list__item,
  .gn-ranked-list__chevron,
  .gn-ranked-list__progress-fill {
    transition: none;
  }

  .gn-ranked-list__loading-spinner {
    animation: none;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .gn-ranked-list__item {
    border: 2px solid transparent;
  }

  .gn-ranked-list__item:hover,
  .gn-ranked-list__item:focus {
    border-color: currentColor;
  }
}

/* ==========================================================================
   9. TEACHER PERFORMANCE CARDS - 3 SECTION LAYOUT
   ========================================================================== */

/* Teacher Performance Container */
.gn-teacher-performance-container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--gn-space-6);
  margin-bottom: var(--gn-space-8);
}

/* Teacher Section */
.gn-teacher-section {
  display: flex;
  flex-direction: column;
  gap: var(--gn-space-4);
}

/* Teacher Section Header */
.gn-teacher-section__header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: var(--gn-space-2);
  /* border-bottom: 2px solid var(--gn-color-gray-100); */
}

.gn-teacher-section__title {
  display: flex;
  align-items: center;
  gap: var(--gn-space-2);
  font-size: 18px !important;
  font-weight: 700;
  color: var(--gn-color-gray-900);
  margin: 0;
}

.gn-teacher-section__icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* Teacher Section Cards */
.gn-teacher-section__cards {
  display: flex;
  flex-direction: row;
  gap: var(--gn-space-4);
  align-items: stretch;
}

/* Cards within teacher sections */
.gn-teacher-section__cards .gn-dashboard-card {
  flex: 1;
  min-width: 0; /* Allows proper flex shrinking */
}

/* Special handling for single card sections (Amaran) */
.gn-teacher-section:nth-child(3) .gn-dashboard-card {
  flex: none;
  width: 100%;
  max-width: 200px; /* Prevent Amaran card from being too wide */
}

/* Section-specific styling */
.gn-teacher-section:nth-child(1) .gn-teacher-section__header {
  /* border-bottom-color: var(--gn-color-primary); */
}

.gn-teacher-section:nth-child(1) .gn-teacher-section__title {
  /* color: var(--gn-color-primary); */
}

.gn-teacher-section:nth-child(2) .gn-teacher-section__header {
  border-bottom-color: var(--gn-color-secondary);
}

.gn-teacher-section:nth-child(2) .gn-teacher-section__title {
  /* color: var(--gn-color-secondary); */
}

.gn-teacher-section:nth-child(3) .gn-teacher-section__header {
  /* border-bottom-color: var(--gn-color-warning); */
}

.gn-teacher-section:nth-child(3) .gn-teacher-section__title {
  /* color: var(--gn-color-warning); */
}

/* ==========================================================================
   10. RESPONSIVE LAYOUT FOR TEACHER SECTIONS
   ========================================================================== */

/* Tablet Layout (2 columns, then 1) */
@media (max-width: 1023px) {
  .gn-teacher-performance-container {
    gap: var(--gn-space-4);
  }
  
  .gn-teacher-section:nth-child(3) {
    grid-column: 1 / -1;
    max-width: 50%;
    justify-self: start;
  }
}

/* Small tablet - stack cards when too narrow */
@media (max-width: 900px) {
  .gn-teacher-section__cards {
    flex-direction: column;
    gap: var(--gn-space-3);
  }
  
  .gn-teacher-section:nth-child(3) .gn-dashboard-card {
    /* Maintain consistent sizing with other cards */
  }
}

/* Mobile Layout (single column) */
@media (max-width: 767px) {
  .gn-teacher-performance-container {
    flex-direction: column;
    gap: var(--gn-space-4);
    padding: var(--gn-space-3) 0;
  }
  
  .gn-teacher-section:nth-child(3) {
    grid-column: auto;
    max-width: 100%;
    justify-self: stretch;
  }
  
  .gn-teacher-section__title {
    font-size: var(--gn-font-size-base);
  }
  
  .gn-teacher-section__icon {
    width: 20px;
    height: 20px;
  }
  
  /* Stack cards vertically on mobile */
  .gn-teacher-section__cards {
    flex-direction: column;
  }
  
  .gn-teacher-section:nth-child(3) .gn-dashboard-card {
    max-width: 100%;
  }
}

/* ==========================================================================
   11. TEACHER DASHBOARD GRID PADDING
   ========================================================================== */

/* Add padding specifically to teacher dashboard grid */
.gn-dashboard-grid--teacher {
  padding: var(--gn-space-4);
}

/* ==========================================================================
   12. TEACHER DASHBOARD EQUAL HEIGHT PANELS
   ========================================================================== */

/* Make all panels in teacher dashboard have equal height */
.gn-dashboard-grid--teacher {
  align-items: stretch; /* Ensure all columns stretch to equal height */
}

/* Make dashboard panels fill the full height of their containers */
.gn-dashboard-grid--teacher .gn-dashboard-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Make panel content expand to fill available space */
.gn-dashboard-grid--teacher .gn-dashboard-panel__content {
  flex: 1; /* Take up remaining space after header */
  max-height: 400px; /* Set reasonable maximum height */
  min-height: 300px; /* Set minimum height for consistency */
  height: auto; /* Let it grow naturally within limits */
}

/* Ensure ranked lists fill the panel content area */
.gn-dashboard-grid--teacher .gn-ranked-list {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding: var(--gn-space-1);
}

/* Make ranked list body expand to fill remaining space */
.gn-dashboard-grid--teacher .gn-ranked-list__body {
  flex: 1;
  overflow-y: auto; /* Add scroll if content exceeds height */
  overflow-x: hidden;
}

/* ==========================================================================
   13. TEACHER SWIPER COMPATIBILITY
   ========================================================================== */

/* Apply teacher dashboard styles to Swiper slides */
.gn-teacher-swiper .swiper-slide {
  /* padding: var(--gn-space-4); */
  height: auto;
}

/* Make dashboard columns fill the slide height */
.gn-teacher-swiper .swiper-slide .gn-dashboard-column {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 400px;
}

/* Ensure dashboard panels within Swiper slides have proper height */
.gn-teacher-swiper .swiper-slide .gn-dashboard-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Panel content styling within Swiper */
.gn-teacher-swiper .swiper-slide .gn-dashboard-panel__content {
  flex: 1;
  max-height: 400px;
  min-height: 300px;
  height: auto;
}

/* Ranked lists within Swiper slides */
.gn-teacher-swiper .swiper-slide .gn-ranked-list {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding: 0;
}

/* Ranked list body within Swiper */
.gn-teacher-swiper .swiper-slide .gn-ranked-list__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}