/**
 * MongDaoVien Content Protection Styles
 * CSS cho hệ thống chống copy/leak nội dung
 */

/* ===== BASE PROTECTION STYLES ===== */
.content-protected,
.msv-khung-truyen-noi-dung,
#noi_dung_truyen,
.watermarked-content {
    /* Disable text selection */
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    
    /* Disable touch callouts on mobile */
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    
    /* Disable drag */
    -webkit-user-drag: none !important;
    -khtml-user-drag: none !important;
    -moz-user-drag: none !important;
    -o-user-drag: none !important;
    user-drag: none !important;
    
    /* Prevent highlighting */
    outline: none !important;
}

/* Remove selection highlighting */
.content-protected::selection,
.msv-khung-truyen-noi-dung::selection,
#noi_dung_truyen::selection,
.watermarked-content::selection {
    background: transparent !important;
    color: inherit !important;
}

.content-protected::-moz-selection,
.msv-khung-truyen-noi-dung::-moz-selection,
#noi_dung_truyen::-moz-selection,
.watermarked-content::-moz-selection {
    background: transparent !important;
    color: inherit !important;
}

/* ===== IMAGE PROTECTION ===== */
.content-protected img,
.msv-khung-truyen-noi-dung img,
#noi_dung_truyen img,
.watermarked-content img {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
    -khtml-user-drag: none !important;
    -moz-user-drag: none !important;
    -o-user-drag: none !important;
    user-drag: none !important;
    pointer-events: auto !important; /* Allow normal interaction but prevent dragging */
}

/* Prevent image context menu */
.content-protected img::-webkit-media-controls,
.msv-khung-truyen-noi-dung img::-webkit-media-controls,
#noi_dung_truyen img::-webkit-media-controls {
    display: none !important;
}

/* ===== WATERMARK STYLES ===== */
.watermark-container {
    position: relative;
    overflow: hidden;
}

.watermark-overlay {
    position: relative;
    overflow: hidden;
}

.watermark-overlay::before {
    content: attr(data-watermark);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    font-size: 16px;
    color: rgba(252, 172, 163, 0.08) !important; /* Main color with low opacity */
    pointer-events: none;
    z-index: 1;
    line-height: 80px;
    white-space: pre-wrap;
    word-break: break-all;
    transform: rotate(-15deg);
    font-weight: 500;
    letter-spacing: 3px;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 120px,
        rgba(252, 172, 163, 0.03) 120px,
        rgba(252, 172, 163, 0.03) 240px
    );
}

.watermark-overlay::after {
    content: 'MongDaoVien.com - Bản quyền được bảo vệ';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-20deg);
    font-size: 14px;
    color: rgba(191, 35, 35, 0.06) !important; /* Second text color with low opacity */
    pointer-events: none;
    z-index: 2;
    font-weight: bold;
    letter-spacing: 2px;
    white-space: nowrap;
}

/* Dynamic watermarks */
.dynamic-watermark {
    position: absolute;
    font-size: 12px;
    color: rgba(255, 97, 102, 0.08) !important; /* Second main color */
    pointer-events: none;
    z-index: 3;
    font-weight: 600;
    transform: rotate(-25deg);
    user-select: none;
    white-space: nowrap;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

/* ===== PROTECTION BLUR EFFECTS ===== */
.content-blur {
    filter: blur(8px) !important;
    transition: filter 0.3s ease;
}

.content-protected-blur {
    filter: blur(15px) brightness(0.7) !important;
    transition: filter 0.5s ease;
}

/* ===== PROTECTION MESSAGES ===== */
.protection-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.3);
    z-index: 10000;
    font-size: 14px;
    font-weight: 500;
    max-width: 320px;
    animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
}

.protection-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    color: white;
    font-size: 24px;
    text-align: center;
    backdrop-filter: blur(5px);
}

.protection-warning-content {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    max-width: 500px;
    animation: scaleIn 0.5s ease-out;
}

