/* pickers.css: emoji picker, GIF picker and the combined tabbed picker
   Flattened from the Blazor scoped CSS at commit 7af3454 (parent of 2c1b6c0 "Step 1: remove Blazor").
   Selectors and declarations are copied as they were; only ::deep was removed and a root
   class was put in front of selectors whose class names collided between components.
   See README.md in this folder for the prefixes and the dropped rules. */

/* ==== CombinedPicker (was Yap/Components/CombinedPicker.razor.css) ==== */

.combined-picker {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 50vh;
    max-height: 400px;
    background: var(--bg-sidebar);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
    overflow: hidden;
}

.combined-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 8px 6px;
    background: var(--bg-header);
    flex-shrink: 0;
    border-bottom: 1px solid var(--bg-input);
}

.combined-tab {
    background: transparent;
    border: none;
    padding: 8px 14px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: background-color 0.15s, color 0.15s;
}

.combined-tab:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

/* Active tab rides on the root's data-active-tab, flipped client-side (chat.js). */
.combined-picker[data-active-tab="gifs"] .combined-tab[data-combined-tab="gifs"],
.combined-picker[data-active-tab="emoji"] .combined-tab[data-combined-tab="emoji"] {
    color: var(--text-primary);
    background: var(--bg-input);
}

.combined-body {
    flex: 1;
    min-height: 0;
    position: relative;
}

/* Stack panes so inactive ones keep state (search query, scroll position).
   Only the active one is visible. */
.combined-pane {
    position: absolute;
    inset: 0;
    display: none;
}

.combined-picker[data-active-tab="gifs"] .combined-pane[data-combined-pane="gifs"],
.combined-picker[data-active-tab="emoji"] .combined-pane[data-combined-pane="emoji"] {
    display: block;
}

/* The wrapped pickers have their own fixed widths/heights and shadows — strip them
   so they fill our pane cleanly. !important because the inner picker's own scoped
   rule has identical specificity (0,2,0) and could win on source-order ties. */
.combined-pane .emoji-picker,
.combined-pane .gif-picker {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* ==== EmojiPicker (was Yap/Components/EmojiPicker.razor.css) ==== */

.emoji-picker {
    display: flex;
    flex-direction: row;
    width: 460px;
    height: min(450px, calc(100vh - 130px));
    background: var(--bg-sidebar);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
    overflow: hidden;
    z-index: 1000;
}

/* Left sidebar with category icons */
.emoji-sidebar {
    display: flex;
    flex-direction: column;
    width: 40px;
    padding: 6px 4px;
    gap: 2px;
    background: var(--bg-header);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
}

.emoji-sidebar::-webkit-scrollbar {
    display: none;
}

.emoji-picker .category-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.5;
    transition: opacity 0.15s, background-color 0.15s;
}

.emoji-picker .category-btn:hover {
    opacity: 1;
    background: var(--bg-input);
}

.emoji-picker .category-btn.active {
    opacity: 1;
    background: var(--bg-input);
}

/* Right scrollable content area */
.emoji-content {
    flex: 1;
    overflow-y: auto;
    min-width: 0;
}

/* Search input */
.emoji-search {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 8px 4px;
    background: var(--bg-sidebar);
    display: flex;
    align-items: center;
    gap: 4px;
}

.emoji-search input {
    flex: 1;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    box-sizing: border-box;
    min-width: 0;
}

.emoji-search input::placeholder {
    color: var(--text-placeholder);
}

.emoji-search-clear {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
}

.emoji-search-clear:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

/* The ✕ appears only while a query exists — value-driven via :placeholder-shown, same
   pattern as the send button. Requires a non-empty placeholder on the input. */
.emoji-search input:placeholder-shown ~ .emoji-search-clear {
    display: none;
}

/* The search filter (ui/emoji-picker.js): non-matching cells and emptied sections hide
   through attributes the script sets; a reopen clears them. */
.emoji-btn[data-search-miss],
.emoji-section[data-search-empty] {
    display: none;
}

.emoji-content::-webkit-scrollbar {
    width: 8px;
}

.emoji-content::-webkit-scrollbar-track {
    background: transparent;
}

.emoji-content::-webkit-scrollbar-thumb {
    background: var(--bg-header);
    border-radius: 4px;
}

/* Each category section */
.emoji-section {
    /* Skip layout/paint for offscreen sections — with ~1000 cells mounted (hidden)
       this is what keeps the grid cheap. The intrinsic-size estimate only affects
       scrollbar accuracy until a section first renders. */
    content-visibility: auto;
    contain-intrinsic-size: auto 320px;
}

/* Sticky category header */
.emoji-picker .section-header {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 6px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-sidebar);
    letter-spacing: 0.02em;
}

/* Emoji grid within each section */
.emoji-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px 6px 8px;
    align-content: flex-start;
}

.emoji-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.emoji-btn:hover {
    background: var(--bg-input);
    transform: scale(1.1);
}

/* Override inline 18px from forceSmall */
.emoji-btn .emoji {
    width: 40px !important;
    height: 40px !important;
}

