/**
 * Mylawyers Content Guard - Frontend Security Styles
 */

/* 1. Disable text selection and mobile callouts */
body.ml-guard-protected,
body.ml-guard-protected * {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

/* Allow interactive elements to receive full touch/click events */
body.ml-guard-protected input,
body.ml-guard-protected textarea,
body.ml-guard-protected select,
body.ml-guard-protected button,
body.ml-guard-protected a,
body.ml-guard-protected [role="button"],
body.ml-guard-protected [role="tab"] {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    pointer-events: auto !important;
}

/* Prevent image dragging without breaking click events */
body.ml-guard-protected img {
    -webkit-user-drag: none !important;
    pointer-events: auto;
}

/* 2. Anti-Screenshot Blank Page Screen Overlay (Mobile & Desktop) */
#ml-guard-blank-screen {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #ffffff !important;
    z-index: 2147483647 !important; /* Maximum 32-bit integer z-index */
    pointer-events: none;
    opacity: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
}

html.ml-guard-blank-active #ml-guard-blank-screen,
body.ml-guard-blank-active #ml-guard-blank-screen {
    display: block !important;
    opacity: 1 !important;
    pointer-events: all !important;
}

html.ml-guard-blank-active,
html.ml-guard-blank-active body,
body.ml-guard-blank-active {
    background: #ffffff !important;
    overflow: hidden !important;
}

/* Instantly eliminate all page contents during blank screen activation */
html.ml-guard-blank-active body > *:not(#ml-guard-blank-screen),
body.ml-guard-blank-active > *:not(#ml-guard-blank-screen) {
    opacity: 0 !important;
    visibility: hidden !important;
    transition: none !important;
}

/* Secondary anti-screenshot focus blur */
body.ml-guard-blurred {
    filter: blur(25px) grayscale(100%) !important;
    transition: filter 0.05s ease-out;
}

/* Blackout veil for printscreen/focus loss */
#ml-guard-blackout-veil {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    z-index: 99999999;
    color: #333333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

#ml-guard-blackout-veil.active {
    display: flex;
}

.ml-veil-content {
    max-width: 400px;
}

.ml-veil-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    stroke: #c59d5f;
}

.ml-veil-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #fff;
}

.ml-veil-text {
    font-size: 13px;
    color: #a0aec0;
    line-height: 1.5;
}

/* 3. Forensic Watermark Canvas Overlay */
#ml-guard-watermark-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 999998;
}

/* ==========================================================================
   DEVELOPER TOOLS RESTRICTION POPUP MODAL (REPLACES BROWSER DEBUGGER)
   ========================================================================== */
#ml-guard-devtools-popup {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.78) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    backdrop-filter: blur(14px) !important;
    z-index: 2147483646 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 24px 16px !important;
    box-sizing: border-box !important;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

#ml-guard-devtools-popup.active {
    display: flex !important;
    opacity: 1 !important;
}

.ml-devtools-modal {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 24px !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08) !important;
    padding: 32px 24px 26px !important;
    max-width: 360px !important;
    width: 100% !important;
    text-align: center !important;
    position: relative !important;
    transform: scale(0.92) translateY(12px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    box-sizing: border-box !important;
}

#ml-guard-devtools-popup.active .ml-devtools-modal {
    transform: scale(1) translateY(0);
}

.ml-devtools-icon-wrap {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.18) 0%, rgba(220, 38, 38, 0.32) 100%);
    border: 1.5px solid rgba(239, 68, 68, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

.ml-devtools-icon {
    width: 32px;
    height: 32px;
    stroke: #ef4444;
}

.ml-devtools-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    letter-spacing: 0.3px;
}

.ml-devtools-title {
    font-size: 19px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    margin: 0 0 10px 0 !important;
    line-height: 1.3 !important;
}

.ml-devtools-desc {
    font-size: 13.5px !important;
    color: #cbd5e1 !important;
    line-height: 1.5 !important;
    margin: 0 0 22px 0 !important;
}

.ml-devtools-btn {
    display: block !important;
    width: 100% !important;
    padding: 12px 18px !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, #7c4dff 0%, #2563eb 100%) !important;
    color: #ffffff !important;
    font-size: 14.5px !important;
    font-weight: 600 !important;
    border: none !important;
    cursor: pointer !important;
    box-shadow: 0 6px 18px rgba(124, 77, 255, 0.45) !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    outline: none !important;
    box-sizing: border-box !important;
}

.ml-devtools-btn:hover,
.ml-devtools-btn:focus {
    background: linear-gradient(135deg, #6d38f5 0%, #1d4ed8 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 8px 22px rgba(124, 77, 255, 0.55) !important;
}

/* 4. Complete Print & Export Elimination */
@media print {
    html, body {
        background: #fff !important;
        height: 100% !important;
        overflow: hidden !important;
    }

    body * {
        display: none !important;
        visibility: hidden !important;
    }

    body::before {
        display: block !important;
        visibility: visible !important;
        content: "SECURITY ALERT: Printing, saving, or exporting this document is strictly prohibited by Mylawyers Data Protection." !important;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
        font-size: 22px !important;
        font-weight: bold !important;
        color: #b91c1c !important;
        text-align: center !important;
        margin-top: 150px !important;
        padding: 40px !important;
        border: 2px dashed #b91c1c !important;
        background: #fef2f2 !important;
    }
}