.protection-warning-icon {
    font-size: 64px;
    color: #e74c3c;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

/* ===== ANIMATIONS ===== */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ===== ANTI-SCREENSHOT PROTECTION ===== */
.anti-screenshot {
    position: relative;
}

.anti-screenshot::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(252, 172, 163, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 97, 102, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(191, 35, 35, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
}

/* ===== MOBILE SPECIFIC PROTECTION ===== */
@media (max-width: 768px) {
    .content-protected,
    .msv-khung-truyen-noi-dung,
    #noi_dung_truyen,
    .watermarked-content {
        /* Enhanced mobile protection */
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
    }
    
    .protection-toast {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 13px;
        padding: 12px 16px;
    }
    
    .watermark-overlay::before {
        font-size: 12px;
        line-height: 60px;
    }
    
    .watermark-overlay::after {
        font-size: 10px;
    }
}

/* ===== PRINT PROTECTION ===== */
@media print {
    .content-protected,
    .msv-khung-truyen-noi-dung,
    #noi_dung_truyen,
    .watermarked-content {
        display: none !important;
    }
    
    .content-protected::after,
    .msv-khung-truyen-noi-dung::after,
    #noi_dung_truyen::after {
        content: "Nội dung được bảo vệ bởi bản quyền - Không được phép in";
        display: block !important;
        text-align: center;
        font-size: 24px;
        color: #e74c3c;
        padding: 50px;
        border: 3px solid #e74c3c;
        margin: 20px 0;
    }
}

/* ===== HIGH CONTRAST / ACCESSIBILITY OVERRIDE PROTECTION ===== */
@media (prefers-contrast: high) {
    .content-protected,
    .msv-khung-truyen-noi-dung,
    #noi_dung_truyen,
    .watermarked-content {
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        user-select: none !important;
    }
}

/* ===== DEVELOPER TOOLS DETECTION STYLES ===== */
.devtools-detected {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: #2c3e50 !important;
    color: white !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
    font-size: 20px !important;
    text-align: center !important;
}

/* ===== CONTENT CHUNK LOADING ===== */
.content-chunk {
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

.content-chunk:nth-child(odd) {
    animation-delay: 0.1s;
}

.content-chunk:nth-child(even) {
    animation-delay: 0.2s;
}

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

/* ===== ENHANCED WATERMARK FOR VIP CONTENT ===== */
.doc-quyen .watermark-overlay::before {
    background-image: 
        repeating-linear-gradient(
            45deg,
            rgba(252, 172, 163, 0.05),
            rgba(252, 172, 163, 0.05) 100px,
            rgba(255, 97, 102, 0.05) 100px,
            rgba(255, 97, 102, 0.05) 200px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 150px,
            rgba(191, 35, 35, 0.03) 150px,
            rgba(191, 35, 35, 0.03) 300px
        );
    font-size: 18px;
    line-height: 100px;
}

.doc-quyen .watermark-overlay::after {
    content: '🔒 ĐỘC QUYỀN - MONGDAOVIEN.COM 🔒';
    font-size: 16px;
    color: rgba(191, 35, 35, 0.1) !important;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
}

/* ===== CURSOR PROTECTION ===== */
.content-protected,
.msv-khung-truyen-noi-dung,
#noi_dung_truyen,
.watermarked-content {
    cursor: default !important;
}

.content-protected *,
.msv-khung-truyen-noi-dung *,
#noi_dung_truyen *,
.watermarked-content * {
    cursor: inherit !important;
}

/* ===== FOCUS PROTECTION ===== */
.content-protected:focus,
.msv-khung-truyen-noi-dung:focus,
#noi_dung_truyen:focus,
.watermarked-content:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* ===== LOADING PROTECTION ===== */
.content-loading {
    position: relative;
    min-height: 200px;
}

.content-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(252, 172, 163, 0.3);
    border-top: 4px solid #fcaca3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}
