/**
 * Content Protection Security Styles
 * probtest.kz - Professional Testing Platform
 */

/* ============================================
   PRINT PROTECTION
   ============================================ */
@media print {
  /* Hide main content during print */
  body > *:not(#print-protection-notice) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }

  /* Show copyright notice instead */
  body::before {
    content: "⚠️ ЗАЩИЩЕНО АВТОРСКИМ ПРАВОМ";
    display: block !important;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    color: #e53e3e;
    text-align: center;
    z-index: 999999;
  }

  body::after {
    content: "Материалы probtest.kz защищены законом об интеллектуальной собственности. Несанкционированное копирование, распространение или воспроизведение преследуется по закону.";
    display: block !important;
    position: fixed;
    top: 60%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    font-size: 18px;
    color: #2d3748;
    text-align: center;
    line-height: 1.6;
    z-index: 999999;
  }
}

/* ============================================
   TEXT SELECTION PROTECTION
   ============================================ */
body, body * {
  -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 selection for input fields */
input, textarea, [contenteditable="true"], .allow-select {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#security-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999998;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
}

.security-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 4px 8px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  border-left: 4px solid #f59e0b;
  max-width: 100%;
}

.security-toast-show {
  opacity: 1;
  transform: translateX(0);
}

.security-toast-warning {
  border-left-color: #f59e0b;
}

.security-toast-error {
  border-left-color: #ef4444;
}

.security-toast-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.security-toast-content {
  flex: 1;
  min-width: 0;
}

.security-toast-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 4px;
}

.security-toast-message {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
}

/* Mobile responsive */
@media (max-width: 640px) {
  #security-toast-container {
    left: 20px;
    right: 20px;
    max-width: none;
  }

  .security-toast {
    max-width: none;
  }
}

/* ============================================
   BLUR PROTECTION OVERLAY
   ============================================ */
.security-blur-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 999997;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.security-blur-overlay.active {
  opacity: 1;
  visibility: visible;
}

.security-blur-content {
  text-align: center;
  padding: 40px;
  max-width: 500px;
}

.security-blur-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: pulse 2s ease-in-out infinite;
}

.security-blur-content h2 {
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 12px;
}

.security-blur-content p {
  font-size: 16px;
  color: #6b7280;
  line-height: 1.6;
}

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

/* ============================================
   WATERMARK PROTECTION
   ============================================ */
.content-watermark {
  position: fixed;
  bottom: 10px;
  right: 10px;
  font-size: 10px;
  color: rgba(0, 0, 0, 0.1);
  pointer-events: none;
  z-index: 999996;
  font-family: monospace;
  user-select: none;
  transform: rotate(-5deg);
}

/* Prevent dragging of images */
img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* Re-enable for specific cases */
img.allow-drag {
  pointer-events: auto;
  -webkit-user-drag: auto;
}

/* ============================================
   COPY PROTECTION FOR CODE BLOCKS
   ============================================ */
pre, code {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}

/* ============================================
   HIDE SCREENSHOT INDICATORS
   ============================================ */
::selection {
  background: transparent !important;
  color: inherit !important;
}

::-moz-selection {
  background: transparent !important;
  color: inherit !important;
}

/* ============================================
   DEVTOOLS DETECTION VISUAL WARNING
   ============================================ */
@keyframes devtools-warning {
  0%, 100% {
    border-color: #ef4444;
  }
  50% {
    border-color: #f59e0b;
  }
}

.devtools-detected {
  animation: devtools-warning 1s ease-in-out infinite;
}

/* ============================================
   CURSOR PROTECTION
   ============================================ */
.no-select-cursor {
  cursor: not-allowed !important;
}

/* ============================================
   CONSOLE WARNING STYLES
   ============================================ */
.console-warning {
  display: none !important;
}

/* ============================================
   IFRAME PROTECTION
   ============================================ */
iframe {
  pointer-events: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

/* ============================================
   VIDEO PROTECTION
   ============================================ */
video {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  pointer-events: none;
}

video::-webkit-media-controls {
  pointer-events: auto;
}

/* ============================================
   ADDITIONAL SECURITY MEASURES
   ============================================ */

/* Prevent text highlighting during rapid clicks */
body {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Hide scrollbars during screenshot attempts */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ============================================
   ACCESSIBILITY OVERRIDE
   Allow screen readers but block visual copying
   ============================================ */
[aria-hidden="true"] {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  user-select: none !important;
}

/* ============================================
   PERFORMANCE OPTIMIZATION
   Ensure protection doesn't affect UX
   ============================================ */
.security-toast,
.security-blur-overlay {
  will-change: opacity, transform;
  contain: layout style paint;
}

/* ============================================
   PRINT PROTECTION NOTICE
   ============================================ */
#print-protection-notice {
  display: none;
}

@media print {
  #print-protection-notice {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 999999;
    padding: 40px;
    text-align: center;
  }
}
