/**
 * VdoCipher LearnDash Video Progression Styles
 * @version 1.7.0
 * 
 * 브라우저 호환성: Chrome, Edge, Safari (14.0+), Firefox, Whale, 모바일
 * - gap 속성 대신 margin 사용 (Safari 14.0 이하 지원)
 * - -webkit- vendor prefix 포함
 */

/* ========================================
   버튼 숨김/표시
   ======================================== */

.vdocp-hidden-until-complete {
    opacity: 0 !important;
    visibility: hidden !important;
    max-height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    -webkit-transition: all 0.4s ease !important;
    transition: all 0.4s ease !important;
}

/* ========================================
   영상 아래 완료 알림
   ======================================== */

.vdocp-completion-notice {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    background: -webkit-linear-gradient(315deg, #3DBAB0 0%, #2FA89E 100%);
    background: linear-gradient(135deg, #3DBAB0 0%, #2FA89E 100%);
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 8px;
    margin: 12px 0;
    -webkit-box-shadow: 0 2px 8px rgba(61, 186, 176, 0.2);
    box-shadow: 0 2px 8px rgba(61, 186, 176, 0.2);
    -webkit-animation: vdocpSlideIn 0.5s ease;
    animation: vdocpSlideIn 0.5s ease;
}

.vdocp-notice-icon {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    margin-right: 10px;
}

.vdocp-notice-text {
    font-size: 13px;
    line-height: 1.4;
}

/* ========================================
   이어보기 팝업 (공통)
   ======================================== */

.vdocp-resume-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    z-index: 999999;
    -webkit-animation: vdocpFadeIn 0.3s ease;
    animation: vdocpFadeIn 0.3s ease;
}

.vdocp-resume-popup {
    background: #ffffff;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    -webkit-box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    -webkit-animation: vdocpPopIn 0.3s ease;
    animation: vdocpPopIn 0.3s ease;
}

.vdocp-resume-popup-wide {
    max-width: 480px;
}

.vdocp-resume-title {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 20px;
}

.vdocp-resume-message {
    font-size: 15px;
    color: #6b7280;
    margin-bottom: 25px;
    line-height: 1.6;
}

.vdocp-resume-message strong {
    color: #3DBAB0;
    font-size: 18px;
}

/* ========================================
   다른 레슨 이어보기 팝업
   ======================================== */

.vdocp-resume-lesson-info {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    background: #f3f4f6;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 25px;
    text-align: left;
}

/* gap 대체: margin 사용 */
.vdocp-resume-lesson-info > * {
    margin-right: 15px;
}

.vdocp-resume-lesson-info > *:last-child {
    margin-right: 0;
}

.vdocp-resume-lesson-icon {
    font-size: 32px;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.vdocp-resume-lesson-details {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 0;
}

.vdocp-resume-lesson-title {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 6px;
    line-height: 1.4;
    /* 긴 제목 말줄임 - Safari 호환 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* Firefox 대응 */
    max-height: 2.8em;
}

.vdocp-resume-lesson-progress {
    font-size: 14px;
    color: #6b7280;
}

.vdocp-resume-lesson-progress strong {
    color: #3DBAB0;
    font-size: 16px;
}

/* ========================================
   버튼
   ======================================== */

.vdocp-resume-buttons {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
}

/* gap 대체: margin 사용 */
.vdocp-resume-buttons > button {
    margin: 0 6px;
}

.vdocp-resume-buttons > button:first-child {
    margin-left: 0;
}

.vdocp-resume-buttons > button:last-child {
    margin-right: 0;
}

.vdocp-resume-buttons button {
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    border: none;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    max-width: 180px;
    /* 터치 영역 확보 (모바일) */
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.vdocp-resume-yes {
    background: -webkit-linear-gradient(315deg, #4F3F98 0%, #3F3280 100%);
    background: linear-gradient(135deg, #4F3F98 0%, #3F3280 100%);
    color: #ffffff;
}

.vdocp-resume-yes:hover {
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 4px 15px rgba(79, 63, 152, 0.4);
    box-shadow: 0 4px 15px rgba(79, 63, 152, 0.4);
}

.vdocp-resume-yes:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
}

.vdocp-resume-no {
    background: #f3f4f6;
    color: #6b7280;
}

.vdocp-resume-no:hover {
    background: #e5e7eb;
}

/* 버튼 서브타이틀 */
.vdocp-btn-subtitle {
    display: block;
    font-size: 11px;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 4px;
}

.vdocp-resume-yes .vdocp-btn-subtitle {
    opacity: 0.9;
}

/* ========================================
   애니메이션
   ======================================== */

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

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

@-webkit-keyframes vdocpFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@-webkit-keyframes vdocpPopIn {
    from {
        opacity: 0;
        -webkit-transform: scale(0.9);
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        -webkit-transform: scale(1);
        transform: scale(1);
    }
}

@keyframes vdocpPopIn {
    from {
        opacity: 0;
        -webkit-transform: scale(0.9);
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        -webkit-transform: scale(1);
        transform: scale(1);
    }
}

/* ========================================
   반응형
   ======================================== */

@media screen and (max-width: 768px) {
    .vdocp-completion-notice {
        padding: 8px 12px;
    }

    .vdocp-notice-icon {
        width: 24px;
        height: 24px;
        font-size: 12px;
        margin-right: 8px;
    }

    .vdocp-notice-text {
        font-size: 12px;
    }

    .vdocp-resume-popup {
        padding: 25px 20px;
        margin: 15px;
        /* iOS Safari safe area */
        padding-bottom: calc(25px + env(safe-area-inset-bottom, 0px));
    }
    
    .vdocp-resume-popup-wide {
        max-width: 100%;
    }

    .vdocp-resume-buttons {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
    }

    /* gap 대체: column 방향일 때 margin 변경 */
    .vdocp-resume-buttons > button {
        margin: 6px 0;
        width: 100%;
        max-width: none;
    }

    .vdocp-resume-buttons > button:first-child {
        margin-top: 0;
    }

    .vdocp-resume-buttons > button:last-child {
        margin-bottom: 0;
    }
    
    .vdocp-resume-lesson-info {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
        text-align: center;
    }

    /* gap 대체: column 방향일 때 margin 변경 */
    .vdocp-resume-lesson-info > * {
        margin-right: 0;
        margin-bottom: 10px;
    }

    .vdocp-resume-lesson-info > *:last-child {
        margin-bottom: 0;
    }
    
    .vdocp-resume-lesson-icon {
        font-size: 40px;
    }
}

/* ========================================
   다크 테마 지원
   ======================================== */

.bb-dark-theme .vdocp-resume-popup,
.dark-mode .vdocp-resume-popup,
[data-theme="dark"] .vdocp-resume-popup {
    background: #1f2937;
}

.bb-dark-theme .vdocp-resume-title,
.dark-mode .vdocp-resume-title,
[data-theme="dark"] .vdocp-resume-title {
    color: #f9fafb;
}

.bb-dark-theme .vdocp-resume-message,
.dark-mode .vdocp-resume-message,
[data-theme="dark"] .vdocp-resume-message {
    color: #9ca3af;
}

.bb-dark-theme .vdocp-resume-no,
.dark-mode .vdocp-resume-no,
[data-theme="dark"] .vdocp-resume-no {
    background: #374151;
    color: #d1d5db;
}

.bb-dark-theme .vdocp-resume-no:hover,
.dark-mode .vdocp-resume-no:hover,
[data-theme="dark"] .vdocp-resume-no:hover {
    background: #4b5563;
}

.bb-dark-theme .vdocp-resume-lesson-info,
.dark-mode .vdocp-resume-lesson-info,
[data-theme="dark"] .vdocp-resume-lesson-info {
    background: #374151;
}

.bb-dark-theme .vdocp-resume-lesson-title,
.dark-mode .vdocp-resume-lesson-title,
[data-theme="dark"] .vdocp-resume-lesson-title {
    color: #f9fafb;
}

.bb-dark-theme .vdocp-resume-lesson-progress,
.dark-mode .vdocp-resume-lesson-progress,
[data-theme="dark"] .vdocp-resume-lesson-progress {
    color: #9ca3af;
}

/* ========================================
   접근성
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .vdocp-completion-notice,
    .vdocp-resume-overlay,
    .vdocp-resume-popup {
        -webkit-animation: none !important;
        animation: none !important;
    }
    
    .vdocp-hidden-until-complete {
        -webkit-transition: none !important;
        transition: none !important;
    }
}

.vdocp-resume-buttons button:focus {
    outline: 3px solid #3DBAB0;
    outline-offset: 2px;
}

/* iOS Safari 포커스 스타일 */
.vdocp-resume-buttons button:focus-visible {
    outline: 3px solid #3DBAB0;
    outline-offset: 2px;
}

/* ========================================
   동시 재생 경고 알림
   ======================================== */

.vdocp-concurrent-warning {
    position: fixed;
    top: 20px;
    left: 50%;
    -webkit-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    transform: translateX(-50%);
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    background: -webkit-linear-gradient(315deg, #f59e0b 0%, #d97706 100%);
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    padding: 16px 20px;
    border-radius: 12px;
    -webkit-box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
    z-index: 1000000;
    max-width: 90%;
    -webkit-animation: vdocpSlideDown 0.4s ease;
    animation: vdocpSlideDown 0.4s ease;
}

/* gap 대체: margin 사용 */
.vdocp-concurrent-warning > * {
    margin-right: 12px;
}

.vdocp-concurrent-warning > *:last-child {
    margin-right: 0;
}

.vdocp-warning-icon {
    font-size: 24px;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.vdocp-warning-content {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
}

.vdocp-warning-message {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.vdocp-warning-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    -webkit-transition: background 0.2s ease;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.vdocp-warning-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.vdocp-warning-close:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.vdocp-warning-close:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

@-webkit-keyframes vdocpSlideDown {
    from {
        opacity: 0;
        -webkit-transform: translateX(-50%) translateY(-20px);
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateX(-50%) translateY(0);
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes vdocpSlideDown {
    from {
        opacity: 0;
        -webkit-transform: translateX(-50%) translateY(-20px);
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateX(-50%) translateY(0);
        transform: translateX(-50%) translateY(0);
    }
}

/* 모바일용 슬라이드 다운 애니메이션 (translateX 없음) */
@-webkit-keyframes vdocpSlideDownMobile {
    from {
        opacity: 0;
        -webkit-transform: translateY(-20px);
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}

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

/* 모바일 반응형 */
@media screen and (max-width: 768px) {
    .vdocp-concurrent-warning {
        top: 10px;
        left: 10px;
        right: 10px;
        -webkit-transform: none;
        -ms-transform: none;
        transform: none;
        max-width: none;
        -webkit-animation: vdocpSlideDownMobile 0.4s ease;
        animation: vdocpSlideDownMobile 0.4s ease;
    }
}

/* 다크 테마 */
.bb-dark-theme .vdocp-concurrent-warning,
.dark-mode .vdocp-concurrent-warning,
[data-theme="dark"] .vdocp-concurrent-warning {
    -webkit-box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* ========================================
   커스텀 Mark Complete 버튼
   (Video Progression ON 시 주입)
   ======================================== */

#vdocp-mark-complete-btn,
.vdocp-mark-complete-btn {
    display: inline-block;
    background: -webkit-linear-gradient(315deg, #3DBAB0 0%, #2FA89E 100%);
    background: linear-gradient(135deg, #3DBAB0 0%, #2FA89E 100%);
    color: #ffffff !important;
    border: none;
    border-radius: 6px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    white-space: nowrap;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    -webkit-box-shadow: 0 2px 8px rgba(61, 186, 176, 0.3);
    box-shadow: 0 2px 8px rgba(61, 186, 176, 0.3);
    text-decoration: none !important;
}

#vdocp-mark-complete-btn:hover,
.vdocp-mark-complete-btn:hover {
    background: -webkit-linear-gradient(315deg, #2FA89E 0%, #268F86 100%);
    background: linear-gradient(135deg, #2FA89E 0%, #268F86 100%);
    -webkit-box-shadow: 0 4px 14px rgba(61, 186, 176, 0.45);
    box-shadow: 0 4px 14px rgba(61, 186, 176, 0.45);
    -webkit-transform: translateY(-1px);
    -ms-transform: translateY(-1px);
    transform: translateY(-1px);
}

#vdocp-mark-complete-btn:active,
.vdocp-mark-complete-btn:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    -webkit-box-shadow: 0 2px 6px rgba(61, 186, 176, 0.3);
    box-shadow: 0 2px 6px rgba(61, 186, 176, 0.3);
}

#vdocp-mark-complete-btn:disabled,
.vdocp-mark-complete-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    -webkit-transform: none;
    -ms-transform: none;
    transform: none;
}

/* 완료된 상태 (회색) */
#vdocp-mark-complete-btn.vdocp-btn-completed,
.vdocp-mark-complete-btn.vdocp-btn-completed {
    background: #9ca3af;
    -webkit-box-shadow: none;
    box-shadow: none;
    cursor: default;
    pointer-events: none;
}

#vdocp-mark-complete-btn.vdocp-btn-completed:hover,
.vdocp-mark-complete-btn.vdocp-btn-completed:hover {
    background: #9ca3af;
    -webkit-box-shadow: none;
    box-shadow: none;
    -webkit-transform: none;
    -ms-transform: none;
    transform: none;
}

/* Focus Mode 헤더 내 버튼 위치 조정 */
.ld-content-action .vdocp-mark-complete-btn,
.vdocp-injected-action .vdocp-mark-complete-btn {
    margin: 0 12px;
    padding: 8px 20px;
    font-size: 13px;
}

/* 본문 영역 폴백 래퍼 */
.vdocp-injected-button-wrapper {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    margin: 20px 0;
    padding: 15px;
}

.vdocp-injected-button-wrapper .vdocp-mark-complete-btn {
    padding: 14px 36px;
    font-size: 16px;
    border-radius: 8px;
}

/* 모바일 반응형 */
@media screen and (max-width: 768px) {
    #vdocp-mark-complete-btn,
    .vdocp-mark-complete-btn {
        padding: 8px 16px;
        font-size: 12px;
    }

    .ld-content-action .vdocp-mark-complete-btn,
    .vdocp-injected-action .vdocp-mark-complete-btn {
        margin: 0 8px;
    }

    .vdocp-injected-button-wrapper .vdocp-mark-complete-btn {
        padding: 12px 28px;
        font-size: 14px;
        width: 100%;
        text-align: center;
    }
}

@media screen and (max-width: 480px) {
    .ld-content-action .vdocp-mark-complete-btn,
    .vdocp-injected-action .vdocp-mark-complete-btn {
        margin: 0 6px;
        padding: 6px 12px;
        font-size: 11px;
    }

    .vdocp-resume-popup {
        padding: 20px 16px;
        border-radius: 12px;
    }

    .vdocp-resume-title {
        font-size: 17px;
        margin-bottom: 16px;
    }

    .vdocp-resume-message {
        font-size: 13px;
        margin-bottom: 20px;
    }

    .vdocp-resume-buttons button {
        padding: 12px 16px;
        font-size: 14px;
    }

    .vdocp-resume-lesson-info {
        padding: 12px 16px;
        margin-bottom: 20px;
    }

    .vdocp-resume-lesson-title {
        font-size: 13px;
    }

    .vdocp-resume-lesson-progress {
        font-size: 12px;
    }

    .vdocp-concurrent-warning {
        padding: 12px 14px;
        border-radius: 10px;
    }

    .vdocp-warning-message {
        font-size: 12px;
    }

    .vdocp-completion-notice {
        padding: 8px 10px;
        border-radius: 6px;
    }

    .vdocp-notice-icon {
        width: 22px;
        height: 22px;
        font-size: 11px;
        margin-right: 8px;
    }

    .vdocp-notice-text {
        font-size: 11px;
    }
}
