/**
 * 7eys-AI Sticker page - getstyle/getavata와 동일한 메인 이미지 프레임 구조
 * getstyle.css를 베이스로 로드하며, .avatar-image-wrapper를 그대로 사용.
 * 여기서는 스티커 전용 그리드·체크박스·확대보기만 정의.
 */

/* 메인 이미지: 사용자 업로드 시 프레임 꽉 채우기 (아바타/스타일과 동일) */
#stickerBackgroundImage .background-img {
    object-fit: cover !important;
}

/* 3×3 스티커 결과 그리드 - 넉넉한 간격으로 배경 이미지가 사이사이 보이게 */
.sticker-result-grid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 16px;
    padding: 24px;
    box-sizing: border-box;
    z-index: 2;
}

.sticker-cell {
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}
/* 스티커 생성 후 투명 배경이 보이도록 미세한 체커보드 */
.sticker-cell:not(.sticker-cell-placeholder) {
    background:
        linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.04) 75%),
        linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.04) 75%);
    background-size: 12px 12px;
    background-position: 0 0, 6px 6px;
}

.sticker-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: relative;
    z-index: 1;
}

.sticker-cell-placeholder {
    background: rgba(255, 255, 255, 0.04);
}

/* 셀 호버 & 클릭 */
.sticker-cell:not(.sticker-cell-placeholder) {
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.sticker-cell:not(.sticker-cell-placeholder):hover {
    transform: scale(1.03);
    box-shadow: 0 2px 8px rgba(183, 78, 145, 0.35);
    z-index: 3;
}

/* 체크박스 선택 버튼 (우측 하단) - main.css 전역 숨김 스타일 강제 재정의 */
.sticker-cell-check {
    -webkit-appearance: checkbox !important;
    -moz-appearance: checkbox !important;
    appearance: checkbox !important;
    position: absolute !important;
    bottom: 5px !important;
    right: 5px !important;
    width: 22px !important;
    height: 22px !important;
    accent-color: #b74e91;
    cursor: pointer !important;
    z-index: 10 !important;
    margin: 0 !important;
    opacity: 0.85 !important;
    float: none !important;
    display: block !important;
    transition: opacity 0.2s, transform 0.15s;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
    pointer-events: auto;
}
.sticker-cell:hover .sticker-cell-check {
    opacity: 1 !important;
    transform: scale(1.15);
}
.sticker-cell-check:checked {
    opacity: 1 !important;
}

/* ===== 확대 보기 오버레이 ===== */
.sticker-enlarged-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 30000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}
.sticker-enlarged-overlay.active {
    display: flex;
}

.sticker-enlarged-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.2rem;
    cursor: pointer;
    z-index: 2;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.sticker-enlarged-close:hover {
    opacity: 1;
}

.sticker-enlarged-image {
    max-width: min(85vw, 520px);
    max-height: 70vh;
    object-fit: contain;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
}

/* 스티커 서비스: 메인 이미지 프레임 우측 서비스 버튼+컨테이너 전체 비표시 (로직 유지, 화면만 숨김). 다시 보이게 하려면 getsticker.html에서 .hide-all-service-btns 제거 */
.icon-menu-container.hide-all-service-btns {
    display: none !important;
}

/* ===================================================================
   Motion Menu - icon-menu-container 패턴 (pill 형태, 우측 중앙)
   hedra-container 기준 absolute → 이미지 프레임에 반쯤 걸침
   =================================================================== */
