/* ============================================================
   CVGURU — Emoji Picker
   ============================================================
   THEME-SAFE: ei defineeri ega kirjuta üle :root muutujaid.
   Kõik var() kutsungid omavad fallback väärtust.
   ============================================================ */

/* Floating picker popup */
.cvguru-emoji-picker {
  position: fixed;  /* ★ fixed, mitte absolute — et getBoundingClientRect-i koordinaadid (viewport-ist) oleks õiged */
  z-index: 10001;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--card-bg, #0a0f1c);
  border: 1px solid var(--border, rgba(0, 212, 255, 0.16));
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(0, 212, 255, 0.08);
  overflow: hidden;
  display: none;
  flex-direction: column;
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}
.cvguru-emoji-picker.open {
  display: flex;
  animation: emojiFadeIn 160ms ease;
}
@keyframes emojiFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Search row */
.cvguru-emoji-picker-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, rgba(0, 212, 255, 0.16));
  background: var(--bg, #04060c);
}
.cvguru-emoji-picker-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main, #e6edf6);
  font-size: 14px;
  font-family: inherit;
  min-width: 0;
}
.cvguru-emoji-picker-search input::placeholder {
  color: var(--text-muted, #7a8aa6);
}
.cvguru-emoji-picker-search-close {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted, #7a8aa6);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease;
  flex-shrink: 0;
}
.cvguru-emoji-picker-search-close:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-main, #e6edf6);
}

/* Category tabs */
.cvguru-emoji-picker-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border, rgba(0, 212, 255, 0.16));
  background: var(--bg, #04060c);
  scrollbar-width: none;
}
.cvguru-emoji-picker-tabs::-webkit-scrollbar { display: none; }
.cvguru-emoji-picker-tab {
  flex-shrink: 0;
  padding: 10px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted, #7a8aa6);
  opacity: 0.6;
  transition: opacity 160ms ease, background 160ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
}
.cvguru-emoji-picker-tab:hover {
  opacity: 1;
  background: rgba(255,255,255,0.04);
}
.cvguru-emoji-picker-tab.active {
  opacity: 1;
  background: rgba(0, 212, 255, 0.08);
  box-shadow: inset 0 -2px 0 var(--primary, #00d4ff);
}

/* Emoji grid */
.cvguru-emoji-picker-grid {
  height: 260px;
  overflow-y: auto;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary, #00d4ff) transparent;
}
.cvguru-emoji-picker-grid::-webkit-scrollbar { width: 6px; }
.cvguru-emoji-picker-grid::-webkit-scrollbar-track { background: transparent; }
.cvguru-emoji-picker-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 255, 0.3);
  border-radius: 3px;
}

.cvguru-emoji-item {
  width: 100%;
  aspect-ratio: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 100ms ease, transform 100ms ease;
  padding: 0;
}
.cvguru-emoji-item:hover {
  background: rgba(0, 212, 255, 0.12);
  transform: scale(1.15);
}
.cvguru-emoji-item:active {
  transform: scale(0.9);
}

/* Recently used section (only shows if there are any) */
.cvguru-emoji-picker-recent {
  border-bottom: 1px solid var(--border, rgba(0, 212, 255, 0.16));
  padding: 8px 12px 10px;
  background: var(--bg, #04060c);
}
.cvguru-emoji-picker-recent-label {
  font-size: 11px;
  color: var(--text-muted, #7a8aa6);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 600;
}
.cvguru-emoji-picker-recent-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.cvguru-emoji-picker-recent-grid .cvguru-emoji-item {
  width: 32px;
  height: 32px;
  font-size: 20px;
  aspect-ratio: auto;
}

/* Empty state when search returns nothing */
.cvguru-emoji-picker-empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted, #7a8aa6);
  font-size: 13px;
}

/* Footer hint */
.cvguru-emoji-picker-foot {
  padding: 6px 12px;
  border-top: 1px solid var(--border, rgba(0, 212, 255, 0.16));
  background: var(--bg, #04060c);
  font-size: 11px;
  color: var(--text-muted, #7a8aa6);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cvguru-emoji-picker-foot .kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--border, rgba(0, 212, 255, 0.16));
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  color: var(--text-main, #e6edf6);
}

/* Backdrop — invisible layer that captures outside clicks to close */
.cvguru-emoji-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: transparent;
  display: none;
}
.cvguru-emoji-picker-backdrop.open {
  display: block;
}

/* ★ The trigger button — small 😊 that you put next to your textarea.
   This class is optional. You can use your own button and just call
   EmojiPicker.toggle(textareaEl, btnEl). */
.cvguru-emoji-trigger {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border, rgba(0, 212, 255, 0.16));
  background: var(--card-bg, #0a0f1c);
  color: var(--text-muted, #7a8aa6);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.cvguru-emoji-trigger:hover {
  color: var(--primary, #00d4ff);
  border-color: var(--primary, #00d4ff);
}
.cvguru-emoji-trigger.active {
  color: var(--primary, #00d4ff);
  border-color: var(--primary, #00d4ff);
  background: rgba(0, 212, 255, 0.08);
}

/* Mobile-friendly: picker takes full width on small screens */
@media (max-width: 480px) {
  .cvguru-emoji-picker {
    width: calc(100vw - 24px);
    max-width: 360px;
  }
  .cvguru-emoji-picker-grid {
    height: 220px;
    grid-template-columns: repeat(6, 1fr);
  }
}
