/* ============================================
   SISTEMA DE DISEÑO PROFESIONAL - UCV
   Mobile-First Responsive Design (Optimizado)
   ============================================ */

:root {
  /* Variables Semánticas del Tema Claro */
  --bg-body: #F1F5F9;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --text-main: #1E293B;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --border-card: #E2E8F0;
  --border-card-hover: #CBD5E1;
  --section-title-color: #0E4B77;
  --input-bg: #FFFFFF;
  --input-text: #1E293B;
  --input-border: #E2E8F0;
  --modal-bg: #FFFFFF;
  --link-color: #0E4B77;
  --shadow-main: 0 1px 2px 0 rgba(0, 0, 0, 0.05);

  /* Colores primarios - Azul UCV refinado */
  --ucv-blue-primary: #0E4B77;
  --ucv-blue-dark: #0A3A5C;
  --ucv-blue-light: #1E6091;
  
  /* Escala de grises profesional */
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;
  
  /* Acentos */
  --accent-blue: #3B82F6;
  --accent-sky: #0EA5E9;
  --white: #FFFFFF;
  
  /* Sombras */
  --shadow-sm: 0 1px 2px 0 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);
  
  /* Tipografía */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  
  /* Espaciado */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  
  /* Bordes */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
}

/* ============================================
   TEMA OSCURO - PALETA PROFESIONAL (SLATE)
   ============================================ */
[data-theme="dark"] {
  --bg-body: #0B1120;
  --bg-card: #1E293B;
  --bg-card-hover: #2A384F;
  --text-main: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --border-card: #334155;
  --border-card-hover: #475569;
  --section-title-color: #38BDF8; /* Sky 400 */
  --input-bg: #1E293B;
  --input-text: #F8FAFC;
  --input-border: #334155;
  --modal-bg: #1E293B;
  --link-color: #38BDF8;
  --shadow-main: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

/* ============================================
   RESET Y BASE
   ============================================ */

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  height: 100%;
  min-height: 100vh;
  background-color: var(--bg-body);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   HEADER INSTITUCIONAL Y BOTÓN DE TEMA
   ============================================ */

header {
  background: linear-gradient(135deg, var(--ucv-blue-primary) 0%, var(--ucv-blue-dark) 100%);
  color: var(--white);
  text-align: center;
  padding: var(--space-8) var(--space-4);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] header {
  background: linear-gradient(135deg, #071E30 0%, #051421 100%);
}

header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.4;
}

header h1, header p {
  position: relative;
  z-index: 1;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

header p {
  font-size: 0.95rem;
  font-weight: 400;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Botón Conmutador de Modo Claro / Oscuro */
.theme-toggle-btn {
  position: absolute;
  top: var(--space-4, 1rem);
  right: var(--space-4, 1rem);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  outline: none;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
  transform: scale(1.1) rotate(15deg);
}

.theme-toggle-btn:active {
  transform: scale(0.95);
}

.theme-toggle-btn .theme-icon {
  font-size: 1.15rem;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

/* ============================================
   CONTENIDO PRINCIPAL
   ============================================ */

.main-content {
  flex: 0;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
  animation: fadeIn 0.5s ease-out;
}

.main-content + .main-content {
  padding-top: 0;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--section-title-color);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 3px solid var(--section-title-color);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  line-height: 1.3;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 1.25rem;
  background: var(--accent-sky);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================
   GRID DE SEMESTRES
   ============================================ */

.semester-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.semester-card {
  position: relative;
  min-width: 0;
}

.card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  padding: var(--space-4) var(--space-3);
  background: var(--bg-card);
  color: var(--section-title-color);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-card);
  box-shadow: var(--shadow-main);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s, box-shadow 0.3s, color 0.3s, background-color 0.3s;
  position: relative;
  overflow: hidden;
  word-break: break-word;
  hyphens: auto;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--ucv-blue-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

[data-theme="dark"] .card::before {
  background: var(--accent-sky);
}

.card:hover,
.card:active {
  border-color: var(--section-title-color);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: var(--section-title-color);
}

.card:hover::before,
.card:active::before {
  transform: scaleX(1);
}

.card.gris {
  color: var(--text-secondary);
}

.card.gris::before {
  background: var(--accent-sky);
}

.card.gris:hover,
.card.gris:active {
  border-color: var(--accent-sky);
  color: var(--section-title-color);
}

/* ============================================
   CALENDARIO ACADÉMICO
   ============================================ */

.calendario-contenedor {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: var(--space-6) 0;
  padding: 0 var(--space-2);
}

.calendario-marco {
  width: 100%;
  background: var(--bg-card);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-main);
  border: 1px solid var(--border-card);
  position: relative;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.calendario-marco::before {
  content: '';
  position: absolute;
  top: -1px;
  inset-x: -1px;
  height: 3px;
  background: linear-gradient(90deg, var(--ucv-blue-primary), var(--accent-sky));
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.calendario-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
}

/* ============================================
   LEYENDA DEL CALENDARIO
   ============================================ */

.calendario-leyenda {
  width: 100%;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-main);
  border: 1px solid var(--border-card);
  position: relative;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.calendario-leyenda::before {
  content: '';
  position: absolute;
  left: 0;
  inset-y: var(--space-5);
  width: 3px;
  background: var(--accent-sky);
  border-radius: 0 2px 2px 0;
}

.calendario-leyenda h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--section-title-color);
  margin-bottom: var(--space-3);
  padding-left: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  line-height: 1.3;
}

.calendario-leyenda h3::before {
  content: '📅';
  font-size: 1.125rem;
  flex-shrink: 0;
}

.calendario-leyenda ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-left: var(--space-3);
}

