@import "tailwindcss";
/* Tailwind v4 At-Rules: The IDE may show warnings if the Tailwind extension is not up to date. */
@plugin "@tailwindcss/forms";
@plugin "@tailwindcss/container-queries";
@custom-variant dark (&:where(.dark, .dark *));

@theme {
  --color-primary: #af272b;
  --color-primary-hover: #8e1f23;
  --color-ral-red: #af272b;
  --color-dark-blue: #05070a;
  --color-background-light: #f8fafc;
  --color-background-dark: #05070a;
  --color-surface-dark: #080c14;
  --color-surface-light: #ffffff;
  --color-card-dark: #1e293b;
  --color-card-dark-alt: #0f172a;
  --color-card-light: #ffffff;
  --color-card-light-alt: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-light: #0f172a;
  --color-accent-green: #10b981;
  --color-accent-orange: #f59e0b;
  --color-border-dark: #1e293b;
  --color-border-light: #e2e8f0;
  --color-success: #22c55e;
  --color-error: #ef4444;
  --color-surface-border: #1e293b;
  --color-warning: #eab308;
  --color-danger: #ef4444;

  --font-display: "Lexend", "Inter", "sans-serif";
  --font-body: "Inter", "sans-serif";

  --breakpoint-3xl: 1920px;
  --breakpoint-4xl: 2560px;

  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-3xl: 1.5rem;
  --radius-4xl: 2rem;

  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --safe-right: env(safe-area-inset-right);
}

/* RAL 3000 / OPOFire Red: #af272b */
:root {
  --primary: #af272b;
  --primary-glow: rgba(175, 39, 43, 0.3);
  --tactical-blue: #3b82f6;
  --slate-dark: #05070a;
  --slate-card: #080c14;
  --emerald: #10b981;
  --input-bg: #080c14;
  --input-text: white;
  --body-bg: #05070a;
  --body-text: white;
}

.light {
  --primary: #AF2B1E;
  --primary-glow: rgba(175, 43, 30, 0.1);
  --tactical-blue: #3b82f6;
  --body-bg: #f8fafc;
  --body-text: #0f172a;
  --input-bg: #ffffff;
  --input-text: #0f172a;
}

html {
  font-size: 16px;
}

@media (min-width: 1024px) and (max-width: 1400px) {
  html {
    font-size: 12px; /* Simula un zoom al 75% reduciendo todos los rem de Tailwind */
  }
}



body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background-color: var(--body-bg);
  color: var(--body-text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  transition: background-color 0.3s, color 0.3s;
}

/* ─── Global Scrollbar (minimal fallback) ─── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(175, 43, 30, 0.25);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(175, 43, 30, 0.55);
}

/* ─── OPOFire Branded Scrollbar ─── */
/* Vertical & horizontal: ultra-thin 4px, red glow thumb */
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: rgba(175, 43, 30, 0.45) transparent;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(8, 12, 20, 0.6);
  border-radius: 99px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(175, 43, 30, 0.45);
  border-radius: 99px;
  box-shadow: 0 0 6px rgba(175, 43, 30, 0.4);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(175, 43, 30, 0.8);
  box-shadow: 0 0 12px rgba(175, 43, 30, 0.6);
}