.sticker-motion-menu {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
    background: linear-gradient(135deg, rgba(94, 66, 166, 0.45) 0%, rgba(183, 78, 145, 0.45) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 10px 8px;
    border-radius: 50px;
    border: 1px solid rgba(183, 78, 145, 0.4);
    box-shadow: 0 8px 32px rgba(94, 66, 166, 0.2);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sticker-motion-menu:hover {
    background: linear-gradient(135deg, rgba(94, 66, 166, 0.65) 0%, rgba(183, 78, 145, 0.65) 100%);
    border-color: rgba(183, 78, 145, 0.6);
    box-shadow: 0 12px 40px rgba(94, 66, 166, 0.35);
}

.sticker-motion-menu .icon-menu-btn {
    width: 40px;
    height: 40px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.9);
    font-size: 18px;
    flex-shrink: 0;
    position: relative;
    padding: 0;
    margin: 0;
}

.sticker-motion-menu .icon-menu-btn:hover,
.sticker-motion-menu .icon-menu-btn:focus,
.sticker-motion-menu .icon-menu-btn:active {
    color: #fff !important;
    transform: scale(1.08);
    background: rgba(255, 255, 255, 0.12) !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.sticker-motion-menu .icon-menu-btn::after {
    display: none !important;
    content: none !important;
}

/* Motion 활성화 상태 */
.sticker-motion-menu .icon-menu-btn.active {
    background: linear-gradient(135deg, rgba(94, 66, 166, 0.9), rgba(183, 78, 145, 0.9)) !important;
    color: #fff !important;
    box-shadow: 0 0 16px rgba(183, 78, 145, 0.5) !important;
}

.sticker-motion-menu .icon-menu-btn.active i {
    animation: motionIconSpin 2s linear infinite;
}

@keyframes motionIconSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===================================================================
   Motion Video Crop - 셀 내 비디오 오버레이
   시트 비디오를 300%로 확대하여 해당 셀 부분만 표시
   =================================================================== */
.motion-video-crop {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 2;
    border-radius: inherit;
    transition: opacity 0.5s ease;
}

.motion-video-crop video {
    pointer-events: none;
}

/* 모션 활성화된 셀에 인디케이터 점 (좌측 상단) */
.sticker-cell.motion-video-active::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    background: #b74e91;
    border-radius: 50%;
    z-index: 11;
    box-shadow: 0 0 6px rgba(183, 78, 145, 0.6);
    animation: motionDotPulse 2s ease-in-out infinite;
}

@keyframes motionDotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===================================================================
   Enlarged View - 모션 비디오 표시
   =================================================================== */
.sticker-enlarged-video {
    max-width: min(85vw, 520px);
    max-height: 70vh;
    width: 360px;
    height: 360px;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
}

.motion-enlarged-video-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.motion-enlarged-video-wrap video {
    pointer-events: none;
}

/* ===================================================================
   Motion Responsive
   =================================================================== */
@media (max-width: 480px) {
    .sticker-motion-menu {
        right: 8px;
        padding: 8px 6px;
    }
    .sticker-motion-menu .icon-menu-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    .sticker-enlarged-video {
        width: 280px;
        height: 280px;
    }
}

/* ===================================================================
   Telegram Sticker Modal - movieStyleModal 동일 패턴 (fixed overlay)
   =================================================================== */
.telegram-sticker-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.82);
    z-index: 50000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: telegramModalFadeIn 0.25s ease-out;
}

@keyframes telegramModalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.telegram-modal-content {
    background: linear-gradient(135deg, #1a2a4a 0%, #243b6e 50%, #1a2a4a 100%);
    border-radius: 16px;
    padding: 36px 32px 28px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 1px rgba(41, 182, 246, 0.4);
    border: 1px solid rgba(41, 182, 246, 0.25);
    position: relative;
    animation: telegramContentSlide 0.3s ease-out;
}

@keyframes telegramContentSlide {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.telegram-modal-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    text-align: center;
}

.telegram-modal-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(41, 182, 246, 0.5), transparent);
    margin: 12px 0 16px;
    border: none;
}

.telegram-modal-desc {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.82rem;
    line-height: 1.55;
    text-align: center;
    margin: 0 0 20px;
}

.telegram-input-label {
    display: block;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 5px;
    margin-top: 12px;
}

.telegram-input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(41, 182, 246, 0.3);
    border-radius: 10px;
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.telegram-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.telegram-input:focus {
    border-color: rgba(41, 182, 246, 0.7);
    box-shadow: 0 0 12px rgba(41, 182, 246, 0.2);
}

.telegram-result-area {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-break: break-all;
}

.telegram-result-area.success {
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid rgba(76, 175, 80, 0.4);
    color: #a5d6a7;
}

.telegram-result-area.error {
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid rgba(244, 67, 54, 0.4);
    color: #ef9a9a;
}

.telegram-result-area.loading {
    background: rgba(41, 182, 246, 0.1);
    border: 1px solid rgba(41, 182, 246, 0.3);
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
}

.telegram-progress-main {
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.telegram-progress-sub {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 10px;
}

.telegram-progress-bar-wrap {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}

.telegram-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0088cc, #29b6f6);
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

.telegram-modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.telegram-btn {
    flex: 1;
    padding: 12px 0;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.telegram-btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.telegram-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.telegram-btn-confirm {
    background: linear-gradient(135deg, #0088cc, #29b6f6);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 136, 204, 0.35);
}

.telegram-btn-confirm:hover {
    background: linear-gradient(135deg, #0099e0, #4fc3f7);
    box-shadow: 0 6px 20px rgba(0, 136, 204, 0.5);
    transform: translateY(-1px);
}

.telegram-btn-confirm.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Telegram icon button color */
.sticker-motion-menu .icon-menu-btn.telegram-icon {
    color: rgba(41, 182, 246, 0.9);
}

.sticker-motion-menu .icon-menu-btn.telegram-icon:hover {
    color: #29b6f6 !important;
    background: rgba(41, 182, 246, 0.15) !important;
}

/* ===== Telegram Modal Responsive ===== */
@media (max-width: 480px) {
    .telegram-modal-content {
        padding: 28px 20px 22px;
    }
    .telegram-modal-title {
        font-size: 1.15rem;
    }
    .telegram-btn {
        font-size: 0.88rem;
        padding: 11px 0;
    }
}

/* ===== 갤러리 최신 항목 강조 ===== */
.gallery-item-active {
    outline: 2px solid rgba(180, 120, 255, 0.8);
    outline-offset: 2px;
    box-shadow: 0 0 10px rgba(180, 120, 255, 0.4);
}
