/* CinemaMod Web Player - Tailwind 보완 스타일 */

/* 텍스트 선택 및 드래그 방지 */
body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    overflow-x: hidden;
}

/* 입력 필드는 선택 허용 */
input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* 인증 코드 입력 */
.code-input-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(2px, 1.5vw, 6px);
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.code-input {
    flex: 0 1 44px;
    width: 44px;
    height: 52px;
    border: 2px solid hsl(240 3.7% 20%);
    border-radius: 10px;
    background: hsl(240 10% 6%);
    color: hsl(0 0% 98%);
    font-size: 1.35rem;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    caret-color: hsl(142 76% 46%);
    transition: all 0.2s ease;
    outline: none;
}

/* 좁은 화면에서 입력창 축소 */
@media (max-width: 340px) {
    .code-input-wrapper {
        gap: 4px;
    }
    .code-input {
        flex: 0 1 36px;
        width: 36px;
        height: 44px;
        font-size: 1.1rem;
        border-radius: 8px;
    }
}

@media (max-width: 280px) {
    .code-input-wrapper {
        gap: 2px;
    }
    .code-input {
        flex: 0 1 28px;
        width: 28px;
        height: 36px;
        font-size: 0.9rem;
        border-radius: 6px;
    }
}

/* 극소형 화면 UI 기본 숨김 */
.login-minimal {
    display: none;
}

/* 극소형 화면 (320x320 이하) */
@media (max-width: 320px) and (max-height: 320px) {
    .login-normal {
        display: none !important;
    }

    .login-minimal {
        display: flex !important;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
        width: 100%;
        box-sizing: border-box;
    }
}

/* 극소형 UI 스타일 */
.minimal-input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    background: hsl(240 10% 8%);
    border: 1px solid hsl(240 3.7% 25%);
    border-radius: 6px;
    color: hsl(0 0% 98%);
    font-size: 14px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    outline: none;
    box-sizing: border-box;
}

.minimal-input:focus {
    border-color: hsl(142 76% 46%);
}

.minimal-input::placeholder {
    text-transform: none;
    letter-spacing: normal;
    color: hsl(240 5% 50%);
}

.minimal-btn {
    width: 100%;
    height: 36px;
    background: hsl(142 76% 36%);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.minimal-btn:active {
    background: hsl(142 76% 30%);
}

.minimal-error {
    font-size: 11px;
    color: hsl(0 70% 60%);
    text-align: center;
    min-height: 14px;
}

.code-input:focus {
    border-color: hsl(142 76% 46%);
    background: hsl(240 10% 8%);
    box-shadow: 0 0 0 3px hsl(142 76% 46% / 0.15);
}

/* 화면 전환 */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* 로그인 화면 */
#login-screen.active {
    display: block !important;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 16px;
    box-sizing: border-box;
    overflow-y: auto;
}

#login-screen .login-content {
    width: 100%;
    max-width: 24rem;
    margin: 0 auto;
}

/* 비디오 컨테이너 */
#video-container iframe,
#video-container #yt-player {
    width: 100%;
    height: 100%;
    border: none;
}

/* 토스트 메시지 */
.toast-message {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: hsl(240 10% 10% / 0.95);
    color: hsl(0 0% 98%);
    padding: 16px 24px;
    border-radius: 8px;
    border: 1px solid hsl(240 3.7% 15.9%);
    font-size: 0.95rem;
    text-align: center;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-message small {
    display: block;
    margin-top: 4px;
    color: hsl(240 5% 64.9%);
    font-size: 0.8rem;
}

/* PIP 옵션 모달 */
.pip-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

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

.pip-modal-content {
    background: hsl(240 10% 3.9%);
    border: 1px solid hsl(240 3.7% 15.9%);
    border-radius: 12px;
    padding: 24px;
    max-width: 340px;
    width: 100%;
    animation: slideUp 0.3s ease;
}

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

.pip-modal-content h3 {
    margin-bottom: 12px;
    font-weight: 600;
}

.pip-modal-content p {
    color: hsl(240 5% 64.9%);
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.pip-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.pip-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: hsl(240 3.7% 15.9%);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: hsl(0 0% 98%);
}

.pip-option:hover {
    border-color: hsl(240 4.9% 83.9%);
    background: hsl(240 3.7% 20%);
}

.pip-option svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.pip-option span {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.pip-option small {
    color: hsl(240 5% 64.9%);
    font-size: 0.8rem;
}

.pip-modal-close {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid hsl(240 3.7% 15.9%);
    border-radius: 8px;
    color: hsl(240 5% 64.9%);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.pip-modal-close:hover {
    background: hsl(240 3.7% 15.9%);
    color: hsl(0 0% 98%);
}

/* 컴팩트 모드 스타일 */
body.compact-mode #player-screen {
    padding: 0;
}

body.compact-mode .player-container {
    padding: 0;
    max-width: 100%;
}

body.compact-mode #video-wrapper {
    border-radius: 0;
    margin-bottom: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding-bottom: 0;
    z-index: 100;
}

body.compact-mode #video-container {
    position: absolute;
    inset: 0;
}