.calendario-leyenda li {
  padding: var(--space-2) 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  line-height: 1.5;
  transition: color 0.2s ease, border-color 0.3s ease;
}

.calendario-leyenda li:last-child {
  border-bottom: none;
}

.calendario-leyenda li:hover {
  color: var(--text-main);
}

.calendario-leyenda li::before {
  content: '•';
  color: var(--accent-sky);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  margin-right: var(--space-2);
}

.calendario-leyenda strong {
  color: var(--text-main);
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

/* ============================================
   BÚSQUEDA Y SUGERENCIAS INTEGRADA
   ============================================ */

.search-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto var(--space-4) auto; 
  font-family: var(--font-sans);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: var(--space-4);
  font-size: 1.1rem;
  opacity: 0.5;
  pointer-events: none;
  z-index: 2;
  color: var(--text-muted);
}

#search-input,
#filtro-materia {
  width: 100%;
  padding: var(--space-4) var(--space-4) var(--space-4) calc(var(--space-4) + 2rem);
  border: 2px solid var(--input-border);
  border-radius: var(--radius-xl);
  font-size: 1rem;
  font-family: var(--font-sans);
  background-color: var(--input-bg);
  color: var(--input-text);
  outline: none;
  box-shadow: var(--shadow-main);
  transition: border-color 0.3s, box-shadow 0.3s, background-color 0.3s, color 0.3s;
}

#filtro-materia {
  padding-right: 7.5rem;
}

#search-input::placeholder,
#filtro-materia::placeholder {
  color: var(--text-muted);
}

#search-input:hover,
#filtro-materia:hover {
  border-color: var(--border-card-hover);
  box-shadow: var(--shadow-md);
}

#search-input:focus,
#filtro-materia:focus {
  border-color: var(--accent-sky);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15), var(--shadow-md);
}

.suggestions-box {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
  box-shadow: var(--shadow-xl);
  padding: var(--space-2) 0;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.suggestions-box:empty {
  display: none !important;
  border: none;
  padding: 0;
}

.suggestions-box::-webkit-scrollbar {
  width: 6px;
}
.suggestions-box::-webkit-scrollbar-thumb {
  background: var(--border-card);
  border-radius: 3px;
}

/* ============================================
   BADGE Y LIMPIEZA PARA FILTRO DE MATERIA
   ============================================ */

.filter-badge-container {
  position: absolute;
  right: var(--space-3, 0.75rem);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  z-index: 3;
}

.filter-counter-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-sky);
  background: rgba(14, 165, 233, 0.12);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full, 9999px);
  white-space: nowrap;
}

