/**
 * @file mparamos-theme.css
 * @description Hoja de estilos compartida calcada de www.miguelparamos.com y card-creator.
 * Incluye tipografía FlorenceSans, fondo de vídeo, efectos hover .mparamos-link/.resource-btn,
 * banderas CSS puras y componentes mobile-first para alumnos y panel del profesor.
 */

@font-face {
  font-family: "FlorenceSans";
  src: url("/font/sfflorencesans.ttf") format("truetype");
  font-weight: normal;
  font-display: swap;
}

@font-face {
  font-family: "FlorenceSans";
  src: url("/font/sfflorencesansblack.ttf") format("truetype");
  font-weight: bold;
  font-display: swap;
}

:root {
  --bg-color: #0b0f19;
  --card-bg: rgba(13, 17, 23, 0.85);
  --card-solid: #0d1117;
  --border-color: #1f2937;
  --accent-color: #3b82f6;
  --emerald-color: #10b981;
  --neon-green: #00ff88;
  --danger-color: #ef4444;
  --amber-color: #f59e0b;
  --text-primary: #f3f4f6;
  --text-muted: #9ca3af;
  --text-subtle: #64748b;
}

*, ::before, ::after {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #1f2937 #0b0f19;
}
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0b0f19; }
::-webkit-scrollbar-thumb { background: #1f2937; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3b82f6; }

html {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  min-width: 320px;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: transparent;
  color: var(--text-primary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  min-width: 320px;
}

body.page-layout {
  display: flex;
  flex-direction: column;
  position: relative;
}

body.admin-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* =========================================
   VÍDEO DE FONDO
   ========================================= */
.video-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  overflow: hidden;
  background-color: var(--bg-color);
  pointer-events: none;
}

#bg-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
  #bg-video {
    display: none;
  }
}

/* =========================================
   CABECERA Y PIE INSTITUCIONALES
   ========================================= */
header.mp-header, footer.mp-footer {
  background-color: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  width: 100%;
  flex-shrink: 0;
  z-index: 30;
}

header.mp-header {
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(to right, #10b981, #3b82f6) 1;
  padding: 0.65rem 1rem;
}

footer.mp-footer {
  border-top: 3px solid transparent;
  border-image: linear-gradient(to right, #10b981, #3b82f6) 1;
  padding: 0.75rem 1rem 0.65rem;
  margin-top: auto;
}

.mp-header-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mp-brand-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.mp-logo-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.mp-logo-img {
  height: 2.75rem;
  width: auto;
  transition: transform 0.25s ease, opacity 0.25s ease;
  filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.35));
}

.mp-logo-img:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

.mp-head-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
  flex: 1;
}

.mp-head-title-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

.mp-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  line-height: 1.25;
}

.mp-sub-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.mp-subtitle {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent-color);
}

.mp-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 0.375rem;
  padding: 0.15rem 0.5rem;
}

.mparamos-line {
  height: 2px;
  width: 100%;
  background: linear-gradient(to right, #10b981, #3b82f6);
  border-radius: 2px;
  margin: 0.3rem 0;
}

/* =========================================
   EFECTOS HOVER DE ENLACES (CALCADOS)
   ========================================= */
a.mparamos-link {
  display: inline-block;
  vertical-align: baseline;
  color: #10b981;
  text-decoration: none;
  transition: transform 0.2s ease;
}

a.mparamos-link:hover,
a.mparamos-link:focus-visible {
  transform: scale(1.05);
  color: transparent;
  font-weight: bold;
  background-image: linear-gradient(90deg, #10b981, #3b82f6, #10b981);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  animation: rotarColores 3s linear infinite;
  outline: none;
}

.resource-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.4);
  color: #e2e8f0;
  text-decoration: none;
  border-radius: 0.65rem;
  font-weight: 700;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.resource-btn:hover:not(:disabled),
.resource-btn:focus-visible:not(:disabled) {
  background: rgba(14, 165, 233, 0.3);
  border-color: rgba(14, 165, 233, 0.85);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
  transform: translateY(-2px);
  outline: none;
}

.resource-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* =========================================
   BANDERAS CSS PURAS (I18N)
   ========================================= */
.flag-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flag-btn {
  width: 32px;
  height: 22px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  outline: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  display: block;
}

.flag-btn:hover {
  transform: scale(1.15);
  border-color: #666;
}

.flag-btn.active {
  border-color: #00ff88;
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.7);
  z-index: 2;
}

