/* ============================================================
   sticker.css — Sticker Generator Drop-Up Bubble
   Uses the app's real theme variables from variables.css
   ============================================================ */

/* ── Drop-Up Container (positioned above the pinned button) ── */
.sticker-dropup {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--bg-surface-solid, #2C3E50);
    border: 1px solid var(--border-glass, rgba(255,255,255,0.08));
    border-radius: var(--radius-lg, 10px);
    width: 620px;
    max-width: 92vw;
    max-height: 82vh;
    display: none;
    flex-direction: column;
    box-shadow: var(--shadow-main, 0 10px 40px rgba(0,0,0,0.35));
    overflow: hidden;
    z-index: var(--z-dropdown, 1000);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    -webkit-tap-highlight-color: transparent;
}

.sticker-dropup.show {
    display: flex;
    opacity: 1;
    pointer-events: all;
    transform: translateX(-50%) translateY(0);
}

/* Arrow pointing down to the trigger button */
.sticker-dropup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 10px solid transparent;
    border-top-color: var(--bg-surface-solid, #2C3E50);
}

/* ── Header ────────────────────────────────────────────────── */
.sticker-dropup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.sticker-dropup-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main, #ECF0F1);
}

.sticker-dropup-title i {
    color: var(--primary, #F9CA24);
    font-size: 1.1rem;
}

.sticker-dropup-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-muted, #95A5A6);
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.sticker-dropup-close:hover {
    background: var(--bg-item, rgba(52,73,94,0.5));
    color: var(--text-main, #ECF0F1);
}

.sticker-dropup-close:active {
    transform: scale(0.9);
}

/* ── AI Notice ─────────────────────────────────────────────── */
.sticker-ai-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: color-mix(in srgb, #f59e0b 10%, transparent);
    border-bottom: 1px solid var(--border-glass);
    color: #f59e0b;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.3;
    flex-shrink: 0;
}

.sticker-ai-notice i {
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* ── Categories Strip ──────────────────────────────────────── */
.sticker-categories {
    display: flex;
    gap: 3px;
    padding: 6px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.sticker-categories::-webkit-scrollbar {
    display: none;
}

.sticker-cat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1.5px solid transparent;
    border-radius: var(--radius-md, 8px);
    background: var(--bg-item, rgba(52,73,94,0.5));
    color: var(--text-muted, #95A5A6);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.sticker-cat-btn:hover {
    background: var(--bg-item-hover, rgba(52,73,94,0.8));
    color: var(--text-main, #ECF0F1);
}

.sticker-cat-btn:active {
    transform: scale(0.95);
}

.sticker-cat-btn.active {
    border-color: var(--cat-color, #10b981);
    background: color-mix(in srgb, var(--cat-color, #10b981) 15%, var(--bg-item, rgba(52,73,94,0.5)));
    color: var(--cat-color, #10b981);
}

.sticker-cat-btn i {
    font-size: 0.9rem;
}

/* ── Content Area ──────────────────────────────────────────── */
.sticker-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Prompts Section ───────────────────────────────────────── */
.sticker-prompts-section {
    padding: 6px 14px 4px;
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.sticker-prompts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main, #ECF0F1);
}

/* ── Labels Toggle ─────────────────────────────────────────── */
.sticker-label-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.sticker-label-toggle input {
    display: none;
}

.sticker-toggle-track {
    position: relative;
    width: 34px;
    height: 18px;
    background: var(--bg-item, rgba(52,73,94,0.5));
    border-radius: 10px;
    border: 1px solid var(--border-glass);
    transition: all 0.25s;
    flex-shrink: 0;
}

.sticker-toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: var(--text-muted, #95A5A6);
    border-radius: 50%;
    transition: all 0.25s;
}

.sticker-label-toggle input:checked + .sticker-toggle-track {
    background: color-mix(in srgb, var(--primary, #F9CA24) 30%, transparent);
    border-color: var(--primary, #F9CA24);
}

.sticker-label-toggle input:checked + .sticker-toggle-track::after {
    left: 18px;
    background: var(--primary, #F9CA24);
}

.sticker-toggle-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted, #95A5A6);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sticker-custom-prompt {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}

.sticker-custom-prompt input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-strong, rgba(255,255,255,0.15));
    border-radius: var(--radius-md, 8px);
    font-size: 16px;
    font-family: 'Outfit', sans-serif;
    background: var(--bg-item, rgba(52,73,94,0.5));
    color: var(--text-main, #ECF0F1);
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.sticker-custom-prompt input:focus {
    border-color: var(--primary, #F9CA24);
}

.sticker-custom-prompt input::placeholder {
    color: var(--text-muted, #95A5A6);
}

.sticker-custom-gen-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-md, 8px);
    background: linear-gradient(135deg, var(--primary, #F9CA24), var(--primary-hover, #F39C12));
    color: var(--text-on-accent, #2C3E50);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.sticker-custom-gen-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(249, 202, 36, 0.4);
}

.sticker-custom-gen-btn:active {
    transform: scale(0.95);
}

.sticker-custom-gen-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    animation: stickerPulse 0.8s ease-in-out infinite;
}

.sticker-custom-gen-btn:not(:disabled) .fa-wand-sparkles {
    transition: transform 0.2s;
}

.sticker-custom-gen-btn:not(:disabled):hover .fa-wand-sparkles {
    animation: stickerShake 0.4s ease;
}

@keyframes stickerShake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* ── Prompts Grid ──────────────────────────────────────────── */
.sticker-prompts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 4px;
    max-height: 68px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.sticker-prompt-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 4px;
    border-radius: var(--radius-md, 8px);
    background: var(--bg-item, rgba(52,73,94,0.5));
    border: 1px solid var(--border-glass);
    transition: all 0.2s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.sticker-prompt-card:hover {
    border-color: var(--primary, #F9CA24);
    background: var(--bg-item-hover, rgba(52,73,94,0.8));
}

.sticker-prompt-card:active {
    transform: scale(0.97);
}

.sticker-prompt-card.loading {
    opacity: 0.6;
    pointer-events: none;
    animation: stickerPulse 0.8s ease-in-out infinite;
}

.sticker-prompt-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #95A5A6);
    font-size: 1rem;
    flex-shrink: 0;
    cursor: pointer;
    pointer-events: none;
}

@keyframes stickerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ── Gallery Section ───────────────────────────────────────── */
.sticker-gallery-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 6px 14px 10px;
    min-height: 0;
}

.sticker-gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main, #ECF0F1);
    flex-shrink: 0;
}

.sticker-gallery-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sticker-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted, #95A5A6);
    background: var(--bg-item, rgba(52,73,94,0.5));
    padding: 2px 8px;
    border-radius: 10px;
}

.sticker-expand-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm, 4px);
    background: var(--bg-item, rgba(52,73,94,0.5));
    color: var(--text-muted, #95A5A6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.sticker-expand-btn:hover {
    background: var(--bg-item-hover, rgba(52,73,94,0.8));
    color: var(--text-main, #ECF0F1);
}

.sticker-expand-btn:active {
    transform: scale(0.9);
}

.sticker-clear-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm, 4px);
    background: var(--bg-item, rgba(52,73,94,0.5));
    color: var(--danger, #E74C3C);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.sticker-clear-btn:hover {
    background: color-mix(in srgb, var(--danger, #E74C3C) 15%, transparent);
}

.sticker-clear-btn:active {
    transform: scale(0.9);
}

/* ── Search Box ────────────────────────────────────────────── */
.sticker-search-box {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    margin-bottom: 4px;
    border: 1px solid var(--border-strong, rgba(255,255,255,0.15));
    border-radius: var(--radius-md, 8px);
    background: var(--bg-item, rgba(52,73,94,0.5));
    transition: border-color 0.2s;
    flex-shrink: 0;
}

.sticker-search-box:focus-within {
    border-color: var(--primary, #F9CA24);
}

.sticker-search-box i {
    color: var(--text-muted, #95A5A6);
    font-size: 0.78rem;
}

.sticker-search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: none;
    font-size: 16px;
    font-family: 'Outfit', sans-serif;
    color: var(--text-main, #ECF0F1);
}

.sticker-search-box input::placeholder {
    color: var(--text-muted, #95A5A6);
}

/* ── Gallery Grid ──────────────────────────────────────────── */
.sticker-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    grid-auto-rows: min-content;
    gap: 5px;
    overflow-y: auto;
    flex: 1;
    align-content: start;
    padding: 2px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* ── Gallery Card ──────────────────────────────────────────── */
.sticker-gallery-item {
    background: var(--bg-item, rgba(52,73,94,0.5));
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-glass);
    transition: all 0.2s;
    animation: stickerItemIn 0.4s ease;
    display: flex;
    flex-direction: column;
}

.sticker-gallery-item:hover {
    border-color: var(--primary, #F9CA24);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

@keyframes stickerItemIn {
    from { opacity: 0; transform: scale(0.85) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Image wrapper — fixed height, always visible */
.sticker-gallery-item-img {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0;
    overflow: hidden;
    flex-shrink: 0;
}

.sticker-gallery-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Sticker name — always visible */
.sticker-item-name {
    padding: 6px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-main, #ECF0F1);
    text-align: center;
    border-top: 1px solid var(--border-glass);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    line-height: 1.3;
}

/* Action buttons — always visible */
.sticker-item-actions {
    display: flex;
    border-top: 1px solid var(--border-glass);
    flex-shrink: 0;
    min-height: 32px;
}

.sticker-action-btn {
    flex: 1;
    padding: 6px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted, #95A5A6);
    min-height: 32px;
    -webkit-tap-highlight-color: transparent;
}

.sticker-action-btn:active {
    transform: scale(0.9);
    opacity: 0.8;
}

.sticker-action-btn.download {
    border-right: 1px solid var(--border-glass);
    color: #3b82f6;
}

.sticker-action-btn.download:hover {
    background: color-mix(in srgb, #3b82f6 12%, transparent);
}

.sticker-action-btn.insert {
    color: #10b981;
}

.sticker-action-btn.insert:hover {
    background: color-mix(in srgb, #10b981 12%, transparent);
}

.sticker-action-btn.delete {
    color: var(--danger, #E74C3C);
    border-left: 1px solid var(--border-glass);
}

.sticker-action-btn.delete:hover {
    background: color-mix(in srgb, var(--danger, #E74C3C) 12%, transparent);
}

/* ── Empty State ───────────────────────────────────────────── */
.sticker-empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 16px;
    color: var(--text-muted, #95A5A6);
}

.sticker-empty-state i {
    font-size: 2.2rem;
    margin-bottom: 8px;
    opacity: 0.4;
}

.sticker-empty-state p {
    font-size: 0.78rem;
    color: var(--text-muted, #95A5A6);
}

/* ============================================================
   Expand Overlay (full-screen modal for browsing all stickers)
   ============================================================ */

.sticker-expand-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal, 200000);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    -webkit-tap-highlight-color: transparent;
}

.sticker-expand-overlay.show {
    display: flex;
}

.sticker-expand-modal {
    background: var(--bg-surface-solid, #2C3E50);
    border: 1px solid var(--border-glass, rgba(255,255,255,0.08));
    border-radius: var(--radius-lg, 10px);
    width: 800px;
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-main, 0 10px 40px rgba(0,0,0,0.35));
    overflow: hidden;
    animation: expandIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes expandIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.sticker-expand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main, #ECF0F1);
}

.sticker-expand-header i {
    color: var(--primary, #F9CA24);
    margin-right: 8px;
}

.sticker-expand-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted, #95A5A6);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.sticker-expand-close:hover {
    background: var(--bg-item, rgba(52,73,94,0.5));
    color: var(--text-main, #ECF0F1);
}

.sticker-expand-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-item, rgba(52,73,94,0.3));
    flex-shrink: 0;
}

.sticker-expand-search i {
    color: var(--text-muted, #95A5A6);
    font-size: 0.85rem;
}

.sticker-expand-search input {
    flex: 1;
    border: none;
    outline: none;
    background: none;
    font-size: 16px;
    font-family: 'Outfit', sans-serif;
    color: var(--text-main, #ECF0F1);
}

.sticker-expand-search input::placeholder {
    color: var(--text-muted, #95A5A6);
}

.sticker-expand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    align-content: start;
    -webkit-overflow-scrolling: touch;
}

.sticker-expand-item {
    background: var(--bg-item, rgba(52,73,94,0.5));
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-glass);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    animation: stickerItemIn 0.4s ease;
}

.sticker-expand-item:hover {
    border-color: var(--primary, #F9CA24);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.sticker-expand-item-img {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0;
    overflow: hidden;
    flex-shrink: 0;
}

.sticker-expand-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sticker-expand-item-name {
    padding: 8px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-main, #ECF0F1);
    text-align: center;
    border-top: 1px solid var(--border-glass);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.sticker-expand-item-actions {
    display: flex;
    border-top: 1px solid var(--border-glass);
    flex-shrink: 0;
    min-height: 36px;
}

.sticker-expand-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted, #95A5A6);
}

.sticker-expand-empty i {
    font-size: 3.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.sticker-expand-empty p {
    font-size: 0.9rem;
    color: var(--text-muted, #95A5A6);
}

/* ============================================================
   Touch Device Optimizations
   ============================================================ */

body.touch-device .sticker-dropup-close {
    min-width: 40px;
    min-height: 40px;
}

body.touch-device .sticker-cat-btn {
    padding: 7px 12px;
    min-height: 40px;
}

body.touch-device .sticker-prompt-card {
    padding: 8px;
    min-height: 42px;
}

body.touch-device .sticker-custom-gen-btn {
    min-width: 40px;
    min-height: 40px;
}

body.touch-device .sticker-action-btn {
    min-height: 38px;
    padding: 8px 6px;
}

body.touch-device .sticker-expand-btn {
    min-width: 34px;
    min-height: 34px;
}

body.touch-device .sticker-clear-btn {
    min-width: 34px;
    min-height: 34px;
}

body.touch-device .sticker-expand-close {
    min-width: 42px;
    min-height: 42px;
}

body.touch-device .sticker-expand-grid {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

body.touch-device .sticker-gallery-grid {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

body.touch-device .sticker-prompts-grid {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

body.touch-device .sticker-categories {
    touch-action: pan-x;
    scroll-snap-type: x proximity;
}

@media (hover: none) {
    .sticker-prompt-card:hover {
        border-color: var(--border-glass);
        background: var(--bg-item);
    }

    .sticker-gallery-item:hover {
        border-color: var(--border-glass);
        box-shadow: none;
    }

    .sticker-custom-gen-btn:hover {
        transform: none;
        box-shadow: none;
    }

    .sticker-expand-item:hover {
        border-color: var(--border-glass);
        box-shadow: none;
    }
}
