
/* =====================================================
   CHICKY GALLERY — CHAT STICKERS
===================================================== */

.chat-input-area {
    position: relative;
}

.message-form {
    position: relative;
}

/* =====================================================
   BOTÓN DE STICKERS
===================================================== */

.chat-sticker-trigger {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 7px;
    margin: 0 5px 0 0;

    border: none;
    border-radius: 12px;

    background: transparent;
    color: var(--chat-text, #444);

    cursor: pointer;
    overflow: hidden;

    transition:
        background .2s ease,
        transform .2s ease;
}

.chat-sticker-trigger:hover {
    background: rgba(128, 128, 128, .14);
    transform: scale(1.04);
}

.chat-sticker-trigger:focus-visible {
    outline: 2px solid var(--chat-primary, #3984d6);
    outline-offset: 2px;
}

.chat-sticker-trigger-icon {
    display: block;

    width: 25px;
    height: 25px;

    max-width: 25px;
    max-height: 25px;

    object-fit: contain;
    object-position: center;

    flex: 0 0 25px;
    pointer-events: none;
}

/* =====================================================
   PANEL
===================================================== */

.chat-sticker-panel {
    position: absolute;

    z-index: 1000;

    left: 0;
    bottom: calc(100% + 12px);

    width: min(340px, calc(100vw - 32px));
    max-height: 390px;

    display: flex;
    flex-direction: column;
    gap: 12px;

    padding: 15px;

    overflow: hidden;

    background: var(--chat-panel-bg, #ffffff);
    color: var(--chat-text, #252525);

    border: 1px solid var(--chat-border, #e5e5e5);
    border-radius: 18px;

    box-shadow: 0 12px 35px rgba(0, 0, 0, .16);

    animation: sticker-panel-in .18s ease;
}

.chat-sticker-panel.oculto {
    display: none !important;
}

@keyframes sticker-panel-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   CABECERA
===================================================== */

.chat-sticker-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chat-sticker-panel-header strong {
    font-size: 15px;
    font-weight: 700;
}

.chat-sticker-count {
    font-size: 11px;
    color: var(--chat-muted, #888);
}

/* =====================================================
   BUSCADOR
===================================================== */

.chat-sticker-search {
    width: 100%;
    min-height: 38px;

    display: flex;
    align-items: center;
    gap: 9px;

    padding: 0 11px;

    background: var(--chat-input-bg, #f3f4f6);

    border: 1px solid var(--chat-border, #e5e5e5);
    border-radius: 10px;
}

.chat-sticker-search i {
    font-size: 14px;
    color: var(--chat-muted, #888);
}

.chat-sticker-search input {
    width: 100%;
    min-width: 0;
    height: 36px;

    padding: 0;

    background: transparent;
    border: none;
    outline: none;

    color: inherit;
    font-size: 13px;
}

/* =====================================================
   CUADRÍCULA
===================================================== */

.chat-sticker-grid {
    display: grid;

    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 9px;

    min-height: 0;
    max-height: 265px;

    overflow-y: auto;
    overscroll-behavior: contain;

    padding: 2px 3px 5px 2px;
}

.chat-sticker-option {
    min-width: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 5px;

    padding: 8px 5px;

    background: var(--chat-input-bg, #f7f7f7);

    border: 1px solid transparent;
    border-radius: 12px;

    cursor: pointer;

    transition:
        background .2s ease,
        border-color .2s ease,
        transform .2s ease;
}

.chat-sticker-option:hover {
    background: rgba(128, 128, 128, .12);
    border-color: var(--chat-primary, #3984d6);
    transform: translateY(-2px);
}

.chat-sticker-option:focus-visible {
    outline: 2px solid var(--chat-primary, #3984d6);
    outline-offset: 2px;
}

.chat-sticker-option[hidden] {
    display: none !important;
}

/* =====================================================
   MINIATURAS
===================================================== */

.chat-sticker-thumb {
    width: 76px;
    height: 76px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;
}

.chat-sticker-thumb img {
    display: block;

    width: 100%;
    height: 100%;

    max-width: 76px;
    max-height: 76px;

    object-fit: contain;
    object-position: center;

    pointer-events: none;
}

.chat-sticker-name {
    max-width: 100%;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 10px;
    font-weight: 600;

    color: var(--chat-text, #555);
}

/* =====================================================
   ESTADO VACÍO
===================================================== */

.chat-sticker-empty {
    grid-column: 1 / -1;

    margin: 0;
    padding: 20px 10px;

    text-align: center;

    font-size: 12px;
    color: var(--chat-muted, #888);
}

/* =====================================================
   STICKERS EN MENSAJES
===================================================== */

.sticker-message {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.chat-sticker-image {
    display: block;

    width: 150px;
    height: 150px;
    max-width: 100%;

    object-fit: contain;
    object-position: center;

    /* Pixel art: escala sin difuminar */
    image-rendering: pixelated;

    border: none;
    border-radius: 0;

    background: transparent;
    box-shadow: none;
}

@media (max-width: 768px) {
    .chat-sticker-image {
        width: 120px;
        height: 120px;
    }
}

.chat-sticker-image--grande {
    width: 1000px;
    height: 1000px;
}

@media (max-width: 768px) {
    .chat-sticker-image--grande {
        width: 700px;
        height: 700px;
    }
}

/* =====================================================
   MODO OSCURO
===================================================== */

[data-theme="dark"] .chat-sticker-panel,
.dark-mode .chat-sticker-panel {
    --chat-panel-bg: #202127;
    --chat-text: #f1f1f1;
    --chat-muted: #a0a0a0;
    --chat-border: #383942;
    --chat-input-bg: #2b2d35;
}

[data-theme="dark"] .chat-sticker-option,
.dark-mode .chat-sticker-option {
    background: #2b2d35;
}

[data-theme="dark"] .chat-sticker-option:hover,
.dark-mode .chat-sticker-option:hover {
    background: #383b46;
}

/* =====================================================
   MÓVIL
===================================================== */

@media (max-width: 768px) {
    .chat-sticker-panel {
        position: fixed;

        left: 12px;
        right: 12px;
        bottom: calc(85px + env(safe-area-inset-bottom));

        width: auto;
        max-width: none;

        max-height: min(390px, 55dvh);

        border-radius: 18px;
    }

    .chat-sticker-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        max-height: min(265px, 38dvh);
    }

    .chat-sticker-thumb {
        width: 68px;
        height: 68px;
    }

    .chat-sticker-thumb img {
        max-width: 68px;
        max-height: 68px;
    }

    .chat-sticker-trigger {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .chat-sticker-trigger-icon {
        width: 24px;
        height: 24px;
        max-width: 24px;
        max-height: 24px;
    }
}