.flag-es {
  background: linear-gradient(to bottom, #c60b1e 25%, #ffc400 25%, #ffc400 75%, #c60b1e 75%);
}

.flag-fr {
  background: linear-gradient(to right, #002395 33.3%, #ffffff 33.3%, #ffffff 66.6%, #ed2939 66.6%);
}

.flag-en {
  background: #fff;
}

.flag-en::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, #3c3b6e 45%, transparent 45%) 0 0 / 100% 50% no-repeat,
    repeating-linear-gradient(to bottom, #b22234 0, #b22234 11.11%, #fff 11.11%, #fff 22.22%);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.flag-en::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, transparent 40%, #c8102e 40%, #c8102e 60%, transparent 60%),
    linear-gradient(to right, transparent 43%, #c8102e 43%, #c8102e 57%, transparent 57%),
    linear-gradient(to bottom, transparent 33%, #fff 33%, #fff 67%, transparent 67%),
    linear-gradient(to right, transparent 36%, #fff 36%, #fff 64%, transparent 64%),
    linear-gradient(35deg, transparent 46%, #c8102e 46%, #c8102e 54%, transparent 54%),
    linear-gradient(-35deg, transparent 46%, #c8102e 46%, #c8102e 54%, transparent 54%),
    linear-gradient(35deg, transparent 40%, #fff 40%, #fff 60%, transparent 60%),
    linear-gradient(-35deg, transparent 40%, #fff 40%, #fff 60%, transparent 60%),
    #012169;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.flag-en-separator {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top left, transparent 47%, #222 47%, #222 53%, transparent 53%);
  z-index: 10;
  pointer-events: none;
}

/* =========================================
   CONTENIDO PRINCIPAL Y TARJETAS
   ========================================= */
main.mp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 1.25rem 1rem;
  position: relative;
  z-index: 10;
}

.central-card {
  width: 100%;
  max-width: 40rem;
  background: rgba(11, 15, 25, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1rem;
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.8);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.legal-card {
  max-width: 52rem;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-color);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
}

.status-pill.is-open {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.status-pill.is-closed {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 9999px;
  background: currentColor;
}

.ws-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ws-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: #64748b;
}

.ws-dot.online { background: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.8); }
.ws-dot.reconnecting { background: #f59e0b; }

/* Campos y botones */
.mp-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 0.4rem;
}

.mp-input {
  width: 100%;
  background: rgba(13, 17, 23, 0.92);
  border: 1px solid #334155;
  color: #f8fafc;
  border-radius: 0.65rem;
  padding: 0.78rem 0.95rem;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mp-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.btn-primary {
  width: 100%;
  border: none;
  border-radius: 0.75rem;
  padding: 0.88rem 1.15rem;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(to right, #10b981, #3b82f6);
  cursor: pointer;
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.38);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 24px rgba(59, 130, 246, 0.65);
  filter: brightness(1.06);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  width: 100%;
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(14, 165, 233, 0.12);
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(14, 165, 233, 0.28);
  border-color: rgba(59, 130, 246, 0.85);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-danger {
  width: 100%;
  border: 1px solid rgba(239, 68, 68, 0.55);
  border-radius: 0.75rem;
  padding: 0.78rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.5);
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(185, 28, 28, 0.78);
  border-color: rgba(248, 113, 113, 0.85);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Cajas informativas, alertas y turno en vivo */
.pseudonym-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.14));
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 0.85rem;
  padding: 1rem;
  text-align: center;
}

.pseudonym-title {
  margin: 0.3rem 0 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
}

.ahead-counter {
  text-align: center;
  padding: 1.2rem 1rem;
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.ahead-number {
  font-size: 3.1rem;
  font-weight: 900;
  line-height: 1.05;
  background: linear-gradient(to right, #10b981, #3b82f6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ahead-caption {
  margin: 0.45rem 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: #e2e8f0;
}

.warning-box {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde68a;
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.86rem;
}

.error-box {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fecaca;
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.88rem;
}

.success-box {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #a7f3d0;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.86rem;
  color: #cbd5e1;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  accent-color: #10b981;
  flex-shrink: 0;
}

.actions-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.hidden {
  display: none !important;
}

/* Footer layout */
.mp-footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.mp-footer-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  text-align: center;
}

.mp-footer-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.mp-footer-logo {
  height: 1.75rem;
  width: auto;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.mp-footer-logo:hover {
  transform: scale(1.05);
  opacity: 0.85;
}

.mp-footer-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.mp-footer-bottom {
  border-top: 1px solid rgba(30, 41, 59, 0.7);
  padding-top: 0.5rem;
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.45;
}

.mp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(6px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.mp-modal {
  width: 100%;
  max-width: 28rem;
  background: #0d1117;
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Scroll independiente para el panel del profesor */
.queue-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.5) transparent;
}

@keyframes rotarColores {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@media (min-width: 768px) {
  .mp-header-inner,
  .mp-brand-group {
    flex-direction: row;
    text-align: left;
  }

  .mp-head-text {
    align-items: flex-start;
    text-align: left;
  }

  .mp-head-title-wrap {
    align-items: flex-start;
  }

  .mp-sub-row {
    justify-content: flex-start;
  }

  .mp-title {
    font-size: 1.45rem;
  }

  .mp-footer-top {
    flex-direction: row;
    text-align: left;
  }

  .mp-footer-brand {
    justify-content: flex-start;
  }
}
