/* ================================
   NOTAS APP - AESTHETIC STYLES
   Optimizado para tablets y móviles
   ================================ */

/* Variables CSS para temas */
:root {
  --primary-color: #667eea;
  --secondary-color: #764ba2;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

/* Tema dark */
body.theme-dark {
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --bg-primary: #1f2937;
  --bg-secondary: #374151;
  --border-color: #4b5563;
}

/* Tema light */
body.theme-light {
  --primary-color: #f59e0b;
  --secondary-color: #d97706;
  --text-primary: #92400e;
  --text-secondary: #a16207;
  --bg-primary: #fffbeb;
  --bg-secondary: #fef3c7;
  --border-color: #fcd34d;
}

/* Tema rosa */
body.theme-rosa {
  --primary-color: #ec4899;
  --secondary-color: #be185d;
  --text-primary: #831843;
  --text-secondary: #9d174d;
  --bg-primary: #fdf2f8;
  --bg-secondary: #fce7f3;
  --border-color: #f9a8d4;
}

/* Tema neon */
body.theme-neon {
  --primary-color: #8b5cf6;
  --secondary-color: #7c3aed;
  --text-primary: #f3e8ff;
  --text-secondary: #ddd6fe;
  --bg-primary: #1e1b4b;
  --bg-secondary: #312e81;
  --border-color: #6d28d9;
}

/* Reset y base */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: transparent;
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Layout principal */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Main content */
.main-content {
  flex: 1;
  padding: 0;
}


/* Contenedor principal */
.notas-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 10;
}


/* Vistas */
.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

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

.view-header {
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
}

.view-header h2 {
  font-size: 2rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text-primary);
}

.view-header p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0;
}

.btn-back {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.btn-back:hover {
  background: var(--bg-secondary);
  transform: translateY(-50%) translateX(-2px);
}

/* Grid de cursos */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.course-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.course-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.course-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
  background: var(--bg-secondary);
}

.course-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text-primary);
}

.course-card p {
  color: var(--text-secondary);
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.course-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Lista de asignaturas */
.subjects-container {
  max-width: 800px;
  margin: 0 auto;
}

.subjects-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.subject-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.subject-card:hover {
  background: var(--bg-secondary);
  transform: translateX(4px);
}

.subject-info h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: var(--text-primary);
}

.subject-info p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
}

.subject-actions {
  display: flex;
  gap: 0.5rem;
}

.add-subject-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border: none;
  border-radius: var(--radius-lg);
  padding: 1rem;
  color: white;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.add-subject-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Configuración */
.config-container {
  max-width: 600px;
  margin: 0 auto;
}

.config-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.form-group small {
  display: block;
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.3s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 3px var(--primary-color);
}

.grade-names-container {
  display: grid;
  gap: 0.75rem;
}

.grade-name-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.config-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 2rem;
}

/* Tabla de notas */
.grades-container {
  max-width: 100%;
}

.grades-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.grades-table-container {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
}

.grades-table {
  width: 100%;
  min-width: 600px;
}

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

.grades-table th,
.grades-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.grades-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Primera columna del header sticky (Estudiante) */
.grades-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 20;
  background: var(--bg-secondary);
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

.grades-table td {
  color: var(--text-primary);
}

.student-name {
  font-weight: 500;
  min-width: 180px;
  position: sticky;
  left: 0;
  background: var(--bg-primary);
  z-index: 5;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}

/* Cuando el mouse pasa sobre la fila, mantener el background */
.grades-table tbody tr:hover .student-name {
  background: var(--bg-secondary);
}

.grade-input {
  width: 80px;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.grade-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
  transform: scale(1.05);
}

.grade-input:hover {
  border-color: var(--primary-color);
  background: var(--bg-secondary);
}

/* Décimas */
.decimals-cell {
  text-align: center;
  background: var(--bg-secondary);
  border-left: 3px solid var(--warning-color);
}

.decimals-input {
  width: 60px;
  padding: 0.4rem;
  border: 2px solid var(--warning-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--warning-color);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.decimals-input:focus {
  outline: none;
  border-color: var(--warning-color);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* Controles de notas */
.grade-cell {
  padding: 0.5rem 0.25rem;
}

.grade-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  justify-content: center;
}

.grade-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.plus-btn {
  background: var(--success-color);
  color: white;
}

.plus-btn:hover:not(.disabled) {
  background: #059669;
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.minus-btn {
  background: var(--error-color);
  color: white;
}

.minus-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.grade-btn.disabled {
  background: var(--border-color);
  color: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.5;
}

.grade-btn.disabled:hover {
  transform: none;
  box-shadow: none;
}

.grade-input {
  width: 70px;
  margin: 0 0.125rem;
}

.average-cell {
  font-weight: 600;
  background: var(--bg-secondary);
}

/* Botones */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  color: white;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  transform: translateY(-1px);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-danger {
  background: linear-gradient(135deg, var(--error-color), #dc2626);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  color: white;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-danger:active {
  transform: translateY(0);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideIn 0.3s ease;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem 2rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

/* Estado vacío */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 1rem;
  margin: 0 0 2rem;
}

/* Loading */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  color: white;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Sección de gráficos */
.charts-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.charts-header {
  text-align: center;
  margin-bottom: 2rem;
}

.charts-header h3 {
  color: var(--text-primary);
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.charts-header p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.9rem;
}

.range-legend {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin: 0 0.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
}

.charts-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 1.5rem;
}

.chart-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.chart-title {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-wrapper {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-stats {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.chart-stats h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
}

.stat-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.stat-label {
  flex: 1;
  color: var(--text-primary);
}

.stat-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* Colores para los rangos */
.range-1 { background-color: #ef4444; } /* 1.0-3.9 Rojo */
.range-2 { background-color: #f59e0b; } /* 4.0-4.9 Amarillo */
.range-3 { background-color: #10b981; } /* 5.0-5.9 Verde */
.range-4 { background-color: #3b82f6; } /* 6.0-7.0 Azul */

/* Responsive Design */
@media (max-width: 768px) {
  .notas-container {
    padding: 15px;
  }
  
  .courses-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .btn-back {
    position: static;
    transform: none;
    margin-bottom: 1rem;
    width: auto;
    border-radius: var(--radius-md);
  }
  
  .view-header {
    text-align: left;
  }
  
  .view-header h2 {
    font-size: 1.5rem;
  }
  
  .config-card {
    padding: 1.5rem;
  }
  
  .config-actions {
    flex-direction: column;
  }
  
  .grades-actions {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .charts-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .chart-wrapper {
    height: 250px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    margin: 20px;
    width: calc(100% - 40px);
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (max-width: 480px) {
  .notas-container {
    padding: 10px;
  }
  
  .course-card,
  .subject-card,
  .config-card {
    padding: 1rem;
  }
  
  .grades-table th,
  .grades-table td {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
  
  .decimals-input {
    width: 50px;
    padding: 0.3rem;
    font-size: 0.8rem;
  }
  
  .grade-btn {
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
  }
  
  .grade-input {
    width: 60px;
    padding: 0.4rem;
  }
  
  .grade-controls {
    gap: 0.125rem;
  }
  
  .student-name {
    min-width: 140px;
  }
  
  /* Mantener sticky en móvil */
  .grades-table th:first-child,
  .student-name {
    position: sticky;
    left: 0;
  }
  
  .grades-table th:first-child {
    box-shadow: 1px 0 3px rgba(0, 0, 0, 0.15);
  }
  
  .student-name {
    box-shadow: 1px 0 3px rgba(0, 0, 0, 0.08);
  }
}