/* ─── Hidden Scrollbar (functional scroll, invisible bar) ─── */
.custom-scrollbar-hidden {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.custom-scrollbar-hidden::-webkit-scrollbar {
  display: none;
}


/* Glassmorphism utility */
.glass {
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Spotlight Input Effect */
.spotlight-input-container {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  padding: 1px;
  border-radius: 0.75rem;
  overflow: hidden;
  transition: all 0.3s;
  display: flex;
  align-items: stretch;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.light .spotlight-input-container {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.spotlight-input-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(800px circle at var(--mouse-x) var(--mouse-y),
      rgba(29, 78, 216, 0.5),
      transparent 80%);
  transition: opacity 0.5s;
  filter: blur(12px);
}

.spotlight-input-container input,
.spotlight-input-container select,
.spotlight-input-container textarea {
  position: relative;
  z-index: 1;
  background: var(--input-bg) !important;
  color: var(--input-text) !important;
  border: none !important;
  border-radius: inherit !important;
  width: 100%;
  transition: all 0.3s;
  outline: none !important;
}

.input-field-grey {
  background: #1e293b !important;
}

.light .input-field-grey {
  background: #f1f5f9 !important;
}

/* Input Focus - 60% Transparency Blue Border, No jumps */
.spotlight-input-container:focus-within {
  background: rgba(30, 58, 138, 0.6) !important;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

/* Checkbox Crystal Style */
.checkbox-crystal {
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.375rem;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  outline: none !important;
}

.checkbox-crystal:checked {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
}

.checkbox-crystal:checked::after {
  content: 'check';
  font-family: 'Material Symbols Outlined';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--emerald);
  font-size: 14px;
  font-weight: bold;
}

/* Crystal Buttons - Refined subtle border glow */
.emerald-crystal-button {
  background: rgba(16, 185, 129, 0.1) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(16, 185, 129, 0.3) !important;
  color: #10b981 !important;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.05);
  transition: all 0.3s ease;
  position: relative;
}

.emerald-crystal-button:hover {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: rgba(16, 185, 129, 0.8) !important;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.3);
  color: #5eead4 !important;
}

.red-crystal-button {
  background: linear-gradient(135deg, rgba(175, 43, 30, 0.12) 0%, rgba(175, 43, 30, 0.05) 100%) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(175, 43, 30, 0.3) !important;
  color: #fff !important;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 0 20px rgba(175, 43, 30, 0.05);
  position: relative;
}

.red-crystal-button:hover {
  background: linear-gradient(135deg, rgba(175, 43, 30, 0.25) 0%, rgba(175, 43, 30, 0.15) 100%) !important;
  border-color: rgba(175, 43, 30, 0.8) !important;
  box-shadow: 0 0 40px rgba(175, 43, 30, 0.2), inset 0 0 30px rgba(175, 43, 30, 0.1);
}



.blue-crystal-button {
  background: rgba(59, 130, 246, 0.1) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(59, 130, 246, 0.3) !important;
  color: #93c5fd !important;
  transition: all 0.3s ease;
}

.blue-crystal-button:hover {
  background: rgba(59, 130, 246, 0.2) !important;
  border-color: rgba(59, 130, 246, 0.8) !important;
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.3);
  color: #60a5fa !important;
}

/* Floating Crystal Messages */
.crystal-toast-emerald {
  background: rgba(16, 185, 129, 0.2);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(16, 185, 129, 0.1);
  color: white;
}

.crystal-toast-red {
  background: rgba(175, 43, 30, 0.2);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(175, 43, 30, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(175, 43, 30, 0.1);
  color: white;
}

.crystal-toast-info {
  background: rgba(59, 130, 246, 0.2);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(59, 130, 246, 0.1);
  color: white;
}

/* Blue Selection Style for Radio Options */
.radio-selected-blue {
  background: rgba(59, 130, 246, 0.1) !important;
  border-color: rgba(59, 130, 246, 0.5) !important;
  color: #60a5fa !important;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.tag-label-style {
  color: #64748b;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* KaTeX Overrides to fix display in standard Tailwind containers */
.katex {
  font-size: 1.1em !important;
  line-height: normal !important;
  text-indent: 0 !important;
  font-family: KaTeX_Main, 'Times New Roman', serif !important;
  font-weight: normal !important;
  font-style: normal !important;
}

.katex-mathml {
  display: none !important;
}

.katex-display {
  margin: 1em 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5em 0;
}

/* Permitir que el texto explicativo mantenga sus estilos pero la math no */
.markdown-content em {
  font-style: italic;
}

/* Fix for specific QuestionCard styling contexts */
.h1-global .katex,
h1 .katex,
h2 .katex,
h3 .katex,
div .katex {
  font-size: 1em !important;
  /* Relative to parent header size */
  font-weight: normal !important;
  text-transform: none !important;
  letter-spacing: normal !important;
}

/* Ensure math elements inside any parent maintain correct styling */
.markdown-content .katex,
.markdown-content .katex * {
  font-weight: normal !important;
  text-transform: none !important;
  font-style: normal !important;
  letter-spacing: normal !important;
}

.katex-display {
  text-align: center !important;
}

/* 3D Flashcard Utilities */
.perspective-1000 {
  perspective: 1000px;
}

.preserve-3d {
  transform-style: preserve-3d;
}

.backface-hidden {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

@keyframes glow-pulse {
  0% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.6;
  }
}

.animate-glow-pulse {
  animation: glow-pulse 2s infinite ease-in-out;
  /* will-change permite al navegador elevar a capa GPU (sin box-shadow = sin repaint) */
  will-change: opacity;
}

/* Safe Area Utilities */
.pt-safe {
  padding-top: var(--safe-top);
}

.pb-safe {
  padding-bottom: var(--safe-bottom);
}

.pl-safe {
  padding-left: var(--safe-left);
}

.pr-safe {
  padding-right: var(--safe-right);
}

.mt-safe {
  margin-top: var(--safe-top);
}

.mb-safe {
  margin-bottom: var(--safe-bottom);
}

/* Ensure the app container respects safe areas if needed */
#root {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

@layer base {
  /* ========================================================
     GLOBAL RESPONSIVE RESET (Nivel 1)
     ======================================================== */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
    height: 100%;
  }

  #root {
    width: 100%;
  }

  /* Texto que se adapta al contenedor en lugar de desbordarse */
  p, span, h1, h2, h3, h4, h5, h6, label, div {
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
  }

  /* Modales: siempre con scroll interno si el contenido 
     es más alto que la pantalla */
  [role="dialog"],
  .modal-content {
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Imágenes responsive por defecto */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Flexbox: prevenir que los hijos se salgan del contenedor */
  .flex, [class*="flex"] {
    min-width: 0;
  }
}

/* ========================================================
   RICH TEXT OVERRIDES (Blog Editor & Renderer)
   ======================================================== */
.rich-text-body b,
.rich-text-body strong {
  font-weight: 700 !important;
}
.rich-text-body ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}
.rich-text-body ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}
.rich-text-body li {
  margin-bottom: 0.25rem;
  display: list-item;
}
