/* ═══════════════════════════════════════════════════════════════
   QUIMII — STICKERS SYSTEM
   Diseño moderno tipo Discord/Telegram/WhatsApp
   Color principal: #1DA1F2
═══════════════════════════════════════════════════════════════ */

/* ── Botón sticker en la toolbar ─────────────────────────────── */
.sticker-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted, #94a3b8);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.sticker-btn:hover {
  color: #1DA1F2;
  background: rgba(29, 161, 242, 0.1);
}
.sticker-btn svg {
  width: 20px;
  height: 20px;
}

/* ── Panel stickers ──────────────────────────────────────────── */
.sticker-panel {
  position: fixed;
  z-index: 999;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: min(380px, 96vw);
  max-height: 420px;
  background: var(--bg-panel, #16213e);
  border: 1px solid rgba(29, 161, 242, 0.18);
  border-radius: 18px;
  box-shadow:
    0 8px 40px rgba(0,0,0,0.45),
    0 0 0 1px rgba(29,161,242,0.08),
    inset 0 1px 0 rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.18s, transform 0.18s;
}
.sticker-panel.hidden {
  display: none;
}
.sticker-panel.panel-enter {
  animation: stickerPanelIn 0.2s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}
@keyframes stickerPanelIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1);    }
}

/* ── Panel header / tabs ─────────────────────────────────────── */
.sticker-panel-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sticker-tab-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 8px 8px 0 0;
  border: none;
  background: none;
  color: var(--text-muted, #94a3b8);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  letter-spacing: 0.01em;
  position: relative;
}
.sticker-tab-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.sticker-tab-btn.active {
  color: #1DA1F2;
  background: rgba(29, 161, 242, 0.08);
}
.sticker-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 2px;
  background: #1DA1F2;
  border-radius: 2px 2px 0 0;
}

/* ── Panel body ──────────────────────────────────────────────── */
.sticker-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(29,161,242,0.3) transparent;
}
.sticker-panel-body::-webkit-scrollbar {
  width: 4px;
}
.sticker-panel-body::-webkit-scrollbar-track {
  background: transparent;
}
.sticker-panel-body::-webkit-scrollbar-thumb {
  background: rgba(29,161,242,0.3);
  border-radius: 99px;
}

/* Tab content visibility */
.sticker-tab-content { display: none; }
.sticker-tab-content.active { display: block; }

/* ── Grid de stickers ────────────────────────────────────────── */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.sticker-grid-item {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(255,255,255,0.03);
  border: 1.5px solid transparent;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sticker-grid-item:hover {
  transform: scale(1.08);
  border-color: rgba(29, 161, 242, 0.45);
  background: rgba(29, 161, 242, 0.08);
  box-shadow: 0 4px 16px rgba(29,161,242,0.2);
}
.sticker-grid-item:active {
  transform: scale(0.95);
}
.sticker-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

/* Delete badge on sticker */
.sticker-grid-item .sticker-del-btn {
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.85);
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding: 0;
  transition: background 0.15s, opacity 0.15s;
  z-index: 2;
}
.sticker-grid-item .sticker-del-btn svg {
  width: 10px; height: 10px;
}
.sticker-grid-item:hover .sticker-del-btn {
  display: flex;
}
.sticker-grid-item .sticker-del-btn:hover {
  background: #ef4444;
}

/* Empty states */
.sticker-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 10px;
  color: var(--text-muted, #64748b);
  text-align: center;
}
.sticker-empty svg {
  width: 40px; height: 40px;
  opacity: 0.35;
}
.sticker-empty p {
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
}
.sticker-empty small {
  font-size: 11px;
  opacity: 0.6;
}

/* ── Sección "Recientes" ─────────────────────────────────────── */
.sticker-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #64748b);
  margin-bottom: 8px;
  margin-top: 4px;
}

/* ── Upload zone / footer ────────────────────────────────────── */
.sticker-upload-zone {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sticker-upload-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  border: 1.5px dashed rgba(29, 161, 242, 0.35);
  background: rgba(29, 161, 242, 0.04);
  color: #1DA1F2;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.sticker-upload-btn:hover {
  background: rgba(29, 161, 242, 0.1);
  border-color: rgba(29, 161, 242, 0.6);
}
.sticker-upload-btn svg {
  width: 15px; height: 15px;
}
#stickerFileInput { display: none; }

/* ── Loading spinner ─────────────────────────────────────────── */
.sticker-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.sticker-spinner {
  width: 24px; height: 24px;
  border: 2.5px solid rgba(29,161,242,0.2);
  border-top-color: #1DA1F2;
  border-radius: 50%;
  animation: stickerSpin 0.7s linear infinite;
}
@keyframes stickerSpin {
  to { transform: rotate(360deg); }
}

/* ── Progress bar de subida ──────────────────────────────────── */
.sticker-upload-progress {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
}
.sticker-upload-progress.visible {
  display: flex;
}
.sticker-progress-bar-wrap {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
}
.sticker-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1DA1F2, #60c4ff);
  border-radius: 99px;
  transition: width 0.3s ease;
  width: 0%;
}

