/* 스티커 위젯 스타일 */

/* 기본 컨테이너 스타일 */
.sticker-container {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* 화면 고정 (fixed) 컨테이너 - 스크롤해도 화면에 고정 */
.sticker-container-fixed {
    position: fixed;
}

/* 페이지 콘텐츠 (absolute) 컨테이너 - 페이지와 함께 스크롤 */
.sticker-container-absolute {
    position: absolute;
    /* 전체 문서 높이만큼 확장 */
    height: auto;
    min-height: 100%;
}

.sticker-item {
    position: absolute;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    transition: transform 0.2s ease;
}

/* 편집 모드 컨트롤 패널 기본 스타일 */
.sticker-control-top,
.sticker-control-right,
.sticker-control-bottom {
    position: absolute;
    border-radius: 6px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.sticker-control-top {
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 6px;
    display: flex;
    gap: 3px;
    white-space: nowrap;
}

.sticker-control-right {
    right: -45px;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sticker-control-bottom {
    bottom: -70px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* 편집 모드일 때만 컨트롤 패널 표시 */
body.sticker-edit-mode .sticker-item:hover .sticker-control-top,
body.sticker-edit-mode .sticker-item:hover .sticker-control-right,
body.sticker-edit-mode .sticker-item:hover .sticker-control-bottom,
body.sticker-edit-mode .sticker-item.selected .sticker-control-top,
body.sticker-edit-mode .sticker-item.selected .sticker-control-right,
body.sticker-edit-mode .sticker-item.selected .sticker-control-bottom {
    opacity: 1;
    pointer-events: auto;
}

/* 컨트롤 버튼 */
.control-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    background: rgba(23, 25, 29, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.control-btn:hover {
    background: rgba(23, 25, 29, 0.3);
    transform: scale(1.1);
}

.control-btn.danger {
    background: rgba(244, 67, 54, 0.8);
    border-color: rgba(244, 67, 54, 1);
}

.control-btn.danger:hover {
    background: rgba(244, 67, 54, 1);
}

/* 아이콘 버튼 (필터/애니메이션) */
.control-icon-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    background: rgba(23, 25, 29, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.control-icon-btn:hover {
    background: rgba(23, 25, 29, 0.3);
    color: white;
}

.control-icon-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.control-row {
    display: flex;
    gap: 2px;
}

/* 수직 슬라이더 */
.vertical-slider {
    writing-mode: bt-lr;
    -webkit-appearance: slider-vertical;
    width: 6px;
    height: 70px;
    cursor: pointer;
}

/* 리사이즈 핸들 */
.resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border: 2px solid var(--info-color);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

body.sticker-edit-mode .sticker-item:hover .resize-handle,
body.sticker-edit-mode .sticker-item.selected .resize-handle {
    opacity: 1;
}

.resize-se {
    bottom: -7px;
    right: -7px;
    cursor: se-resize;
}

.sticker-item.draggable {
    cursor: move;
    cursor: grab;
}

.sticker-item.dragging {
    cursor: grabbing;
    opacity: 0.8;
    transform: scale(1.05);
    z-index: 10000;
}

.sticker-item img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    pointer-events: none;
}

/* 관리자 모드: 삭제 버튼 - 기본은 숨김 (편집 모드에서만 표시) */
.sticker-item .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #f44336;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.2s;
    display: none; /* 기본 숨김 */
}

/* 편집 모드에서만 삭제 버튼 표시 */
body.sticker-edit-mode .sticker-item .delete-btn {
    display: block;
}

body.sticker-edit-mode .sticker-item:hover .delete-btn {
    opacity: 1;
}

.sticker-item .delete-btn:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

/* 반응형 */
@media (max-width: 768px) {
    .sticker-item {
        max-width: 80px !important;
        max-height: 80px !important;
    }

    .sticker-item .delete-btn {
        width: 20px;
        height: 20px;
        font-size: 12px;
        line-height: 16px;
    }
}

/* 애니메이션 효과 (선택) */
@keyframes sticker-appear {
    from {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.sticker-item.appear {
    animation: sticker-appear 0.3s ease-out;
}

/* ===== 스티커 애니메이션 (저장된 애니메이션 표시용) ===== */
/* 통!... 통!... 느낌 - 동작 후 쉬는 시간 포함 */

/* 바운스 - 일반 (1.5초 주기, 0.3초 동작 + 1.2초 대기) */
.sticker-item img.sticker-bounce {
    animation: stickerBounce 1.5s ease-out infinite;
}

/* 바운스 - 좌우반전 */
.sticker-item img.sticker-bounce[data-flip-h="1"] {
    animation: stickerBounceFlip 1.5s ease-out infinite;
}

@keyframes stickerBounce {
    0% { transform: translateY(0) scaleY(1); }
    6% { transform: translateY(-15px) scaleX(0.95) scaleY(1.1); }
    12% { transform: translateY(0) scaleX(1.05) scaleY(0.9); }
    15% { transform: translateY(-5px) scaleY(1.02); }
    20% { transform: translateY(0) scaleY(1); }
    100% { transform: translateY(0) scaleY(1); }
}

@keyframes stickerBounceFlip {
    0% { transform: translateY(0) scaleY(1) scaleX(-1); }
    6% { transform: translateY(-15px) scaleY(1.1) scaleX(-0.95); }
    12% { transform: translateY(0) scaleY(0.9) scaleX(-1.05); }
    15% { transform: translateY(-5px) scaleY(1.02) scaleX(-1); }
    20% { transform: translateY(0) scaleY(1) scaleX(-1); }
    100% { transform: translateY(0) scaleY(1) scaleX(-1); }
}

/* 흔들림 - 일반 (1.2초 주기, 0.25초 동작 + 대기) */
.sticker-item img.sticker-shake {
    animation: stickerShake 1.2s ease-in-out infinite;
}

/* 흔들림 - 좌우반전 */
.sticker-item img.sticker-shake[data-flip-h="1"] {
    animation: stickerShakeFlip 1.2s ease-in-out infinite;
}

@keyframes stickerShake {
    0% { transform: translateX(0) rotate(0deg); }
    4% { transform: translateX(-5px) rotate(-5deg); }
    8% { transform: translateX(5px) rotate(5deg); }
    12% { transform: translateX(-3px) rotate(-3deg); }
    16% { transform: translateX(3px) rotate(3deg); }
    20% { transform: translateX(0) rotate(0deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

@keyframes stickerShakeFlip {
    0% { transform: translateX(0) rotate(0deg) scaleX(-1); }
    4% { transform: translateX(-5px) rotate(-5deg) scaleX(-1); }
    8% { transform: translateX(5px) rotate(5deg) scaleX(-1); }
    12% { transform: translateX(-3px) rotate(-3deg) scaleX(-1); }
    16% { transform: translateX(3px) rotate(3deg) scaleX(-1); }
    20% { transform: translateX(0) rotate(0deg) scaleX(-1); }
    100% { transform: translateX(0) rotate(0deg) scaleX(-1); }
}

/* 펄스 - 일반 (1.5초 주기) */
.sticker-item img.sticker-pulse {
    animation: stickerPulse 1.5s ease-in-out infinite;
}

/* 펄스 - 좌우반전 */
.sticker-item img.sticker-pulse[data-flip-h="1"] {
    animation: stickerPulseFlip 1.5s ease-in-out infinite;
}

@keyframes stickerPulse {
    0% { transform: scale(1); }
    10% { transform: scale(1.12); }
    20% { transform: scale(1); }
    100% { transform: scale(1); }
}

@keyframes stickerPulseFlip {
    0% { transform: scale(1) scaleX(-1); }
    10% { transform: scale(1.12) scaleX(-1); }
    20% { transform: scale(1) scaleX(-1); }
    100% { transform: scale(1) scaleX(-1); }
}

/* 회전 - 일반 (2초 주기, 빠른 회전 후 대기) */
.sticker-item img.sticker-rotate {
    animation: stickerRotate 2s ease-out infinite;
}

/* 회전 - 좌우반전 */
.sticker-item img.sticker-rotate[data-flip-h="1"] {
    animation: stickerRotateFlip 2s ease-out infinite;
}

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

@keyframes stickerRotateFlip {
    0% { transform: rotate(0deg) scaleX(-1); }
    25% { transform: rotate(360deg) scaleX(-1); }
    100% { transform: rotate(360deg) scaleX(-1); }
}
