/* ========================================
   Clean Minimal Design System
   White & Orange Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Primary Colors */
  --color-primary: #FF6B35;
  --color-primary-dark: #E85A28;
  --color-primary-light: #FF8C5F;
  --color-secondary: #FF6B35;
  --color-secondary-dark: #E85A28;
  --color-secondary-light: #FF8C5F;
  --color-accent: #FFB4A2;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --color-info: #3B82F6;

  /* Light Background */
  --color-bg: #FFFFFF;
  --color-bg-secondary: #F9FAFB;
  --color-surface: #FFFFFF;
  --color-surface-elevated: #F9FAFB;
  --color-bg-hover: #F3F4F6;

  /* Text Colors - WCAG AA compliant */
  --color-text: #1F2937;
  --color-text-secondary: #4B5563;
  --color-text-muted: #4B5563;
  --color-border: #E5E7EB;
  --color-border-light: #F3F4F6;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Courier New', monospace;
}

/* ========================================
   Dark Mode — variables sobrescritas
   ======================================== */

[data-theme="dark"] {
  --color-bg: #111827;
  --color-bg-secondary: #1F2937;
  --color-surface: #1F2937;
  --color-surface-elevated: #374151;
  --color-bg-hover: #374151;
  --color-text: #F9FAFB;
  --color-text-secondary: #D1D5DB;
  --color-text-muted: #9CA3AF;
  --color-border: #374151;
  --color-border-light: #4B5563;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .site-header {
  background: #1F2937;
  border-bottom-color: #374151;
}

[data-theme="dark"] .card {
  background: #1F2937;
  border-color: #374151;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #374151;
  color: #F9FAFB;
  border-color: #4B5563;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #9CA3AF;
}

[data-theme="dark"] table thead th {
  background: #374151;
  color: #D1D5DB;
}

[data-theme="dark"] .button-secondary {
  background: #374151;
  color: #F9FAFB;
  border-color: #4B5563;
}

[data-theme="dark"] .button-secondary:hover {
  background: #4B5563;
}

[data-theme="dark"] .button-danger {
  background: var(--color-surface);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

[data-theme="dark"] .modal-dialog {
  background: var(--color-surface);
  color: var(--color-text);
}

[data-theme="dark"] input.invalid-input,
[data-theme="dark"] select.invalid-input,
[data-theme="dark"] textarea.invalid-input {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--color-text);
}

[data-theme="dark"] .table tbody tr:hover,
[data-theme="dark"] .table tbody tr:hover td {
  background: var(--color-bg-hover);
}

[data-theme="dark"] .scores-table tbody tr:hover,
[data-theme="dark"] .scores-table tbody tr:hover td {
  background: var(--color-bg-hover);
}

[data-theme="dark"] .badge-muted {
  background: var(--color-surface-elevated);
  border-color: var(--color-border-light);
}

[data-theme="dark"] .row-optional {
  background: rgba(245, 158, 11, 0.08) !important;
}

/* ========================================
   Quitar flechas de inputs numéricos
   ======================================== */

/* Chrome, Safari, Edge, Opera */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
input[type="number"] {
  -moz-appearance: textfield;
}

/* ========================================
   Avatar en el header
   ======================================== */

