/* ================================================================
   THOMZY.com — GIF Stickers & Picker
   ================================================================ */

/* ── Sticker overlay layer (full desktop, pointer-events only on children) */
#sticker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5; /* above background (z:1), below windows (z:10+) */
  overflow: visible;
}

/* ── Individual sticker ─────────────────────────────────────────── */
.sticker {
  position: absolute;
  pointer-events: all;
  cursor: grab;
  user-select: none;
  border-radius: 4px;
  transition: box-shadow 0.12s, transform 0.12s;
  min-width: 48px;
  max-width: 600px;
}

.sticker img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  pointer-events: none;
}

.sticker:hover {
  box-shadow: 0 0 0 2px var(--owner-color, #e060ff), 0 4px 16px rgba(0,0,0,0.6);
}

/* Resize handle — bottom-right corner, hidden until hover */
.sticker-resize {
  display: none;
  position: absolute;
  bottom: -7px;
  right: -7px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background: var(--owner-color, #c050f0);
  border-radius: 3px;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
  z-index: 3;
  transition: background 0.1s, transform 0.1s;
}

.sticker:hover .sticker-resize {
  display: block;
}

.sticker-resize:hover {
  background: #e060ff;
  transform: scale(1.2);
}

/* Delete button — hidden until hover */
.sticker-del {
  display: none;
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: #d0184c;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
  z-index: 2;
  transition: background 0.1s, transform 0.1s;
}

.sticker:hover .sticker-del {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticker-del:hover {
  background: #ff2060;
  transform: scale(1.15);
}

/* Rotate handle — bottom-left corner, hidden until hover */
.sticker-rotate {
  display: none;
  position: absolute;
  bottom: -14px;
  left: -14px;
  width: 22px;
  height: 22px;
  cursor: grab;
  background: none;
  border: none;
  box-shadow: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cg transform='rotate(-90 11 11)'%3E%3Cpath d='M16 4.5A8 8 0 0 0 5 15' stroke='rgba(0,0,0,0.5)' stroke-width='4' fill='none' stroke-linecap='round'/%3E%3Cpath d='M16 4.5A8 8 0 0 0 5 15' stroke='white' stroke-width='2.2' fill='none' stroke-linecap='round'/%3E%3Cpolygon points='3.5,18 8,16 5.5,12' fill='white'/%3E%3C/g%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 3;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
  transition: transform 0.1s, filter 0.1s;
}

.sticker:hover .sticker-rotate {
  display: block;
}

.sticker-rotate:hover {
  transform: scale(1.25);
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.9)) drop-shadow(0 0 4px var(--owner-color, #2080e0));
}

.sticker-rotate:active {
  cursor: grabbing;
}

/* Locked state — sticker is being moved by another user */
.sticker--locked {
  opacity: 0.55;
  pointer-events: none;
  outline: 2px dashed var(--owner-color, #ff8040);
  outline-offset: 2px;
}

/* Dragging state */
.sticker--drag {
  cursor: grabbing !important;
  opacity: 0.88;
  scale: 1.04;
  box-shadow: 0 0 0 2px var(--owner-color, #e060ff), 0 8px 28px rgba(0,0,0,0.65);
}

/* ── GIF picker popup ───────────────────────────────────────────── */
.gif-picker {
  /* hidden by default — JS adds .is-open to show */
  display: none;
  position: fixed;
  z-index: 99999;
  width: 520px;
  background: #1a0a2e;
  border: 2px solid #5a28a0;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.06);
  flex-direction: column;
  overflow: hidden;
  font-family: Tahoma, Verdana, sans-serif;
}

.gif-picker.is-open {
  display: flex;
}

.gif-picker-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: #230b3a;
  border-top: 1px solid #3d1870;
  flex-shrink: 0;
}

.gif-picker-footer-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gif-picker-title {
  font-size: 13px;
  font-weight: bold;
  color: #c080ff;
  white-space: nowrap;
  flex-shrink: 0;
}

.gif-picker-search {
  flex: 1;
  min-width: 0;
  background: #110720;
  border: 1px solid #5a28a0;
  border-radius: 4px;
  color: #e8d8ff;
  font-size: 13px;
  padding: 5px 9px 5px 28px;
  outline: none;
  font-family: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236a4090' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 7px center;
}

.gif-picker-search:focus {
  border-color: #b060ff;
  box-shadow: 0 0 0 2px rgba(176,96,255,0.25);
}

.gif-picker-search::placeholder {
  color: #6a4090;
}

.gif-picker-grid {
  flex: 1 1 auto;
  min-height: 180px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  gap: 4px;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: #5a28a0 #110720;
}

.gif-picker-grid::-webkit-scrollbar { width: 6px; }
.gif-picker-grid::-webkit-scrollbar-track { background: #110720; }
.gif-picker-grid::-webkit-scrollbar-thumb { background: #5a28a0; border-radius: 3px; }

.gif-picker-item {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  background: #110720;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.1s, transform 0.1s;
  overflow: hidden;
}

.gif-picker-item:hover {
  border-color: #b060ff;
  transform: scale(1.06);
  z-index: 1;
}

.gif-picker-item img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 4px;
}

.gif-picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 8px;
  color: #6a4090;
  font-size: 13px;
  font-style: italic;
}

.gif-picker-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 8px;
  color: #8040c0;
  font-size: 13px;
}

/* Section label */
.gif-picker-section {
  grid-column: 1 / -1;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #5a28a0;
  padding: 4px 2px 0;
  border-top: 1px solid #2a0a4a;
  margin-top: 2px;
}

  border-top: none;
  margin-top: 0;
}

/* Tabs row */
.gif-picker-tabs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.gif-tab {
  background: transparent;
  border: 1px solid #5a28a0;
  border-radius: 4px;
  color: #8050b8;
  font-size: 11px;
  font-weight: bold;
  font-family: inherit;
  padding: 3px 9px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  white-space: nowrap;
}

.gif-tab:hover {
  background: #3d1870;
  border-color: #b060ff;
  color: #d090ff;
}

.gif-tab.is-active {
  background: #5a28a0;
  border-color: #b060ff;
  color: #fff;
}

/* Upload label button */
.gif-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  background: #230b3a;
  border: 1px solid #5a28a0;
  border-radius: 4px;
  color: #b060ff;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  line-height: 1;
}

.gif-upload-label:hover {
  background: #3d1870;
  border-color: #b060ff;
}

.gif-upload-input {
  display: none;
}

/* Load-more button */
.gif-load-more span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: bold;
  color: #5a28a0;
  transition: color 0.1s;
}

.gif-load-more:hover span {
  color: #e060ff;
}

.gif-load-more--loading span {
  font-size: 14px;
  color: #5a28a0;
  animation: gif-spin 1s linear infinite;
}

@keyframes gif-spin {
  to { transform: rotate(360deg); }
}

/* Provider toggle (Klipy / Giphy) */
.gif-provider-toggle {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.gif-provider-btn {
  background: transparent;
  border: 1px solid #5a28a0;
  border-radius: 4px;
  color: #8050b8;
  font-size: 11px;
  font-weight: bold;
  font-family: inherit;
  padding: 3px 8px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  white-space: nowrap;
}

.gif-provider-btn:hover {
  background: #3d1870;
  border-color: #b060ff;
  color: #d090ff;
}

.gif-provider-btn.is-active {
  background: #5a28a0;
  border-color: #b060ff;
  color: #fff;
}