body.compact-mode .flex.items-center.gap-3,
body.compact-mode .space-y-3 {
    display: none;
}

body.compact-mode .compact-overlay {
    display: flex;
}

/* 컴팩트 모드 클릭 레이어 */
.compact-click-layer {
    display: none;
}

body.compact-mode .compact-click-layer {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 99;
    background: transparent;
    cursor: pointer;
}

body.compact-mode.overlay-visible .compact-click-layer {
    display: none;
}

/* 컴팩트 오버레이 */
.compact-overlay {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    padding: 16px;
    z-index: 101;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

.compact-overlay.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

body.compact-mode .compact-overlay.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.compact-overlay .compact-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compact-overlay .compact-time {
    font-size: 0.75rem;
    color: hsl(240 5% 64.9%);
}

.compact-overlay .compact-controls {
    display: flex;
    gap: 8px;
}

.compact-overlay .compact-btn {
    flex: 1;
    padding: 10px;
    background: hsl(0 0% 100% / 0.15);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.compact-overlay .compact-btn:active {
    background: hsl(0 0% 100% / 0.25);
}

.compact-overlay .compact-voteskip-btn {
    background: hsl(38 92% 50% / 0.8);
}

.compact-overlay .compact-voteskip-btn:active {
    background: hsl(38 92% 40%);
}

.compact-overlay .compact-voteskip-btn.hidden {
    display: none;
}

/* 구석 나가기 버튼 - 항상 고정 위치 */
.compact-corner-btn {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    background: hsl(0 0% 0% / 0.6);
    border: 1px solid hsl(0 0% 100% / 0.2);
    border-radius: 50%;
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    z-index: 200;
    transition: background 0.2s;
    flex-shrink: 0;
}

.compact-corner-btn:active {
    background: hsl(0 0% 100% / 0.3);
}

/* 컴팩트 모드에서 항상 표시 */
body.compact-mode .compact-corner-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 극소형 창 */
@media (max-width: 200px), (max-height: 150px) {
    body.compact-mode .compact-overlay {
        padding: 8px;
    }

    body.compact-mode .compact-overlay .compact-title {
        font-size: 0.75rem;
    }

    body.compact-mode .compact-overlay .compact-controls {
        display: none;
    }
}

/* 가로 모드 소형 창 */
@media (max-height: 200px) and (orientation: landscape) {
    body.compact-mode .compact-overlay {
        flex-direction: row;
        align-items: center;
        padding: 8px 12px;
    }

    body.compact-mode .compact-overlay .compact-title {
        flex: 1;
    }

    body.compact-mode .compact-overlay .compact-time {
        margin-left: 8px;
    }

    body.compact-mode .compact-overlay .compact-controls {
        display: none;
    }
}

/* 커스텀 전체화면 버튼 */
.custom-fullscreen-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    padding: 0;
    background: hsl(0 0% 0% / 0.7);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s, background 0.2s;
}

#video-wrapper:hover .custom-fullscreen-btn,
#video-wrapper:focus-within .custom-fullscreen-btn {
    opacity: 1;
}

.custom-fullscreen-btn:hover {
    background: hsl(0 0% 0% / 0.9);
}

.custom-fullscreen-btn:active {
    background: hsl(0 0% 20%);
}

/* 모바일에서는 항상 표시 */
@media (hover: none) {
    .custom-fullscreen-btn {
        opacity: 0.8;
    }
}

/* 컴팩트 모드에서 전체화면 버튼 숨김 */
body.compact-mode .custom-fullscreen-btn {
    display: none;
}

/* 전체화면일 때 버튼 위치 조정 */
#video-wrapper:fullscreen .custom-fullscreen-btn {
    bottom: 24px;
    right: 24px;
}

/* 반응형 */
@media (max-width: 640px) {
    .toast-message {
        bottom: 80px;
        padding: 14px 20px;
        font-size: 0.9rem;
    }

    .custom-fullscreen-btn {
        width: 40px;
        height: 40px;
        bottom: 12px;
        right: 12px;
    }
}
