/* =========================================================
   ÁGUILA REAL — T/C OFICIAL (Valor Referencial BCB)
   =========================================================
   El BCB dejó de publicar compra/venta fijos: desde 2026
   publica UN valor referencial diario. Este widget muestra
   ese único valor.

   Variante "home": nace dentro de #catalogo (sección .catshelf
   en index.html) y pasa a flotante al hacer scroll.
   Variante "floating": flotante persistente desde el inicio,
   usada en catalogo.html y producto.html (atributo
   data-tc-floating en el HTML).
   ========================================================= */

:root {
  --tc-gold: var(--gold, #DEA202);
}

/* =========================================================
   ANCLA (solo variante home) — el contenedor #catalogo
   necesita position:relative para que esto funcione
   ========================================================= */
#tcAnchorHome {
  position: absolute;
  right: 40px;
  top: 40px;
  width: 260px;
  height: 150px;
  pointer-events: none;
  z-index: 20;
}

/* =========================================================
   WIDGET — estructura compartida por ambas variantes
   ========================================================= */
.tc-widget {
  width: 260px;
  padding: 1px;
  border-radius: 18px;
  overflow: hidden;
  pointer-events: auto;
}

/* Variante home: nace posicionada dentro de #tcAnchorHome */
#tcWidgetHome {
  position: absolute;
  top: 0;
  right: 0;
  opacity: 0;
  transform: translateY(18px) scale(.96);
  transition: opacity .45s ease, transform .45s cubic-bezier(.22,1,.36,1);
  z-index: 1000;
}
#tcWidgetHome.tc-visible { opacity: 1; transform: translateY(0) scale(1); }
#tcWidgetHome.tc-floating {
  position: fixed;
  top: auto;
  right: 30px;
  bottom: 30px;
  animation: tcFloat 5s ease-in-out infinite;
}

/* Variante flotante persistente (catalogo.html, producto.html) */
.tc-widget[data-tc-floating] {
  position: fixed;
  right: 30px;
  bottom: 30px;
  z-index: 1500;
  opacity: 0;
  transform: translateY(18px) scale(.96);
  transition: opacity .5s cubic-bezier(.22,1,.36,1), transform .5s cubic-bezier(.22,1,.36,1);
}
.tc-widget[data-tc-floating].tc-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: tcFloat 5s ease-in-out 1s infinite;
}

/* =========================================================
   BORDE DORADO GIRATORIO
   ========================================================= */
.tc-border {
  position: absolute;
  width: 300%;
  height: 300%;
  left: -100%;
  top: -100%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg, transparent 35deg,
    rgba(var(--gold-rgb, 222,162,2), .06) 55deg,
    rgba(var(--gold-rgb, 222,162,2), .28) 75deg,
    var(--tc-gold) 90deg,
    rgba(255,215,80,.85) 102deg,
    rgba(var(--gold-rgb, 222,162,2), .30) 120deg,
    rgba(var(--gold-rgb, 222,162,2), .06) 145deg,
    transparent 165deg, transparent 360deg
  );
  animation: tcBorderRotate 4.5s linear infinite;
}

/* =========================================================
   CONTENIDO
   ========================================================= */
.tc-content {
  position: relative;
  z-index: 2;
  padding: 18px;
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(20,27,22,.98), rgba(11,15,12,.99));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.035);
}

.tc-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.tc-title { display: flex; align-items: center; gap: 10px; }

