/**
 * Frequency History - Premium Styles (Fase 3)
 * Tabela expansível de histórico de aulas com participantes
 */

/* ========================================
   HISTORY CONTAINER
   ======================================== */

.frequency-history {
  padding: 24px;
  max-width: 1800px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease-in-out;
}

/* ========================================
   FILTERS SECTION
   ======================================== */

.history-filters {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group label {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-select,
.filter-input {
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-actions {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

/* ========================================
   TABLE SECTION
   ======================================== */

.history-table-container {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.history-table thead th {
  padding: 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-table tbody tr.lesson-row {
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  transition: background-color 0.2s;
}

.history-table tbody tr.lesson-row:hover {
  background-color: #f8fafc;
}

.history-table tbody tr.lesson-row.expanded {
  background-color: #f1f5f9;
}

.history-table tbody td {
  padding: 16px;
  font-size: 14px;
  color: #1e293b;
}

/* Expand Button */
.expand-cell {
  text-align: center;
}

.expand-btn {
  background: none;
  border: none;
  color: #667eea;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  transition: transform 0.2s;
}

.expand-btn:hover {
  transform: scale(1.2);
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-completed {
  background-color: #d1fae5;
  color: #065f46;
}

.status-scheduled {
  background-color: #dbeafe;
  color: #1e40af;
}

.status-cancelled {
  background-color: #fee2e2;
  color: #991b1b;
}

/* Rate Badge */
.rate-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
}

.rate-excellent {
  background-color: #d1fae5;
  color: #065f46;
}

.rate-good {
  background-color: #bfdbfe;
  color: #1e40af;
}

.rate-fair {
  background-color: #fed7aa;
  color: #92400e;
}

.rate-poor {
  background-color: #fecaca;
  color: #991b1b;
}

/* ========================================
   EXPANDED ROW (PARTICIPANTS)
   ======================================== */

.expanded-row {
  background-color: #f8fafc;
  border-top: none !important;
}

.participants-container {
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.participants-section h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.participants-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border-radius: 8px;
  border-left: 4px solid #e2e8f0;
  transition: all 0.2s;
}

.participant-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transform: translateX(4px);
}

.participant-item.present {
  border-left-color: #10b981;
}

.participant-item.absent {
  border-left-color: #ef4444;
}

.participant-name {
  flex: 1;
  font-weight: 600;
  color: #1e293b;
}

.participant-item small {
  font-size: 12px;
  color: #64748b;
}

.badge-late {
  background-color: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-justified {
  background-color: #dbeafe;
  color: #1e40af;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.no-participants {
  text-align: center;
  color: #94a3b8;
  font-style: italic;
  padding: 20px;
}

/* ========================================
   PAGINATION
   ======================================== */

.history-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.pagination-info {
  font-size: 14px;
  color: #64748b;
}

.pagination-info strong {
  color: #1e293b;
  font-weight: 700;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-pagination {
  padding: 8px 16px;
  border: 2px solid #e2e8f0;
  background: white;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-pagination:hover:not(:disabled) {
  border-color: #667eea;
  color: #667eea;
  transform: translateY(-2px);
}

.btn-pagination:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-numbers {
  display: flex;
  gap: 8px;
}

.page-number {
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  background: white;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 40px;
  text-align: center;
}

.page-number:hover {
  border-color: #667eea;
  color: #667eea;
}

.page-number.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
}

/* ========================================
   EMPTY STATE
   ======================================== */

.empty-state {
  text-align: center;
  padding: 80px 24px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.8;
}

.empty-state h3 {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 12px 0;
}

.empty-state p {
  font-size: 16px;
  color: #64748b;
  margin: 0;
}

/* ========================================
   LOADING & ERROR STATES
   ======================================== */

.loading-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #f3f4f6;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-row td,
.error-row td {
  text-align: center;
  padding: 40px;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.error-row h3 {
  margin: 12px 0;
  color: #ef4444;
}

.error-row p {
  color: #64748b;
  margin-bottom: 20px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet (1024px) */
@media (max-width: 1024px) {
  .history-filters {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-actions {
    grid-column: 1 / -1;
  }

  .participants-container {
    grid-template-columns: 1fr;
  }
}

/* Mobile (768px) */
@media (max-width: 768px) {
  .frequency-history {
    padding: 16px;
  }

  .history-filters {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .history-table-container {
    overflow-x: auto;
  }

  .history-table {
    min-width: 800px;
  }

  .history-pagination {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .participants-container {
    padding: 16px;
  }

  .page-numbers {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* Mobile Small (480px) */
@media (max-width: 480px) {
  .btn-pagination {
    padding: 6px 12px;
    font-size: 12px;
  }

  .page-number {
    padding: 6px 10px;
    font-size: 12px;
    min-width: 32px;
  }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   MODAL STYLES
   ======================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease-out;
}

.modal-large {
  max-width: 900px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

.close-modal {
  background: none;
  border: none;
  font-size: 24px;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Roll Table in Modal */
.roll-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.roll-table th {
  text-align: left;
  padding: 12px;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
}

.roll-table td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.student-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.student-name {
  font-weight: 600;
  color: #1e293b;
}

.student-reg {
  font-size: 12px;
  color: #64748b;
}

.status-select {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  width: 100%;
}

.notes-input {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  width: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
