/* =========================================================================
   CONNEXA STICKER & ANIMATED EMOJI MARKETPLACE — STYLES
   Uses the host app's existing CSS variables (--primary-color, --text-dark,
   --text-grey, --secondary-bg, --border-color, --shadow-lg, etc.)
   ========================================================================= */

/* ---------- Composer sticker button ---------- */
#sticker-button {
  border: none; background: transparent; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-grey); flex-shrink: 0; transition: background .15s, color .15s;
}
#sticker-button:hover { color: var(--primary-color); background: #eff6ff; }
body.dark-mode #sticker-button:hover { background: rgba(59,130,246,0.15); }

/* ---------- Backdrop + Sheet shell ---------- */
.sticker-sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.35);
  opacity: 0; pointer-events: none; transition: opacity .25s ease; z-index: 9998;
}
.sticker-sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sticker-sheet {
  position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%);
  width: 100%; max-width: 480px; height: 68vh; max-height: 620px;
  background: var(--white, #fff); border-radius: 28px 28px 0 0;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  z-index: 9999;
}
.sticker-sheet.open { transform: translate(-50%, 0); }
body.dark-mode .sticker-sheet { background: #1e293b; }

.sticker-sheet-handle {
  width: 36px; height: 4px; border-radius: 3px; background: var(--border-color);
  margin: 10px auto 4px;
}

.sticker-sheet-search {
  display: flex; align-items: center; gap: 8px; padding: 6px 16px 10px;
  color: var(--text-grey);
}
.sticker-sheet-search input {
  flex: 1; border: none; outline: none; background: var(--secondary-bg);
  border-radius: 20px; padding: 9px 14px; font-size: 14px; color: var(--text-dark);
}
.sticker-sheet-close { cursor: pointer; }

.sticker-sheet-tabs {
  display: flex; border-bottom: 1px solid var(--border-color); padding: 0 8px;
  flex-shrink: 0;
}
.sticker-tab {
  flex: 1; border: none; background: transparent; padding: 10px 0; cursor: pointer;
  color: var(--text-grey); display: flex; align-items: center; justify-content: center;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.sticker-tab.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }

.sticker-sheet-body { flex: 1; overflow-y: auto; padding: 12px 16px 24px; }
.sticker-scroll { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Sections ---------- */
.sticker-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sticker-section-head h4 { font-size: 13px; font-weight: 700; color: var(--text-dark); text-transform: uppercase; letter-spacing: .4px; }

.sticker-hint { font-size: 12.5px; color: var(--text-grey); background: var(--secondary-bg); padding: 8px 12px; border-radius: 12px; }

/* ---------- Sticker grid / rows ---------- */
.sticker-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.sticker-row.wrap { flex-wrap: wrap; overflow: visible; }

.sticker-tile {
  position: relative; width: 68px; height: 68px; flex-shrink: 0;
  background: var(--secondary-bg); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transform: scale(.85);
  transition: opacity .25s ease, transform .25s ease, background .15s;
}
.sticker-tile.sticker-visible { opacity: 1; transform: scale(1); }
.sticker-tile:hover { background: #e2e8f0; }
body.dark-mode .sticker-tile { background: #273449; }
body.dark-mode .sticker-tile:hover { background: #324058; }

.sticker-tile-emoji { font-size: 34px; line-height: 1; }
.sticker-tile-img { width: 100%; height: 100%; object-fit: contain; border-radius: 16px; }

.sticker-fav-btn {
  position: absolute; top: 2px; right: 2px; font-size: 15px;
  color: var(--text-grey); background: rgba(255,255,255,.85); border-radius: 50%; padding: 1px;
}
.sticker-fav-btn.active { color: #f59e0b; }

/* ---------- Category chips ---------- */
.sticker-chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.sticker-chip {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-color); background: var(--white);
  border-radius: 20px; padding: 7px 14px; font-size: 12.5px; color: var(--text-grey);
  cursor: pointer;
}
.sticker-chip .material-icons { font-size: 16px; }
.sticker-chip.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
body.dark-mode .sticker-chip { background: #273449; border-color: #334155; }

/* ---------- Pack cards ---------- */
.sticker-pack-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.sticker-pack-card {
  background: var(--secondary-bg); border-radius: 18px; padding: 10px; cursor: pointer;
  opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease;
}
.sticker-pack-card.sticker-visible { opacity: 1; transform: translateY(0); }
body.dark-mode .sticker-pack-card { background: #273449; }

.sticker-pack-cover {
  height: 72px; border-radius: 12px; background: var(--white);
  display: flex; align-items: center; justify-content: center; font-size: 36px; position: relative;
  overflow: hidden;
}
.sticker-pack-cover img { width: 100%; height: 100%; object-fit: contain; }
body.dark-mode .sticker-pack-cover { background: #1e293b; }
.pack-badge {
  position: absolute; top: 6px; right: 6px; background: var(--primary-color); color: #fff;
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 8px;
}

.sticker-pack-meta { margin-top: 8px; }
.sticker-pack-meta strong { display: block; font-size: 13px; color: var(--text-dark); }
.sticker-pack-meta span { font-size: 11px; color: var(--text-grey); }

.sticker-pack-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.sticker-pack-btn {
  border: none; background: var(--white); color: var(--text-grey);
  border-radius: 10px; padding: 6px 10px; cursor: pointer; display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; box-shadow: var(--shadow-sm);
}
.sticker-pack-btn.primary { background: var(--primary-color); color: #fff; }
.sticker-pack-btn.danger { background: var(--danger); color: #fff; }
.sticker-pack-btn.wide { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
body.dark-mode .sticker-pack-btn { background: #1e293b; }

/* ---------- Empty state ---------- */
.sticker-empty { text-align: center; color: var(--text-grey); padding: 30px 10px; }
.sticker-empty .material-icons { font-size: 40px; opacity: .5; margin-bottom: 6px; }
.sticker-empty p { font-size: 13px; }

/* ---------- Inline action button (Create pack) ---------- */
.sticker-mine-actions { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.sticker-inline-btn {
  border: none; background: var(--primary-color); color: #fff; border-radius: 12px;
  padding: 8px 14px; font-size: 13px; display: flex; align-items: center; gap: 6px; cursor: pointer;
}

/* ---------- Preview / Create modal ---------- */
.sticker-preview-modal {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45); z-index: 10001;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity .2s ease;
}
.sticker-preview-modal.open, .sticker-preview-modal { opacity: 1; }
.sticker-preview-card {
  background: var(--white); border-radius: 20px; width: 100%; max-width: 420px;
  max-height: 80vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden;
}
body.dark-mode .sticker-preview-card { background: #1e293b; }
.sticker-preview-head {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 18px;
  border-bottom: 1px solid var(--border-color); color: var(--text-dark);
}
.sticker-preview-close { cursor: pointer; color: var(--text-grey); }
.sticker-preview-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 16px;
  overflow-y: auto;
}
.sticker-preview-actions { padding: 14px 18px; border-top: 1px solid var(--border-color); }

/* ---------- Create pack form ---------- */
.sticker-create-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.sticker-text-input {
  border: 1px solid var(--border-color); border-radius: 12px; padding: 10px 14px;
  font-size: 14px; outline: none; color: var(--text-dark); background: var(--white);
}
.sticker-text-input:focus { border-color: var(--primary-color); }
body.dark-mode .sticker-text-input { background: #273449; color: #f1f5f9; }

.sticker-import-drop {
  border: 2px dashed var(--border-color); border-radius: 16px; padding: 22px 10px;
  text-align: center; color: var(--text-grey); cursor: pointer;
}
.sticker-import-drop .material-icons { font-size: 30px; color: var(--primary-color); }
.sticker-import-drop p { font-size: 12.5px; margin-top: 6px; }

.sticker-import-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.sticker-import-grid .sticker-tile { width: 100%; height: 56px; opacity: 1; transform: none; }

/* ---------- Toast ---------- */
.sticker-toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 10px);
  background: var(--text-dark); color: #fff; padding: 10px 18px; border-radius: 12px;
  font-size: 13px; z-index: 10010; opacity: 0; transition: opacity .2s, transform .2s;
  box-shadow: var(--shadow-lg);
}
.sticker-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================================
   ANIMATED EMOJI — chat bubble (big-emoji-msg) + marketplace tiles
   ========================================================================= */
.big-emoji-msg { display: flex; gap: 6px; padding: 4px 2px; }
.big-emoji { font-size: 56px; line-height: 1; display: inline-block; }
.big-emoji-msg.sme-multi .big-emoji { font-size: 40px; }

/* Message bubbles carrying only a sticker or a big emoji lose their bubble chrome,
   Telegram-style, so the art reads on the background. */
.message-container.sticker-message .message,
.message-container.big-emoji-message .message {
  background: transparent !important; box-shadow: none !important; padding: 2px 0 !important;
  position: relative;
}
.sticker-msg-emoji { font-size: 88px; line-height: 1; }
.sticker-msg-image { width: 128px; height: 128px; object-fit: contain; }

/* Without bubble chrome, the light-on-bubble time/tick styling from
   chatStyles.css (white @ 75% opacity) disappears against a light chat
   background. Give sticker/big-emoji messages a small floating pill —
   the same trick Telegram/WhatsApp use on photos — so time + read ticks
   stay legible no matter the theme or wallpaper underneath. */
.message-container.sticker-message .time-status,
.message-container.big-emoji-message .time-status {
  position: absolute;
  right: 4px;
  bottom: 2px;
  margin-top: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: rgba(255, 255, 255, 0.92) !important;
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1.5;
  pointer-events: none;
}
.message-container.sticker-message .time-status .status-tick,
.message-container.big-emoji-message .time-status .status-tick {
  color: rgba(255, 255, 255, 0.85) !important;
}
.message-container.sticker-message .time-status .status-tick.read,
.message-container.big-emoji-message .time-status .status-tick.read {
  color: #7dc4ff !important;
}
/* Big-emoji messages render 1-3 glyphs side by side and don't have the
   fixed footprint a sticker tile has — leave room so the pill never
   overlaps a glyph mid-animation. */
.message-container.big-emoji-message .message { padding-bottom: 20px !important; }
.message-container.sticker-message .message { padding-bottom: 4px !important; }

@keyframes sme-fire {
  0%, 100% { transform: scale(1) rotate(-2deg); filter: brightness(1); }
  50% { transform: scale(1.12) rotate(2deg); filter: brightness(1.25); }
}
.sme-fire { animation: sme-fire .55s ease-in-out infinite; transform-origin: 60% 100%; }

@keyframes sme-laugh {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  20% { transform: rotate(-12deg) translateY(-2px); }
  40% { transform: rotate(10deg) translateY(0); }
  60% { transform: rotate(-8deg) translateY(-2px); }
  80% { transform: rotate(6deg) translateY(0); }
}
.sme-laugh { animation: sme-laugh .6s ease-in-out infinite; }

@keyframes sme-hurt {
  0%, 40%, 100% { opacity: 1; transform: scale(1); }
  20% { opacity: .35; transform: scale(.92) translateX(-2px); }
  60% { transform: scale(1.05) translateX(2px); }
}
.sme-hurt { animation: sme-hurt 1.1s ease-in-out infinite; }

@keyframes sme-wink {
  0%, 85%, 100% { transform: scaleY(1); }
  92% { transform: scaleY(0.15); }
}
.sme-wink { animation: sme-wink 1.6s ease-in-out infinite; transform-origin: center; }

@keyframes sme-heartbeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.2); }
  40% { transform: scale(1); }
  55% { transform: scale(1.15); }
}
.sme-heartbeat { animation: sme-heartbeat .9s ease-in-out infinite; }

@keyframes sme-heart-eyes {
  0%, 100% { transform: scale(1) rotate(0); }
  50% { transform: scale(1.1) rotate(-4deg); }
}
.sme-heart-eyes { animation: sme-heart-eyes .8s ease-in-out infinite; }

@keyframes sme-cry {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}
.sme-cry { animation: sme-cry .7s ease-in-out infinite; }

@keyframes sme-pop {
  0% { transform: scale(.6); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.sme-pop { animation: sme-pop .5s cubic-bezier(.34,1.56,.64,1) both, sme-pulse 1.4s ease-in-out 0.5s infinite; }

@keyframes sme-clap {
  0%, 100% { transform: rotate(0) scale(1); }
  50% { transform: rotate(-15deg) scale(1.1); }
}
.sme-clap { animation: sme-clap .4s ease-in-out infinite; }

@keyframes sme-thumbsup {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-6px) rotate(-8deg); }
}
.sme-thumbsup { animation: sme-thumbsup .7s ease-in-out infinite; }

@keyframes sme-party {
  0% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.1) rotate(8deg); }
  75% { transform: scale(1.1) rotate(-8deg); }
  100% { transform: scale(1) rotate(0); }
}
.sme-party { animation: sme-party .8s ease-in-out infinite; }

@keyframes sme-angry {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-3px) rotate(-4deg); }
  75% { transform: translateX(3px) rotate(4deg); }
}
.sme-angry { animation: sme-angry .3s ease-in-out infinite; }

@keyframes sme-sleep {
  0%, 100% { transform: translateY(0) rotate(0); opacity: 1; }
  50% { transform: translateY(-4px) rotate(-3deg); opacity: .75; }
}
.sme-sleep { animation: sme-sleep 2s ease-in-out infinite; }

@keyframes sme-sparkle {
  0%, 100% { transform: scale(1) rotate(0); filter: brightness(1); }
  50% { transform: scale(1.15) rotate(10deg); filter: brightness(1.4); }
}
.sme-sparkle { animation: sme-sparkle .9s ease-in-out infinite; }

@keyframes sme-pray {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.sme-pray { animation: sme-pray 1.2s ease-in-out infinite; }

@keyframes sme-kiss {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.sme-kiss { animation: sme-kiss .8s ease-in-out infinite; }

@keyframes sme-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.sme-pulse { animation: sme-pulse 1.6s ease-in-out infinite; }

.forward-sticker-emoji { font-size: 28px; line-height: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .sticker-sheet { max-width: 100%; height: 72vh; }
  .sticker-pack-list { grid-template-columns: repeat(3, 1fr); }
  .big-emoji { font-size: 46px; }
}