.tc-status { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: #12833F; animation: tcPulse 2s ease-in-out infinite; }

.tc-title-main { display: block; color: #fff; font-family: "Anton", "Arial Narrow", sans-serif; font-size: 15px; font-weight: 400; line-height: 1; letter-spacing: .03em; }
.tc-title-sub { display: block; margin-top: 4px; color: rgba(255,255,255,.45); font-size: 9px; letter-spacing: .04em; }

.tc-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 23px; padding: 0 8px; border-radius: 999px;
  background: rgba(18,131,63,.18); border: 1px solid rgba(18,131,63,.45);
  color: #fff; font-size: 9px; font-weight: 700; letter-spacing: .08em;
}

.tc-divider { width: 100%; height: 1px; margin: 12px 0; background: rgba(255,255,255,.09); }

/* --- Valor único (reemplaza la grilla compra/venta) --- */
.tc-rate-single { text-align: center; padding: 4px 0 8px; }
.tc-rate-single .tc-label { display: block; margin-bottom: 6px; color: var(--tc-gold); font-size: 10px; font-weight: 700; letter-spacing: .1em; }
.tc-rate-single .tc-value { display: block; color: #fff; font-family: "Inter", Arial, sans-serif; font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }

.tc-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.tc-update { display: flex; align-items: center; gap: 8px; }

.tc-icon { display: flex; align-items: center; justify-content: center; width: 23px; height: 23px; border-radius: 50%; background: rgba(var(--gold-rgb, 222,162,2), .10); color: var(--tc-gold); font-size: 14px; }

.tc-update-label { display: block; color: rgba(255,255,255,.42); font-size: 9px; }
.tc-update-date { display: block; margin-top: 1px; color: rgba(255,255,255,.82); font-size: 10px; }

.tc-source { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; color: rgba(255,255,255,.42); font-size: 9px; }
.tc-source strong { color: rgba(255,255,255,.82); font-size: 10px; }

/* =========================================================
   ESTADOS: cargando / error
   (para que nunca muestre un número viejo sin avisar)
   ========================================================= */
.tc-widget--loading .tc-value { color: rgba(255,255,255,.35); }
.tc-widget--loading .tc-value::after { content: "…"; }

.tc-widget--error .tc-border { animation: none; opacity: .35; }
.tc-widget--error .tc-value { font-size: 15px; color: rgba(255,255,255,.55); }
.tc-widget--error .tc-status { background: #b23b2f; animation: none; }

/* =========================================================
   ANIMACIONES
   ========================================================= */
@keyframes tcBorderRotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes tcFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes tcPulse {
  0%, 100% { opacity: .45; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); box-shadow: 0 0 10px rgba(18,131,63,.35); }
}

.tc-widget:hover { filter: brightness(1.03); }
.tc-widget:hover .tc-border { animation-duration: 3.2s; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1100px) {
  #tcAnchorHome { right: 24px; }
  #tcWidgetHome.tc-floating,
  .tc-widget[data-tc-floating] { right: 24px; bottom: 24px; }
}

@media (max-width: 768px) {
  #tcAnchorHome { position: relative; top: auto; right: auto; width: 100%; height: 0; margin: 0; }
  .tc-widget,
  #tcWidgetHome.tc-floating,
  .tc-widget[data-tc-floating] { width: min(260px, calc(100vw - 32px)); right: 16px; bottom: 16px; }
}

/* =========================================================
   MINIMIZAR / EXPANDIR
   ========================================================= */
.tc-widget[data-tc-floating].tc-widget--collapsed,
#tcWidgetHome.tc-widget--collapsed {
  width: 56px;
  height: 56px;
  border-radius: 50%;
}
.tc-widget--collapsed .tc-content {
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tc-widget--collapsed .tc-header,
.tc-widget--collapsed .tc-divider,
.tc-widget--collapsed .tc-rate-single,
.tc-widget--collapsed .tc-footer {
  display: none;
}

.tc-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.65);
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.tc-toggle:hover { background: rgba(255,255,255,.16); color: #fff; }
.tc-toggle svg { width: 14px; height: 14px; display: block; }

.tc-collapsed-face {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: var(--tc-gold);
  font-family: "Anton", sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: .035em;
  cursor: pointer;
}
.tc-widget--collapsed .tc-collapsed-face { display: flex; }

@media (prefers-reduced-motion: reduce) {
  .tc-border, .tc-status, #tcWidgetHome.tc-floating, .tc-widget[data-tc-floating].tc-visible {
    animation: none;
  }
}
