/* ==========================================================================
   WorkSpace Emoji Picker
   Uses theme tokens (--bg-primary, --bg-secondary, --text-primary,
   --text-secondary, --border, --ws-primary). Falls back to sensible
   defaults if a token is missing.
   ========================================================================== */

.ws-emoji-picker {
    position: fixed;
    z-index: 10000;
    width: 360px;
    max-height: 440px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #1c1e21);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    font-family: inherit;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* Head — search + tone + close */
.ws-emoji-picker__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}

.ws-emoji-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--bg-secondary, #f0f2f5);
    border-radius: 999px;
    color: var(--text-secondary, #65676b);
    cursor: text;
}
.ws-emoji-search input {
    flex: 1;
    border: 0;
    background: transparent;
    outline: 0;
    font: inherit;
    font-size: 14px;
    color: var(--text-primary, #1c1e21);
    min-width: 0;
}
.ws-emoji-search input::placeholder { color: var(--text-secondary, #8a8d91); }

.ws-emoji-tone-btn,
.ws-emoji-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary, #1c1e21);
    font-size: 20px;
    line-height: 1;
    transition: background 0.12s ease;
}
.ws-emoji-tone-btn:hover,
.ws-emoji-close:hover { background: var(--bg-secondary, #f0f2f5); }
.ws-emoji-tone-glyph { display: inline-block; line-height: 1; }

/* Tone picker dropdown */
.ws-emoji-tone-menu {
    position: absolute;
    top: 50px;
    right: 50px;
    z-index: 10;
    display: flex;
    gap: 2px;
    padding: 4px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
/* The [hidden] attribute sets display:none by default, but our display:flex
   above overrides it. Re-assert it with matching specificity. */
.ws-emoji-tone-menu[hidden] {
    display: none;
}
.ws-emoji-tone-opt {
    width: 32px;
    height: 32px;
    border: 0;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.ws-emoji-tone-opt:hover { background: var(--bg-secondary, #f0f2f5); }
.ws-emoji-tone-opt.is-active {
    background: var(--bg-secondary, #f0f2f5);
    box-shadow: inset 0 0 0 2px var(--ws-primary, #1877f2);
}

/* Tabs */
.ws-emoji-tabs {
    display: flex;
    align-items: center;
    background: var(--bg-secondary, #f7f8fa);
    border-bottom: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}
.ws-emoji-tab {
    flex: 1;
    height: 40px;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    border-bottom: 2px solid transparent;
    transition: background 0.1s ease, border-color 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ws-emoji-tab img {
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.ws-emoji-tab:hover { background: rgba(0, 0, 0, 0.04); }
.ws-emoji-tab.is-active { border-bottom-color: var(--ws-primary, #1877f2); }

/* Body — scrollable section list */
.ws-emoji-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 12px 14px;
    scroll-behavior: smooth;
}
.ws-emoji-body::-webkit-scrollbar { width: 8px; }
.ws-emoji-body::-webkit-scrollbar-thumb {
    background: var(--border, #cfd2d7);
    border-radius: 4px;
}

.ws-emoji-section {
    margin: 8px 4px 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #65676b);
    letter-spacing: 0.01em;
}

.ws-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}
.ws-emoji-item {
    aspect-ratio: 1 / 1;
    border: 0;
    background: transparent;
    width: 39px;
    height: 39px;
    /* More padding so face emojis (which draw to the SVG edge) look the same
       size as object emojis (which have built-in internal whitespace). */
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s ease, transform 0.05s ease;
}
.ws-emoji-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}
.ws-emoji-glyph {
    font-size: 22px;
    line-height: 1;
    pointer-events: none;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", emoji, sans-serif;
}
.ws-emoji-item:hover { background: var(--bg-secondary, #f0f2f5); }
.ws-emoji-item:active { transform: scale(0.92); }

.ws-emoji-empty {
    text-align: center;
    padding: 28px 16px;
    color: var(--text-secondary, #65676b);
    font-size: 14px;
}

/* Inline emoji rendered inside content */
.ws-emoji {
    width: 1.2em;
    height: 1.2em;
    vertical-align: -0.22em;
    display: inline-block;
}
.js-emoji-toggle{
    font-size: 28px;
}

/* Dark mode */
[data-theme="dark"] .ws-emoji-picker {
    background: var(--bg-primary, #242526);
    color: var(--text-primary, #e4e6eb);
    border-color: var(--border, #3a3b3c);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .ws-emoji-search,
[data-theme="dark"] .ws-emoji-tabs {
    background: var(--bg-secondary, #3a3b3c);
}
[data-theme="dark"] .ws-emoji-tone-btn:hover,
[data-theme="dark"] .ws-emoji-close:hover,
[data-theme="dark"] .ws-emoji-tab:hover,
[data-theme="dark"] .ws-emoji-item:hover,
[data-theme="dark"] .ws-emoji-tone-opt:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Mobile — make it full-width above the keyboard */
@media (max-width: 480px) {
    .ws-emoji-picker {
        width: calc(100vw - 16px) !important;
        max-width: 360px;
        max-height: 60vh;
    }
}