.header-avatar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 50%;
  transition: box-shadow var(--transition-fast);
  flex-shrink: 0;
}
.header-avatar-link:hover,
.header-avatar-link:focus {
  box-shadow: 0 0 0 3px var(--color-primary);
  outline: none;
}
.header-avatar-img {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.header-avatar-initials {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: .03em;
  user-select: none;
}

/* ========================================
   Base Styles
   ======================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main, header, footer {
  position: relative;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--color-text);
}
h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
}
h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
}
h4 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}
h5 {
  font-size: 1.125rem;
  font-weight: 600;
}
h6 {
  font-size: 1rem;
  font-weight: 600;
}

p {
  margin: 0 0 1rem;
  font-weight: 400;
  color: var(--color-text-secondary);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
}

/* ========================================
   Layout
   ======================================== */

.container {
  width: min(1400px, 94%);
  margin: 0 auto;
}

.stack {
  display: grid;
  gap: 28px;
}

.grid-2 {
  display: grid;
  gap: 28px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.center {
  text-align: center;
}

main.container {
  display: block;
  padding: 40px 0 80px;
}

/* ========================================
   Header
   ======================================== */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
  transition: opacity var(--transition-fast);
}

.brand:hover {
  opacity: 0.8;
}

.main-nav ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 8px;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.main-nav a:hover {
  color: var(--color-primary);
  background: var(--color-bg-hover);
}

.main-nav a.nav-active {
  color: var(--color-primary);
  background: var(--color-bg-hover);
  font-weight: 600;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
}

.user-role {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-role.badge-super-admin {
  background: linear-gradient(135deg, #FF6B35 0%, #FF8C5F 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(255, 107, 53, 0.2);
}

.user-role.badge-teacher {
  background: #3B82F6;
  color: white;
}

.user-role.badge-admin {
  background: #8B5CF6;
  color: white;
}

.user-role.badge-student {
  background: #10B981;
  color: white;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========================================
   Mobile Navigation Toggle
   ======================================== */

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  position: relative;
  z-index: 1001;
}

.nav-toggle:hover {
  background: var(--color-bg-hover);
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text);
  margin: 5px 0;
  transition: all var(--transition-fast);
  border-radius: 2px;
}

.nav-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

@media (max-width: 768px) {
  .nav-toggle {
    display: block;
    order: 2;
  }

  .brand {
    order: 1;
  }

  .main-nav {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    z-index: 1000;
    order: 4;
  }

  .main-nav.active {
    max-height: 400px;
  }

  .main-nav ul {
    flex-direction: column;
    padding: 16px;
    gap: 0;
  }

  .main-nav li {
    border-bottom: 1px solid var(--color-border-light);
  }

  .main-nav li:last-child {
    border-bottom: none;
  }

  .main-nav a {
    display: block;
    padding: 16px 12px;
    width: 100%;
    border-radius: 0;
  }

  .header-content {
    flex-wrap: wrap;
    position: relative;
  }

  .nav-actions {
    order: 3;
    margin-left: auto;
  }

  .user-name {
    display: none;
  }

  .user-info {
    padding: 6px 10px;
  }

  .nav-actions form button {
    padding: 6px 12px;
    font-size: 0.8125rem;
  }
}

/* ========================================
   Breadcrumbs
   ======================================== */

.breadcrumbs {
  margin-bottom: 1.5rem;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  color: var(--color-text-secondary);
}

.breadcrumb-item:not(:last-child)::after {
  content: '>';
  margin-left: 8px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.breadcrumb-item a {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.breadcrumb-item a:hover {
  color: var(--color-primary);
  background: var(--color-bg-hover);
}

.breadcrumb-item:last-child span {
  color: var(--color-text);
  font-weight: 500;
}

/* ========================================
   Empty States
   ======================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  background: var(--color-bg);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  margin: 2rem 0;
}

.empty-state-icon {
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  opacity: 0.6;
}

.empty-state-icon svg {
  width: 64px;
  height: 64px;
}

.empty-state-title {
  color: var(--color-text);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.empty-state-description {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  max-width: 400px;
  margin: 0 0 1.5rem 0;
  line-height: 1.5;
}

.empty-state-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--color-primary);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all var(--transition-normal);
  cursor: pointer;
}

.empty-state-action:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========================================
   Modal / Confirmation Dialog
   ======================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
}

.modal-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: auto;
  transform: scale(0.9);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-dialog {
  transform: scale(1);
}

.modal-content {
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--color-text);
}

.modal-body {
  padding: 1.5rem;
  color: var(--color-text-secondary);
}

.modal-consequences {
  margin-top: 1rem;
  padding: 1rem;
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  border-radius: var(--radius-md);
}

.modal-consequences strong {
  color: #92400E;
  display: block;
  margin-bottom: 0.5rem;
}

.modal-consequences ul {
  margin: 0;
  padding-left: 1.5rem;
  color: #92400E;
}

.modal-consequences li {
  margin: 0.25rem 0;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ========================================
   Cards
   ======================================== */

.card {
  background: var(--color-surface);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.card-header h2,
.card-header h3,
.card-header h4 {
  margin: 0;
}

/* ========================================
   Buttons
   ======================================== */

button,
.button-primary,
.button-secondary,
.button-link,
.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.button-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.button-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-md);
}

.button-primary:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.2);
}

.button-secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

.button-secondary:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-text-muted);
}

.button-secondary:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.2);
}

.button-link {
  background: transparent;
  border: none;
  color: var(--color-primary);
  padding: 8px 12px;
}

.button-link:hover {
  color: var(--color-primary-dark);
  background: var(--color-bg-hover);
}

.button-link:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.2);
}

.button-danger {
  background: var(--color-surface);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.button-danger:hover {
  background: var(--color-danger);
  color: white;
}

.button-danger:focus {
  outline: 2px solid var(--color-danger);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

/* Focus visible for all interactive elements */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ========================================
   Accessibility - Skip Links
   ======================================== */

.skip-link {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: white;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  z-index: 10000;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
}

.skip-link:focus {
  top: 1rem;
  opacity: 1;
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* ========================================
   Forms
   ======================================== */

.form-grid {
  display: grid;
  gap: 20px;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--color-border-light);
}

label {
  display: grid;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--color-text);
}

input,
select,
textarea {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  transition: all var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

input.invalid-input,
select.invalid-input,
textarea.invalid-input {
  border-color: var(--color-danger);
  background-color: #FEE2E2;
}

input.invalid-input:focus,
select.invalid-input:focus,
textarea.invalid-input:focus {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  cursor: pointer;
  color: var(--color-text-secondary);
}

/* ========================================
   Tables
   ======================================== */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9375rem;
}

.table th {
  padding: 12px 16px;
  text-align: left;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  background: var(--color-surface);
}

.table tbody tr {
  transition: all var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--color-bg-secondary);
}

