/**
 * Progress Graph Styles
 * Styles for student and teacher progress graph components
 */

/* Container Styles */
.progress-graph-container {
  margin: 2rem 0;
  padding: 1.5rem;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.graph-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.graph-header h3 {
  margin: 0;
  color: #6564b6;
  font-size: 1.3rem;
}

.graph-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.graph-controls label {
  font-size: 0.9rem;
  color: #666;
  font-weight: 500;
}

.date-range-select {
  padding: 0.4rem 0.8rem;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: white;
  color: #333;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.3s;
}

.date-range-select:hover,
.date-range-select:focus {
  border-color: #6564b6;
  outline: none;
}

/* Graph Canvas Container */
.graph-canvas-container {
  position: relative;
  height: 400px;
  padding: 1rem;
}

/* Table View Container */
.table-view-container {
  overflow-x: auto;
}

.table-scroll-container {
  min-width: 100%;
}

.progress-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.progress-table thead {
  background-color: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 10;
}

.progress-table th {
  padding: 0.8rem;
  text-align: left;
  color: #6564b6;
  font-weight: 600;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
}

.progress-table tbody tr {
  border-bottom: 1px solid #e0e0e0;
  transition: background-color 0.2s;
}

.progress-table tbody tr:hover {
  background-color: #f8f9fa;
}

.progress-table td {
  padding: 0.8rem;
  white-space: nowrap;
}

.score-cell {
  text-align: center;
  font-weight: bold;
  cursor: pointer;
  padding: 0.5rem 0.8rem;
  border-radius: 5px;
  transition: transform 0.2s;
}

.score-cell:hover {
  transform: scale(1.05);
}

/* Score badge colors (matching existing progress page) */
.badge-bright-green {
  background-color: #4caf50;
  color: white;
}

.badge-light-green {
  background-color: #81c784;
  color: white;
}

.badge-light-orange {
  background-color: #ffb74d;
  color: #333;
}

.badge-light-red {
  background-color: #e57373;
  color: white;
}

/* Orientation Hint */
.orientation-hint {
  text-align: center;
  padding: 1rem;
  background-color: #f0f4ff;
  border-radius: 8px;
  margin-top: 1rem;
  color: #6564b6;
  font-size: 0.9rem;
}

/* Teacher View Specific Styles */
.teacher-graph-container {
  min-height: 500px;
}

.filter-bar {
  background-color: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-group label {
  font-size: 0.75rem;
  color: #666;
  text-transform: uppercase;
  font-weight: 600;
}

.filter-select,
.filter-input {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: white;
  min-width: 150px;
  font-size: 0.9rem;
}

.student-multiselect {
  min-width: 250px;
  position: relative;
}

.view-toggle-group {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

.view-toggle-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #6564b6;
  background: white;
  color: #6564b6;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.view-toggle-btn.active {
  background: #6564b6;
  color: white;
}

.view-toggle-btn:hover:not(.active) {
  background: #f0f4ff;
}

/* Student Grid (Teacher View) */
.student-grid-container {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid #e0e0e0;
  display: none; /* Hidden by default, shown when student selected */
}

.student-grid-container.visible {
  display: block;
}

.student-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem;
  background-color: #f0f4ff;
  border-radius: 8px;
}

.student-name {
  font-size: 1.2rem;
  font-weight: bold;
  color: #6564b6;
}

.close-student-view {
  padding: 0.5rem 1rem;
  background: #6564b6;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.close-student-view:hover {
  background: #534f9a;
}

.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.exam-grid-item {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.exam-grid-item:hover {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.exam-grid-title {
  font-weight: bold;
  color: #333;
  margin-bottom: 0.5rem;
}

.exam-grid-date {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.exam-grid-scores {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.exam-grid-score {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  background-color: #f8f9fa;
}

.grammar-tags-expand {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e0e0e0;
  font-size: 0.8rem;
  color: #6564b6;
  cursor: pointer;
}

.grammar-tags-content {
  display: none;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background-color: #f8f9fa;
  border-radius: 5px;
  font-size: 0.8rem;
}

.grammar-tags-content.visible {
  display: block;
}

/* Chart Line Hover Effects */
.chart-line-thin {
  stroke-width: 1.5px;
  opacity: 0.6;
  transition: all 0.2s;
}

.chart-line-highlight {
  stroke-width: 3px;
  opacity: 1;
}

.chart-line-dimmed {
  opacity: 0.2;
}

/* Loading States */
.graph-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 400px;
  color: #666;
  font-size: 1.1rem;
}

.graph-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #6564b6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 1rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .graph-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .graph-controls {
    width: 100%;
    justify-content: space-between;
  }

  .graph-canvas-container {
    height: 300px;
    padding: 0.5rem;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .filter-select,
  .filter-input {
    width: 100%;
  }

  .view-toggle-group {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }

  /* Mobile table optimizations */
  .progress-table {
    font-size: 0.8rem;
  }

  .progress-table th,
  .progress-table td {
    padding: 0.5rem;
  }

  .score-cell {
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
  }
}

/* Portrait Mode Specific */
@media (max-width: 768px) and (orientation: portrait) {
  .graph-canvas-container {
    display: none;
  }

  .table-view-container {
    display: block !important;
  }
}

/* Landscape Mode Specific */
@media (max-width: 768px) and (orientation: landscape) {
  .graph-canvas-container {
    display: block !important;
    height: 250px;
  }

  .table-view-container {
    display: none;
  }

  .orientation-hint {
    display: none !important;
  }
}

/* Animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Tooltip Styles for Tippy.js */
.tippy-box[data-theme~='exam-details'] {
  background-color: white;
  color: #333;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 1rem;
  max-width: 400px;
}

.tippy-box[data-theme~='exam-details'] .tippy-arrow {
  color: white;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9998;
}

/* Transposed Exam Results Table (Teacher View) */
.exam-results-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.exam-results-table th,
.exam-results-table td {
  padding: 0.75rem;
  text-align: center;
  border: 1px solid #ddd;
}

.exam-results-table .exam-column-header {
  background-color: #6564b6;
  color: white;
  font-weight: 600;
  white-space: nowrap;
}

.exam-results-table .row-header {
  font-weight: bold;
  text-align: left;
  background-color: #f5f5f5;
  color: #6564b6;
  white-space: nowrap;
  width: 150px;
}

.exam-results-table .score-cell {
  cursor: pointer;
  font-weight: bold;
  transition: transform 0.2s, box-shadow 0.2s;
}

.exam-results-table .score-cell:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.exam-results-table .no-data {
  text-align: center;
  color: #999;
  font-style: italic;
  padding: 2rem;
}

/* Exam Details Modal */
.exam-details-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.exam-details-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.exam-details-modal .modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.exam-details-modal .modal-content {
  position: relative;
  max-width: 800px;
  margin: 50px auto;
  background: white;
  border-radius: 10px;
  padding: 0;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.exam-details-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background-color: #6564b6;
  color: white;
  border-bottom: 2px solid #534f9a;
}

.exam-details-modal .modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.exam-details-modal .modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.exam-details-modal .modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.exam-details-modal .modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.exam-details-modal .modal-body h3 {
  color: #6564b6;
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 0.5rem;
}

.exam-details-modal .modal-body h3:not(:first-child) {
  margin-top: 1.5rem;
}

/* Parts List in Modal */
.parts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.part-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background-color: #f8f9fa;
  border-radius: 5px;
  border-left: 4px solid #6564b6;
}

.part-name {
  font-weight: 600;
  color: #333;
}

.part-score {
  font-weight: bold;
  font-size: 1.1rem;
  color: #6564b6;
}

.part-score.high-score {
  color: #4caf50;
}

.part-score.low-score {
  color: #e57373;
}

/* Grammar Tags List in Modal */
.grammar-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.grammar-tag-item {
  background-color: #f0f4ff;
  color: #6564b6;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid #6564b6;
}

.grammar-tags-list .no-tags {
  color: #999;
  font-style: italic;
  padding: 1rem;
  text-align: center;
  width: 100%;
}

/* Mobile Modal Styles */
@media (max-width: 768px) {
  .exam-details-modal .modal-content {
    margin: 20px;
    max-height: calc(100vh - 40px);
  }

  .exam-details-modal .modal-header {
    padding: 1rem;
  }

  .exam-details-modal .modal-header h2 {
    font-size: 1.1rem;
  }

  .exam-details-modal .modal-body {
    padding: 1rem;
  }

  .exam-results-table {
    font-size: 0.8rem;
  }

  .exam-results-table th,
  .exam-results-table td {
    padding: 0.5rem 0.3rem;
  }

  .exam-results-table .row-header {
    width: 100px;
    font-size: 0.75rem;
  }
}

/* Print Styles */
@media print {
  .graph-controls,
  .orientation-hint,
  .filter-bar,
  .view-toggle-group {
    display: none !important;
  }

  .graph-canvas-container {
    height: 600px;
    page-break-inside: avoid;
  }
}