/* ── Drag-over glow effect en el chat ────────────────────────── */
.chat-main.sticker-drag-over {
  outline: 2.5px solid #1DA1F2 !important;
  outline-offset: -3px;
  background: rgba(29, 161, 242, 0.04) !important;
}
.sticker-drag-overlay {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: rgba(29, 161, 242, 0.07);
  border: 2.5px dashed rgba(29, 161, 242, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  z-index: 80;
  backdrop-filter: blur(1px);
  animation: dragOverlayIn 0.15s ease both;
}
@keyframes dragOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.sticker-drag-overlay svg {
  width: 48px; height: 48px;
  color: #1DA1F2;
  filter: drop-shadow(0 0 12px rgba(29,161,242,0.5));
}
.sticker-drag-overlay span {
  font-size: 14px;
  font-weight: 600;
  color: #1DA1F2;
  text-shadow: 0 0 20px rgba(29,161,242,0.5);
}

/* ── Stickers animados: indicador visual ─────────────────────── */
.sticker-grid-item.is-animated::after {
  content: '▶';
  position: absolute;
  bottom: 4px;
  right: 5px;
  font-size: 8px;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.sticker-grid-item.is-animated:hover::after {
  opacity: 0; /* ocultar cuando ya está animando */
}
/* Pequeño badge "GIF" en esquina */
.sticker-grid-item.is-animated .sticker-anim-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: rgba(255,255,255,0.85);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 1px 4px;
  border-radius: 4px;
  pointer-events: none;
  transition: opacity 0.15s;
}
.sticker-grid-item.is-animated:hover .sticker-anim-badge {
  opacity: 0;
}

/* Modal: cursor pointer sobre imagen animada para indicar que se puede hover */
.sticker-modal-img-wrap img[data-animated-src] {
  cursor: crosshair;
}
.sticker-modal-img-wrap img[data-animated-src]:hover {
  cursor: default;
}

.msg-sticker {
  max-width: 160px;
  width: 160px;
  padding: 0;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}
.msg-sticker img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.25));
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
}
.msg-sticker img:hover {
  transform: scale(1.08);
}

/* Burbujas de sticker sin fondo */
.msg-wrapper:has(.msg-sticker) .msg-bubble {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
}

/* ── Botón favorito (estrella) en cada sticker del grid ──────── */
.sticker-grid-item .sticker-fav-btn {
  position: absolute;
  top: 4px; left: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  padding: 0;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
  z-index: 2;
}
.sticker-grid-item .sticker-fav-btn svg {
  width: 10px; height: 10px;
}
.sticker-grid-item:hover .sticker-fav-btn {
  display: flex;
}
.sticker-grid-item .sticker-fav-btn.is-fav {
  display: flex;
  color: #FBBF24;
  background: rgba(0, 0, 0, 0.55);
}
.sticker-grid-item .sticker-fav-btn:hover {
  color: #FBBF24;
  background: rgba(0, 0, 0, 0.75);
}

/* ── Modal de sticker (tipo WhatsApp) ────────────────────────── */
.sticker-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sticker-modal.hidden {
  display: none;
}
.sticker-modal-enter .sticker-modal-box {
  animation: stickerModalIn 0.22s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}
@keyframes stickerModalIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

.sticker-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sticker-modal-box {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px 20px 20px;
  background: var(--bg-panel, #16213e);
  border: 1px solid rgba(29, 161, 242, 0.18);
  border-radius: 22px;
  box-shadow:
    0 16px 64px rgba(0,0,0,0.55),
    0 0 0 1px rgba(29,161,242,0.08),
    inset 0 1px 0 rgba(255,255,255,0.05);
  width: min(320px, 90vw);
}

.sticker-modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.07);
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.sticker-modal-close svg { width: 13px; height: 13px; }
.sticker-modal-close:hover {
  background: rgba(255,255,255,0.13);
  color: #f1f5f9;
}

.sticker-modal-img-wrap {
  width: 200px; height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sticker-modal-img-wrap img {
  width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.4));
  border-radius: 8px;
}

.sticker-modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}
.sticker-modal-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.sticker-modal-btn:active { transform: scale(0.96); }
.sticker-modal-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.sticker-modal-fav {
  background: rgba(251, 191, 36, 0.12);
  color: #FBBF24;
  border: 1.5px solid rgba(251, 191, 36, 0.25);
}
.sticker-modal-fav:hover {
  background: rgba(251, 191, 36, 0.2);
}
.sticker-modal-fav.is-fav {
  background: rgba(251, 191, 36, 0.22);
  border-color: rgba(251, 191, 36, 0.5);
}

.sticker-modal-dl {
  background: rgba(29, 161, 242, 0.1);
  color: #1DA1F2;
  border: 1.5px solid rgba(29, 161, 242, 0.25);
}
.sticker-modal-dl:hover {
  background: rgba(29, 161, 242, 0.18);
}
.sticker-import-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--bg-card, #1e293b);
  border: 1px solid rgba(29,161,242,0.3);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #f1f5f9;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  z-index: 1100;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.sticker-import-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.sticker-import-toast .sit-icon {
  font-size: 18px;
}
.sticker-import-toast .sit-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(29,161,242,0.25);
  border-top-color: #1DA1F2;
  border-radius: 50%;
  animation: stickerSpin 0.6s linear infinite;
  flex-shrink: 0;
}