/* Motion Video Panel — 우측 슬라이드 패널
   Style Reference Panel과 동일 레이아웃, 영상 카드 지원
   PC (769px+): 35% / Tablet (481-768px): 45% / Mobile (≤480px): 100% */

/* === 오버레이 === */
.motion-video-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.35s ease;
}
.motion-video-overlay.active { display: block; opacity: 1; }

/* === 패널 === */
.motion-video-panel {
    position: fixed;
    right: 0; top: 0;
    width: 35%; height: 100vh;
    background: linear-gradient(180deg, #1e1a2e 0%, #2a2342 40%, #312450 100%);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.35);
    display: flex; flex-direction: column;
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}
.motion-video-panel.active { transform: translateX(0); }

/* 패널 열릴 때 메인 콘텐츠 축소 */
body.motion-video-open .avatar-container {
    width: 65% !important;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* === 헤더 === */
.motion-video-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.2rem 1.2rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}
.motion-video-header-left { flex: 1; }
.motion-video-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.motion-video-subtitle {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 0.2rem;
}
.motion-video-close {
    width: 32px; height: 32px;
    min-width: 32px; max-width: 32px;
    min-height: 32px; max-height: 32px;
    aspect-ratio: 1/1;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    padding: 0;
    margin: 0;
    line-height: 1;
    flex-grow: 0;
    align-self: flex-start;
    transition: background 0.2s, color 0.2s;
}
.motion-video-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* === 카테고리 탭 === */
.motion-video-tabs {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    flex-shrink: 0;
    overflow-x: auto;
}
.motion-video-tab {
    padding: 0.35rem 0.8rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
    height: auto;
    line-height: 1.4;
    letter-spacing: 0;
    text-transform: none;
}
.motion-video-tab:hover {
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.7);
}
.motion-video-tab.active {
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}

/* === 그리드 === */
.motion-video-grid-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 0.8rem 1.2rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(167, 139, 250, 0.3) transparent;
}
.motion-video-grid-wrapper::-webkit-scrollbar { width: 6px; }
.motion-video-grid-wrapper::-webkit-scrollbar-track { background: transparent; }
.motion-video-grid-wrapper::-webkit-scrollbar-thumb { background: rgba(167, 139, 250, 0.25); border-radius: 3px; }

.motion-video-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem;
}

/* === 카드 === */
.motion-video-card {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid transparent;
    transition: all 0.25s ease;
    aspect-ratio: 9/16;
}
.motion-video-card:hover {
    border-color: rgba(167, 139, 250, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.motion-video-card.selected {
    border-color: #a78bfa;
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.3);
}

/* 영상 썸네일 */
.motion-video-card video,
.motion-video-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 재생 아이콘 오버레이 (클릭으로 재생/정지) */
.motion-video-play-icon {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 36px; height: 36px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    z-index: 4;
}
.motion-video-card:hover .motion-video-play-icon { opacity: 1; }
/* 재생 중: 평소 투명, hover 시 반투명 표시 */
.motion-video-play-icon.playing { opacity: 0; }
.motion-video-card:hover .motion-video-play-icon.playing { opacity: 0.7; }

/* 카드 이름 오버레이 */
.motion-video-card-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding: 1.5rem 0.5rem 0.5rem;
}
.motion-video-card-name {
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

/* 🆕 영상 길이/크레딧 칩 (좌상단) */
.motion-video-card-chip {
    position: absolute;
    top: 6px; left: 6px;
    background: rgba(30, 26, 46, 0.85);
    color: #d8b4fe;
    font-size: 0.62rem;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 999px;
    border: 1px solid rgba(167, 139, 250, 0.35);
    line-height: 1;
    z-index: 4;
    pointer-events: none;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* 🆕 헤더 가격 안내 (조용한 톤) */
.motion-video-pricing-hint {
    color: rgba(167, 139, 250, 0.75);
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 0.15rem;
    cursor: help;
}

/* === 오디오 컨트롤 (항상 표시, 조작 후 자동 숨김) === */
.motion-video-audio-ctrl {
    position: absolute;
    bottom: 28px; left: 6px; right: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 5;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.4s ease;
}
/* 조작 후 자동 숨김 */
.motion-video-audio-ctrl.auto-hidden {
    opacity: 0;
    pointer-events: none;
}
/* hover 시 다시 표시 */
.motion-video-card:hover .motion-video-audio-ctrl.auto-hidden {
    opacity: 1;
    pointer-events: auto;
}

.motion-audio-toggle {
    width: 26px; height: 26px;
    min-width: 26px; max-width: 26px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    padding: 0;
    margin: 0;
    line-height: 1;
    transition: background 0.2s, border-color 0.2s;
}
.motion-audio-toggle:hover {
    background: rgba(167, 139, 250, 0.5);
    border-color: rgba(167, 139, 250, 0.6);
}

.motion-volume-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.45);
    outline: none;
    cursor: pointer;
}
.motion-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #a78bfa;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    margin-top: -4px;
}
.motion-volume-slider::-moz-range-thumb {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #a78bfa;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.motion-volume-slider::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
}
.motion-volume-slider::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.45);
}

/* 빈 상태 */
.motion-video-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem 1rem;
    color: rgba(255, 255, 255, 0.3);
}
.motion-video-empty i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}
.motion-video-empty p {
    font-size: 0.82rem;
    line-height: 1.4;
}

/* === 푸터 — 적용 버튼 === */
.motion-video-footer {
    padding: 0.8rem 1.2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.motion-video-footer-info {
    flex: 1;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}
.motion-video-footer-info i { margin-right: 0.3rem; }
.motion-video-apply-btn {
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    border: none;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
    height: auto;
    line-height: 1.4;
    letter-spacing: 0;
    text-transform: none;
}
.motion-video-apply-btn:hover { opacity: 0.85; }
.motion-video-apply-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* === 선택된 참조영상 오버레이 (메인 이미지 위) === */
.motion-ref-overlay {
    position: absolute;
    bottom: 8px; left: 8px;
    background: rgba(30, 26, 46, 0.9);
    border: 1px solid rgba(167, 139, 250, 0.3);
    border-radius: 8px;
    padding: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
    max-width: 45%;
}
.motion-ref-overlay video,
.motion-ref-overlay img {
    width: 48px; height: 48px;
    border-radius: 6px;
    object-fit: cover;
}
.motion-ref-overlay-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.motion-ref-overlay-label {
    font-size: 0.6rem;
    color: #a78bfa;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.motion-ref-overlay-meta {
    font-size: 0.6rem;
    color: rgba(216, 180, 254, 0.85);
    font-weight: 600;
    margin-top: 1px;
}
.motion-ref-overlay-name {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}
.motion-ref-remove {
    width: 20px; height: 20px;
    min-width: 20px; max-width: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    padding: 0;
    margin: 0;
    line-height: 1;
    transition: background 0.2s;
}
.motion-ref-remove:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* === 반응형 === */
@media (max-width: 768px) {
    .motion-video-panel { width: 45%; }
    body.motion-video-open .avatar-container { width: 55% !important; }
}
@media (max-width: 480px) {
    .motion-video-panel { width: 100%; }
    body.motion-video-open .avatar-container { width: 100% !important; }
    .motion-video-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
}