.emoji-empty {
    width: 100%;
    text-align: center;
    color: var(--text-placeholder);
    padding: 2rem;
    font-size: 0.875rem;
}

/* Mobile adjustments - match parent's 600px breakpoint */
@media (max-width: 600px) {
    .emoji-sidebar {
        width: 36px;
    }

    .emoji-picker .category-btn {
        width: 28px;
        height: 28px;
    }

    .emoji-btn {
        width: 36px;
        height: 36px;
    }

    .emoji-btn .emoji {
        width: 28px !important;
        height: 28px !important;
    }
}

/* ==== GifPicker (was Yap/Components/GifPicker.razor.css) ==== */

.gif-picker {
    display: flex;
    flex-direction: row;
    width: 500px;
    height: min(460px, calc(100vh - 130px));
    background: var(--bg-sidebar);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
    overflow: hidden;
    z-index: 1000;
}

.gif-sidebar {
    display: flex;
    flex-direction: column;
    width: 40px;
    padding: 6px 4px;
    gap: 2px;
    background: var(--bg-header);
    flex-shrink: 0;
}

.gif-picker .category-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s, background-color 0.15s;
}

.gif-picker .category-btn:hover {
    opacity: 1;
    background: var(--bg-input);
}

.gif-picker .category-btn.active {
    opacity: 1;
    background: var(--bg-input);
    color: var(--text-primary);
}

.gif-picker .category-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.gif-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.gif-search {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px;
    background: var(--bg-sidebar);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.gif-search input {
    flex: 1;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    box-sizing: border-box;
    min-width: 0;
}

.gif-search input::placeholder {
    color: var(--text-placeholder);
}

.gif-search-clear,
.gif-upload-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
}

.gif-search-clear:hover,
.gif-upload-btn:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.gif-upload-btn.is-busy {
    pointer-events: none;
    cursor: default;
}

.gif-spinner {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    border: 2px solid var(--bg-input);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: gif-spin 0.7s linear infinite;
}

@keyframes gif-spin {
    to { transform: rotate(360deg); }
}

/* Busy overlay shown while a custom GIF/WebP is uploading & processing.
   Sits below the sticky search bar (z-index 2), so the "+" → spinner swap stays visible. */
.gif-upload-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(1px);
}

.gif-upload-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: gif-spin 0.7s linear infinite;
}

.gif-upload-overlay-text {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.gif-results {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 8px;
}

.gif-results::-webkit-scrollbar {
    width: 8px;
}

.gif-results::-webkit-scrollbar-track {
    background: transparent;
}

.gif-results::-webkit-scrollbar-thumb {
    background: var(--bg-header);
    border-radius: 4px;
}

.gif-section-header {
    padding: 8px 0 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

/* CSS masonry — natural packing without JS */
.gif-grid {
    column-count: 2;
    column-gap: 6px;
}

.gif-card {
    break-inside: avoid;
    position: relative;
    margin-bottom: 6px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-input);
    cursor: pointer;
    display: block;
    width: 100%;
}

.gif-card video,
.gif-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--bg-input);
}

.gif-fav-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: white;
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.15s, background-color 0.15s;
    padding: 0;
}

.gif-card:hover .gif-fav-btn {
    opacity: 1;
}

.gif-fav-btn.favorited {
    opacity: 1;
    color: #ffc107;
}

.gif-fav-btn:hover {
    background: rgba(0, 0, 0, 0.75);
}

.gif-empty {
    text-align: center;
    color: var(--text-placeholder);
    padding: 2rem 1rem;
    font-size: 0.875rem;
}

/* Folder / shortcut tiles (Favorites, Server, Browse): Discord-style — a random member GIF
   animating under a blur, with the name on top. */
.gif-tile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.gif-folder-tile {
    position: relative;
    aspect-ratio: 2 / 1;
    border: none;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
    background: var(--bg-input);
    cursor: pointer;
}

.gif-folder-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* the scale-up hides the blur's translucent fringe at the tile edges */
    transform: scale(1.15);
    filter: blur(4px) brightness(0.55);
}

.gif-folder-tile span {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0 10px;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

.gif-folder-tile:hover img {
    filter: blur(4px) brightness(0.7);
}

/* Back row shown while inside a folder */
.gif-folder-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 2px 2px 8px 2px;
    max-width: 100%;
}

.gif-folder-back span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gif-folder-back:hover {
    color: var(--accent-primary);
}

/* Footer link at the bottom of the Favorites tab */
.gif-manage-link {
    display: block;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 10px 0 4px;
    text-decoration: none;
}

.gif-manage-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.gif-attribution {
    flex-shrink: 0;
    padding: 6px 8px;
    text-align: right;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--bg-input);
}

.gif-attribution img {
    height: 16px;
    opacity: 0.6;
    vertical-align: middle;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .gif-picker {
        width: calc(100vw - 16px);
    }

    .gif-sidebar {
        width: 36px;
    }

    .gif-picker .category-btn {
        width: 28px;
        height: 28px;
    }
}