.table tbody tr:hover td {
  background: var(--color-bg-secondary);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-compact th,
.table-compact td {
  padding: 8px 12px;
  font-size: 0.875rem;
}

.table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ========================================
   Lists
   ======================================== */

.list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  gap: 12px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  transition: all var(--transition-fast);
}

.list-item:hover {
  background: var(--color-bg-secondary);
  box-shadow: var(--shadow-sm);
}

.list-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.item-actions form {
  margin: 0;
}

/* ========================================
   Badges
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--color-success);
  color: var(--color-success);
}

.badge-muted {
  background: var(--color-bg-secondary);
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

.row-optional {
  background: #fffbf0;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* ========================================
   Alerts
   ======================================== */

.alert {
  margin-bottom: 24px;
  padding: 16px 20px;
  font-weight: 500;
  border: 1px solid;
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  position: relative;
  animation: slideInDown 0.3s ease-out;
  box-shadow: var(--shadow-md);
}

.alert strong {
  display: block;
  margin-bottom: 0.25rem;
}

.alert small {
  display: block;
  margin-top: 0.5rem;
  opacity: 0.9;
  font-weight: 400;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--color-success);
  color: var(--color-success);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

/* ========================================
   Utility Classes
   ======================================== */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.breadcrumb {
  margin-bottom: 24px;
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.breadcrumb a:hover {
  color: var(--color-primary);
}

code {
  background: var(--color-bg-secondary);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--color-primary);
  font-family: var(--font-mono);
  font-size: 0.875em;
}

