/* Aviso de error de conexion / servidor: diente animado delante del icono de InciSoft.
   Sin color-mix ni :has para que se vea igual en la tablet del sillon (Chrome viejo). */
.server-error-overlay {
  --se-primary: #2775f5;
  --se-surface: #ffffff;
  --se-surface-2: #f8fbff;
  --se-border: #dde8f3;
  --se-text: #16263d;
  --se-muted: #66778d;
  --se-danger: #e5484d;
  --se-tooth: #ffffff;
  --se-tooth-line: #16263d;
  --se-glow: rgba(39, 117, 245, 0.18);
  --se-shadow-soft: rgba(22, 38, 61, 0.12);
  --se-card-shadow: 0 30px 70px rgba(22, 38, 61, 0.22), 0 2px 6px rgba(22, 38, 61, 0.08);

  position: fixed;
  inset: 0;
  z-index: 8000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 30, 55, 0.38);
  backdrop-filter: blur(3px);
}

body.dark-mode .server-error-overlay {
  --se-primary: #60a5fa;
  --se-surface: #0f172a;
  --se-surface-2: #111c2f;
  --se-border: #26354a;
  --se-text: #e8f1ff;
  --se-muted: #9eb2cc;
  --se-tooth: #eef4ff;
  --se-tooth-line: #0b1220;
  --se-glow: rgba(96, 165, 250, 0.18);
  --se-shadow-soft: rgba(232, 241, 255, 0.12);
  --se-card-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
  background: rgba(2, 6, 14, 0.62);
}

.server-error-overlay.is-open {
  display: flex;
}

.server-error-card {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow: hidden auto;
  padding: 26px 28px 24px;
  border-radius: 24px;
  border: 1px solid var(--se-border);
  background: var(--se-surface);
  color: var(--se-text);
  box-shadow: var(--se-card-shadow);
  text-align: center;
  animation: serverErrorCardIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.server-error-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 210px;
  z-index: 0;
  background: radial-gradient(60% 90% at 50% 0%, var(--se-glow), transparent 70%);
  pointer-events: none;
}

.server-error-card > * {
  position: relative;
  z-index: 1;
}

/* ---------- Escena: icono atras, diente delante ---------- */
.server-error-scene {
  position: relative;
  width: 250px;
  height: 200px;
  margin: 0 auto 6px;
}

.server-error-logo,
.server-error-halo {
  position: absolute;
  left: 18px;
  top: 8px;
  width: 150px;
  height: 150px;
  border-radius: 34px;
  transform: rotate(-6deg);
}

.server-error-logo {
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(10, 23, 48, 0.35), 0 0 0 1px var(--se-shadow-soft);
}

.server-error-logo img {
  width: 100%;
  height: 100%;
  display: block;
}

.server-error-halo {
  border: 2px solid var(--se-danger);
  opacity: 0;
  animation: serverErrorHalo 2.4s ease-out infinite;
}

.server-error-halo.h2 {
  animation-delay: 1.2s;
}

.server-error-badge {
  position: absolute;
  left: 146px;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--se-danger);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 4px var(--se-surface);
  animation: serverErrorShake 2.4s ease-in-out infinite;
}

.server-error-tooth {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 118px;
  height: 140px;
  overflow: visible;
}

.server-error-tooth-group {
  transform-origin: 80px 150px;
  animation: serverErrorFloat 3.2s ease-in-out infinite;
}

.server-error-shadow {
  fill: var(--se-shadow-soft);
  transform-origin: 80px 186px;
  animation: serverErrorShadow 3.2s ease-in-out infinite;
}

.server-error-tooth-body {
  fill: var(--se-tooth);
  stroke: var(--se-tooth-line);
  stroke-width: 3.5;
  stroke-linejoin: round;
  filter: drop-shadow(0 6px 10px rgba(10, 23, 48, 0.22));
}

.server-error-shine {
  fill: none;
  stroke: #93c5fd;
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.8;
}

.server-error-eye {
  fill: var(--se-tooth-line);
  transform-box: fill-box;
  transform-origin: center;
  animation: serverErrorBlink 4s infinite;
}

.server-error-cheek {
  fill: #ff8fb1;
  opacity: 0.55;
}

.server-error-mouth {
  fill: var(--se-tooth-line);
}

.server-error-sweat {
  fill: #7cc4ff;
  animation: serverErrorSweat 3.2s ease-in infinite;
}

/* ---------- Textos y botones ---------- */
.server-error-code {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3em;
  color: var(--se-muted);
}

.server-error-title {
  margin: 12px 0 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--se-text);
}

.server-error-message {
  margin: 0 auto;
  max-width: 400px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--se-muted);
  word-break: break-word;
}

.server-error-detail {
  margin: 10px auto 0;
  max-width: 400px;
  font-size: 12px;
  color: var(--se-muted);
  word-break: break-all;
  opacity: 0.85;
}

.server-error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.server-error-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--se-border);
  border-radius: 12px;
  padding: 11px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.server-error-btn:hover {
  transform: translateY(-1px);
}

.server-error-btn.secondary {
  background: var(--se-surface-2);
  color: var(--se-text);
}

.server-error-btn.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--se-primary), #3aa0ff);
  box-shadow: 0 8px 20px rgba(39, 117, 245, 0.35);
}

.server-error-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.server-error-btn.primary:hover svg {
  animation: serverErrorSpin 0.7s ease;
}

/* ---------- Animaciones ---------- */
@keyframes serverErrorCardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
}

@keyframes serverErrorFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}

@keyframes serverErrorShadow {
  50% { transform: scaleX(0.8); opacity: 0.6; }
}

@keyframes serverErrorBlink {
  0%, 44%, 50%, 100% { transform: scaleY(1); }
  47% { transform: scaleY(0.1); }
}

@keyframes serverErrorSweat {
  0%, 40% { opacity: 0; transform: translateY(-4px); }
  55% { opacity: 1; }
  100% { opacity: 0; transform: translateY(14px); }
}

@keyframes serverErrorHalo {
  0% { transform: rotate(-6deg) scale(1); opacity: 0.55; }
  100% { transform: rotate(-6deg) scale(1.22); opacity: 0; }
}

@keyframes serverErrorShake {
  0%, 80%, 100% { transform: rotate(0); }
  84% { transform: rotate(-12deg); }
  88% { transform: rotate(10deg); }
  92% { transform: rotate(-6deg); }
}

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

@media (prefers-reduced-motion: reduce) {
  .server-error-overlay *,
  .server-error-overlay *::before {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 560px) {
  .server-error-card {
    padding: 22px 18px 20px;
    border-radius: 20px;
  }

  .server-error-title {
    font-size: 21px;
  }

  .server-error-actions .server-error-btn {
    flex: 1 1 auto;
  }
}

/* Poco alto (tablet horizontal): escena mas chica para que entren los botones. */
@media (max-height: 520px) {
  .server-error-scene {
    transform: scale(0.75);
    margin: -22px auto -42px;
  }
}
