* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: #30363d;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --danger-hover: #ff6b6b;
  --radius: 8px;
  --shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
  --transition: all 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
}

section {
  display: none;
  height: 100vh;
}

section.active {
  display: flex;
}

/* ===== LOGIN ===== */
#login-section {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== DASHBOARD LAYOUT ===== */
#dashboard-section {
  display: none;
}

#dashboard-section.active {
  display: flex;
}

#sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 12px;
}

#user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#user-name {
  font-size: 14px;
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-admin {
  background: rgba(248, 81, 73, 0.2);
  color: var(--danger);
}

.badge-instructor {
  background: rgba(210, 153, 34, 0.2);
  color: var(--warning);
}

.badge-alumno {
  background: rgba(88, 166, 255, 0.2);
  color: var(--accent);
}

#sidebar-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  font-weight: 500;
}

.nav-icon {
  display: none;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

#top-bar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

#top-bar h2 {
  font-size: 20px;
  font-weight: 600;
}

#content-area {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== TABLES ===== */
.table-container {
  overflow-x: auto;
}

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

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  font-size: 14px;
}

tr:hover td {
  background: var(--bg-tertiary);
}

/* ===== FORMS IN MODALS ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  background: none;
  border: none;
  line-height: 1;
}

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

.modal h3 {
  margin-bottom: 20px;
  font-size: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== AUDIO PLAYER ===== */
.audio-section {
  margin: 16px 0;
}

.audio-section label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 6px;
  font-weight: 500;
}

audio {
  width: 100%;
  height: 40px;
  border-radius: var(--radius);
}

audio::-webkit-media-controls-panel {
  background: var(--bg-tertiary);
}

/* ===== STARS RATING ===== */
.star-rating {
  display: flex;
  gap: 4px;
  margin: 8px 0;
}

.star-rating .star {
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  background: none;
  border: none;
}

.star-rating .star.active,
.star-rating .star:hover {
  color: var(--warning);
}

/* ===== CHECKBOX GROUP ===== */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.checkbox-group label:hover {
  border-color: var(--accent);
}

.checkbox-group input[type="checkbox"] {
  accent-color: var(--accent);
}

/* ===== ALERT / MESSAGE ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-success {
  background: rgba(63, 185, 80, 0.15);
  border: 1px solid rgba(63, 185, 80, 0.3);
  color: var(--success);
}

.alert-error {
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: var(--danger);
}

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  min-width: 250px;
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-info {
  border-left: 4px solid var(--accent);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 12px;
}

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

/* ===== RECORDING INDICATOR ===== */
.recording-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 14px;
  margin: 12px 0;
}

.recording-indicator.active {
  display: flex;
}

.recording-dot {
  width: 12px;
  height: 12px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== COURSE TREE ===== */
.course-tree {
  padding-left: 0;
  list-style: none;
}

.course-tree li {
  position: relative;
}

.module-item {
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin: 8px 0;
  cursor: pointer;
  transition: var(--transition);
}

.module-item:hover {
  border-color: var(--accent);
}

.module-item h4 {
  font-size: 15px;
  margin-bottom: 4px;
}

.module-item span {
  font-size: 12px;
  color: var(--text-muted);
}

.lesson-item {
  padding: 8px 16px 8px 32px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  border-radius: var(--radius);
}

.lesson-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.lesson-item.completed {
  color: var(--success);
}

.lesson-item.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== SCENARIO CARD ===== */
.scenario-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.scenario-card .scenario-text {
  font-size: 15px;
  color: var(--text-primary);
  margin: 12px 0;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}

/* ===== EVALUATION FORM ===== */
.evaluation-section {
  margin: 20px 0;
}

.evaluation-section h4 {
  margin-bottom: 12px;
  font-size: 15px;
  color: var(--text-secondary);
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 15px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar {
    width: 220px;
    min-width: 220px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-content {
    width: 95%;
    padding: 16px;
  }
}