.filter-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, transform 0.2s ease;
}

.filter-clear-btn:hover {
  color: #EF4444;
  transform: scale(1.15);
}

.suggestion-item {
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: background-color 0.15s, color 0.15s, padding 0.15s;
}

.suggestion-item::before {
  content: '📖';
  font-size: 0.9rem;
  opacity: 0.8;
}

.suggestion-item:hover, 
.suggestion-item.active {
  background-color: var(--bg-card-hover);
  color: var(--link-color);
  padding-left: calc(var(--space-5) + 4px);
}

/* ============================================
   FOOTER INSTITUCIONAL
   ============================================ */

footer {
  background: var(--ucv-blue-dark);
  color: var(--white);
  text-align: center;
  padding: var(--space-5) var(--space-4);
  flex-shrink: 0;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  transition: background-color 0.3s ease;
}

[data-theme="dark"] footer {
  background: #051421;
}

footer p {
  margin: 0;
  font-size: 0.875rem;
  opacity: 0.9;
  font-weight: 400;
  line-height: 1.5;
}

/* ============================================
   BOTÓN FLOTANTE (FAB)
   ============================================ */

.floating-chat-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 50px;
  height: 50px;
  background: var(--ucv-blue-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s, box-shadow 0.3s;
  border: 2px solid var(--white);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] .floating-chat-btn {
  background: #0284C7;
  border-color: #38BDF8;
}

.floating-chat-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ucv-blue-primary);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
}

.floating-chat-btn img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.floating-chat-btn:hover,
.floating-chat-btn:active {
  transform: scale(1.05) translateY(-2px);
  background: var(--ucv-blue-dark);
  box-shadow: 0 15px 25px -5px rgba(14, 75, 119, 0.3);
}

.floating-chat-btn:hover::after,
.floating-chat-btn:active::after {
  opacity: 0.4;
  transform: scale(1.1);
}

.floating-chat-btn:hover img,
.floating-chat-btn:active img {
  transform: scale(1.1);
}

/* --- ESTILOS DEL FOOTER Y MODAL --- */

footer .credit-link {
    color: #ffffff;
}

footer .panel-control-btn {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.8rem;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

footer .panel-control-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
}

/* Modal Overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 45, 73, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
    box-sizing: border-box;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.75);
}

/* Modal Box */
.modal-content {
    background: var(--modal-bg);
    padding: 28px 24px;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 360px;
    color: var(--text-main);
    border: 1px solid var(--border-card);
    border-top: 4px solid var(--section-title-color);
    position: relative;
    box-shadow: var(--shadow-xl);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.modal-close {
    position: absolute;
    right: 16px;
    top: 14px;
    cursor: pointer;
    font-size: 1.4rem;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #EF4444;
}

.modal-title {
    margin: 0 0 18px 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--section-title-color);
}

/* Formulario */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    box-sizing: border-box;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    color: var(--input-text);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-sky);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.auth-error-msg {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.15);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 14px;
    display: none;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background: var(--ucv-blue-primary);
    border: none;
    color: var(--white);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

[data-theme="dark"] .btn-submit {
    background: #0284C7;
}

.btn-submit:hover {
    background: var(--ucv-blue-dark);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .btn-submit:hover {
    background: #0369A1;
}

.reset-container {
    margin-top: 14px;
    text-align: center;
}

.btn-reset-link {
    color: var(--accent-sky);
    font-size: 0.85rem;
    text-decoration: none;
    font-weight: 500;
}

.btn-reset-link:hover {
    text-decoration: underline;
}

.btn-reset-link:hover {
    text-decoration: underline;
}


/* ============================================
   MEDIA QUERIES (RESPONSIVE)
   ============================================ */

/* Mobile Small Landscape */
@media (max-height: 500px) and (orientation: landscape) {
  header { padding: var(--space-4); }
  header h1 { font-size: 1.25rem; }
  .semester-grid { grid-template-columns: repeat(3, 1fr); }
  .card { min-height: 70px; padding: var(--space-3); }
  .floating-chat-btn { bottom: 15px; right: 15px; width: 45px; height: 45px; }
}

/* Mobile Small Search Adjustments */
@media (max-width: 640px) {
  .search-container { margin-bottom: var(--space-3); }
  #search-input {
    padding: var(--space-3) var(--space-3) var(--space-3) calc(var(--space-3) + 2rem);
    font-size: 0.95rem;
    border-radius: var(--radius-lg);
  }
  .suggestions-box { border-radius: var(--radius-lg); max-height: 250px; }
  .suggestion-item { padding: var(--space-3) var(--space-4); }
}