small {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.summary {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: grid;
  gap: 12px;
}

.summary-label {
  color: var(--color-text-secondary);
  margin-right: 8px;
  font-weight: 500;
}

.summary-points {
  color: var(--color-primary);
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
}

.row-highlight {
  background: var(--color-bg-secondary);
  font-weight: 600;
}

/* ========================================
   Footer
   ======================================== */

.site-footer {
  padding: 32px 0;
  border-top: 1px solid var(--color-border);
  margin-top: 80px;
  color: var(--color-text-secondary);
  text-align: center;
  font-size: 0.875rem;
  background: var(--color-bg-secondary);
}

/* ========================================
   Authentication Pages
   ======================================== */

.auth {
  display: grid;
  gap: 28px;
  max-width: 500px;
  margin: 80px auto;
}

.auth-grid {
  display: grid;
  gap: 28px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-actions {
    width: 100%;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .button-link {
    justify-content: flex-start;
  }

  .item-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .card {
    padding: 24px;
  }

  .table {
    font-size: 0.9375rem;
  }

  .table th,
  .table td {
    padding: 14px 16px;
  }
}

/* ========================================
   Special Components
   ======================================== */

.corte-block {
  margin-bottom: 28px;
}

.corte-block h4 {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.group-detail .table-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

/* Scores Table Specific Styles */
.scores-table {
  border-collapse: collapse;
}

.scores-table th {
  vertical-align: top;
  padding: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.8125rem;
}

.scores-table td {
  padding: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.scores-table input[type="number"] {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: center;
  transition: all var(--transition-fast);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-weight: 500;
}

.scores-table input[type="number"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.scores-table thead tr:first-child th {
  font-weight: 600;
  font-size: 0.875rem;
}

.scores-table tbody tr:hover {
  background: var(--color-bg-secondary);
}

.scores-table tbody tr:hover td {
  background: var(--color-bg-secondary);
}

/* ========================================
   Global Search
   ======================================== */

@media screen and (min-width: 769px) {
  .global-search {
    display: block !important;
  }
}

.global-search-result-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.global-search-result-item:hover {
  background: var(--color-bg-hover);
}

.global-search-result-item:last-child {
  border-bottom: none;
}

/* ========================================
   Responsive Tables
   ======================================== */

@media screen and (max-width: 768px) {
  /* Hacer tablas scrollables horizontalmente en móvil */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Alternativamente, convertir tablas a cards en móvil */
  .table.mobile-cards {
    border: 0;
  }

  .table.mobile-cards thead {
    display: none;
  }

  .table.mobile-cards tbody,
  .table.mobile-cards tr,
  .table.mobile-cards td {
    display: block;
    width: 100%;
  }

  .table.mobile-cards tr {
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 1rem;
  }

  .table.mobile-cards td {
    text-align: left !important;
    padding: 0.5rem 0;
    border: none;
    position: relative;
    padding-left: 50%;
  }

  .table.mobile-cards td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 45%;
    padding-right: 0.5rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
  }

  /* Grid responsive */
  .grid-2 {
    grid-template-columns: 1fr !important;
  }

}

/* ========================================
   Accesibilidad - Labels ocultos para lectores de pantalla
   ======================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
   Widget flotante - Barra inferior en pantallas muy pequeñas
   ======================================== */

@media (max-width: 479px) {
  .floating-widget {
    width: 100%;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
    margin: 0;
    min-width: unset;
    display: flex !important;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    flex-wrap: wrap;
  }
}

/* ========================================
   Thead sticky en tablas de datos largas
   ======================================== */

/* Primera fila del thead: sticky debajo del topbar (~52px) */
.table-sticky-header thead tr:first-child th {
  position: sticky;
  top: 52px;
  z-index: 10;
  background: var(--color-bg-secondary, #F9FAFB);
  box-shadow: 0 1px 0 var(--color-border, #E5E7EB);
}

/* Segunda fila del thead (si existe): se posiciona dinámicamente vía JS. */
.table-sticky-header thead tr:nth-child(2) th {
  position: sticky;
  top: 92px;
  z-index: 10;
  background: var(--color-bg-secondary, #F9FAFB);
}

/* Primera columna sticky (nombre del estudiante) */
.table-sticky-header thead th:first-child,
.table-sticky-header tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 11;
  background: inherit;
}

.table-sticky-header thead th:first-child {
  z-index: 12;
}

/* ========================================
   App Layout — Sidebar + Content
   ======================================== */

/* Body con sidebar: fondo diferenciado para el área de contenido */
body.has-sidebar {
  background: var(--color-bg-secondary);
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */

.app-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform var(--transition-slow);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.app-sidebar::-webkit-scrollbar {
  width: 4px;
}
.app-sidebar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

.sidebar-brand-wrap {
  padding: 0 20px;
  min-height: 52px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.sidebar-brand-wrap img {
  height: 36px;
  width: auto;
  object-fit: contain;
  display: block;
}

.sidebar-user-wrap {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sidebar-user-role {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  line-height: 1.3;
}

.sidebar-nav-wrap {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
}

.sidebar-nav-section {
  margin-bottom: 6px;
}

.sidebar-nav-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 10px 8px 2px;
  display: block;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
  margin-bottom: 1px;
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  box-sizing: border-box;
}

.sidebar-nav-item:hover {
  background: var(--color-bg-hover);
  color: var(--color-primary);
  text-decoration: none;
}

.sidebar-nav-item.nav-active {
  background: rgba(255, 107, 53, 0.1);
  color: var(--color-primary);
  font-weight: 600;
}

.sidebar-nav-item svg {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.sidebar-nav-item:hover svg,
.sidebar-nav-item.nav-active svg {
  opacity: 1;
}

.sidebar-nav-item.nav-danger {
  color: var(--color-danger);
}

.sidebar-nav-item.nav-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-danger);
}

.sidebar-bottom-wrap {
  padding: 10px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* ---- Sidebar overlay (mobile) ---- */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
  display: block;
}

/* ---- Main area ---- */

.app-main {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Topbar ---- */

.app-topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  min-height: 52px;
}

.sidebar-mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: background var(--transition-fast);
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}

.sidebar-mobile-toggle:hover {
  background: var(--color-bg-hover);
}

.topbar-search {
  flex: 1;
  max-width: 300px;
  position: relative;
}

.topbar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  display: flex;
}

.topbar-search input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: 0.8125rem;
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

.topbar-search input:focus {
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.12);
  outline: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.topbar-avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  padding: 5px 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.topbar-avatar-btn:hover {
  background: var(--color-bg-hover);
}

.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
}

.topbar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- Content area ---- */

.app-content {
  flex: 1;
  padding: 28px 32px 60px;
}

/* ---- Dark mode ---- */

[data-theme="dark"] .app-sidebar {
  background: var(--color-surface);
  border-right-color: var(--color-border);
}

[data-theme="dark"] .app-topbar {
  background: var(--color-surface);
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .topbar-search input {
  background: var(--color-surface-elevated);
  border-color: var(--color-border);
  color: var(--color-text);
}

[data-theme="dark"] .topbar-search input:focus {
  background: var(--color-surface);
}

/* ---- Responsive ---- */

@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .app-sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .app-main {
    margin-left: 0;
  }

  .sidebar-mobile-toggle {
    display: flex;
  }

  .app-content {
    padding: 20px 16px 40px;
  }

  .app-topbar {
    padding: 10px 16px;
  }
}

@media (max-width: 640px) {
  .topbar-search {
    display: none;
  }
}