/* Tablet (min-width: 640px) */
@media (min-width: 640px) {
  header { padding: var(--space-10) var(--space-6); }
  header h1 { font-size: 2rem; margin-bottom: var(--space-3); }
  header p { font-size: 1.1rem; }

  .main-content { padding: var(--space-8) var(--space-6); }
  .section-title { font-size: 1.375rem; margin-bottom: var(--space-6); }
  .section-title::before { height: 1.5rem; }

  .semester-grid { grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
  .card { min-height: 100px; font-size: 1rem; padding: var(--space-5) var(--space-4); border-radius: var(--radius-xl); }
  .card::before { height: 4px; }

  .calendario-contenedor { margin: var(--space-8) 0; padding: 0; }
  .calendario-marco { max-width: 90%; padding: var(--space-4); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
  .calendario-marco::before { height: 4px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .calendario-img { border-radius: var(--radius-md); }

  .calendario-leyenda { max-width: 90%; padding: var(--space-6); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
  .calendario-leyenda::before { width: 4px; inset-y: var(--space-6); }
  .calendario-leyenda h3 { font-size: 1.125rem; margin-bottom: var(--space-4); padding-left: var(--space-4); }
  .calendario-leyenda h3::before { font-size: 1.25rem; }
  .calendario-leyenda ul { gap: var(--space-3); padding-left: var(--space-4); }
  .calendario-leyenda li { flex-direction: row; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; font-size: 0.95rem; }
  .calendario-leyenda strong { display: inline; white-space: nowrap; margin-bottom: 0; }

  footer { padding: var(--space-6); }
  footer p { font-size: 0.95rem; }

  .floating-chat-btn { bottom: 30px; right: 30px; width: 60px; height: 60px; border-width: 3px; }
  .floating-chat-btn::after { inset: -5px; }
  .floating-chat-btn img { width: 28px; height: 28px; }
}

/* Medium / Desktop Small (min-width: 768px) */
@media (min-width: 768px) {
  .semester-grid { grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
  .card { min-height: 110px; font-size: 1.05rem; }
}

/* Desktop Large (min-width: 1024px) */
@media (min-width: 1024px) {
  header { padding: var(--space-12) var(--space-8); }
  header h1 { font-size: 2.5rem; }
  header p { font-size: 1.25rem; max-width: 700px; }

  .main-content { padding: var(--space-10) var(--space-8); }
  .section-title { font-size: 1.5rem; }

  .semester-grid { grid-template-columns: repeat(6, 1fr); gap: var(--space-5); }
  .card { min-height: 120px; font-size: 1.125rem; }

  .calendario-marco, .calendario-leyenda { max-width: 800px; }
  .calendario-marco { padding: var(--space-5); }
  .calendario-leyenda { padding: var(--space-6) var(--space-8); }

  .floating-chat-btn { bottom: 40px; right: 40px; }
}

/* Desktop Extra Large (min-width: 1280px) */
@media (min-width: 1280px) {
  .semester-grid { gap: var(--space-6); }
}

/* ============================================
   ACCESIBILIDAD Y RENDIMIENTO
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

.card:focus-visible,
.floating-chat-btn:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 2px;
}

@media (hover: none) {
  .card:hover { transform: none; box-shadow: var(--shadow-sm); }
  .card:active { transform: scale(0.98); background: var(--gray-50); }
}


/* 1. Asegura que los paddings y borders NO sumen ancho extra */
*, *::before, *::after {
  box-sizing: border-box;
}

/* 2. Evita que la página misma se desborde horizontalmente */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* 3. Evita que imágenes o elementos multimedia se salgan */
img, iframe, video {
  max-width: 100%;
  height: auto;
}