/**
 * Sensitive Content Security & Protection Styles
 * 
 * Implements comprehensive front-end security for NDA-protected content:
 * - Permanent NDA watermarking
 * - User-specific traceability overlays
 * - Anti-screenshot interaction limitations
 * - Visual security indicators
 * 
 * IMPORTANT: These protections make screenshots inconvenient but not impossible.
 * All content is legally protected by NDA between Anabta FZE and Jamal Youness.
 */

/* ==============================================
   CORE SENSITIVE CONTENT WRAPPER
   ============================================== */

.sensitive-content {
  position: relative;
  isolation: isolate; /* Create stacking context */
  
  /* Disable text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  
  /* Disable drag for images and text */
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  
  /* Disable image dragging */
  -webkit-touch-callout: none;
  
  /* Prevent pointer events on watermark layers */
  pointer-events: auto;
}

.sensitive-content * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  
  -webkit-user-drag: none;
  user-drag: none;
}

.sensitive-content img,
.sensitive-content canvas,
.sensitive-content video {
  /* Prevent dragging media elements */
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
}

/* ==============================================
   PERMANENT NDA WATERMARK OVERLAY
   ============================================== */

.sensitive-content::before {
  content: 'CONFIDENTIAL – DATA PROTECTED BY NDA';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9998;
  
  /* Diagonal repeated pattern */
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 200px,
    rgba(220, 38, 38, 0.08) 200px,
    rgba(220, 38, 38, 0.08) 400px
  );
  
  /* Text styling */
  font-family: 'Arial Black', 'Helvetica Bold', sans-serif;
  font-size: clamp(24px, 3vw, 48px);
  font-weight: 900;
  color: rgba(220, 38, 38, 0.25);
  text-shadow: 
    1px 1px 2px rgba(255, 255, 255, 0.8),
    -1px -1px 2px rgba(255, 255, 255, 0.8),
    2px 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  
  /* Centering */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  
  /* Prevent interaction */
  pointer-events: none;
  user-select: none;
  
  /* Rotation for diagonal effect */
  transform: rotate(-15deg);
  
  /* Line breaks for multi-line display */
  white-space: pre-wrap;
  line-height: 1.4;
}

/* Large centered watermark variant */
.sensitive-content.watermark-large::before {
  font-size: clamp(32px, 5vw, 72px);
  opacity: 0.3;
  transform: rotate(-20deg);
}

/* Tiled watermark pattern variant */
.sensitive-content.watermark-tiled::before {
  content: '';
  background-image: repeating-linear-gradient(
    45deg,
    transparent 0px,
    transparent 150px,
    rgba(220, 38, 38, 0.05) 150px,
    rgba(220, 38, 38, 0.05) 151px,
    transparent 151px,
    transparent 250px
  ),
  repeating-linear-gradient(
    -45deg,
    transparent 0px,
    transparent 150px,
    rgba(220, 38, 38, 0.05) 150px,
    rgba(220, 38, 38, 0.05) 151px,
    transparent 151px,
    transparent 250px
  );
  font-size: 0; /* Hide text, use only background pattern */
}

.sensitive-content.watermark-tiled::after {
  content: 'CONFIDENTIAL – DATA PROTECTED BY NDA';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9998;
  
  /* Repeating tiled text */
  font-family: 'Arial', sans-serif;
  font-size: 14px;
  font-weight: bold;
  color: rgba(220, 38, 38, 0.15);
  line-height: 80px;
  text-align: left;
  
  /* Create tiled effect */
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 79px,
    currentColor 79px,
    currentColor 80px
  );
  background-size: 100% 80px;
  
  pointer-events: none;
  user-select: none;
  overflow: hidden;
}

/* ==============================================
   USER-SPECIFIC DYNAMIC WATERMARK
   ============================================== */

.sensitive-content .user-watermark-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
  
  /* Tiled pattern background */
  background: 
    repeating-linear-gradient(
      60deg,
      transparent,
      transparent 250px,
      rgba(59, 130, 246, 0.03) 250px,
      rgba(59, 130, 246, 0.03) 500px
    );
}

.sensitive-content .user-watermark-text {
  position: absolute;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  font-weight: bold;
  color: rgba(59, 130, 246, 0.2);
  text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  transform: rotate(-30deg);
  pointer-events: none;
  user-select: none;
}

/* Position user watermarks in a grid pattern */
.sensitive-content .user-watermark-text:nth-child(1) { top: 5%; left: 5%; }
.sensitive-content .user-watermark-text:nth-child(2) { top: 5%; right: 5%; }
.sensitive-content .user-watermark-text:nth-child(3) { top: 30%; left: 15%; }
.sensitive-content .user-watermark-text:nth-child(4) { top: 30%; right: 15%; }
.sensitive-content .user-watermark-text:nth-child(5) { top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-30deg); }
.sensitive-content .user-watermark-text:nth-child(6) { top: 70%; left: 15%; }
.sensitive-content .user-watermark-text:nth-child(7) { top: 70%; right: 15%; }
.sensitive-content .user-watermark-text:nth-child(8) { bottom: 5%; left: 5%; }
.sensitive-content .user-watermark-text:nth-child(9) { bottom: 5%; right: 5%; }

/* ==============================================
   CLICK-TO-REVEAL / MASKED CONTENT
   ============================================== */

.sensitive-field {
  position: relative;
  display: inline-block;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sensitive-field.masked .field-value {
  filter: blur(8px);
  opacity: 0.5;
  user-select: none;
  pointer-events: none;
}

.sensitive-field.masked::after {
  content: '👁️ Click to reveal';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(59, 130, 246, 0.9);
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

.sensitive-field.revealed .field-value {
  filter: none;
  opacity: 1;
  background: rgba(34, 197, 94, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  border: 2px solid rgba(34, 197, 94, 0.3);
}

.sensitive-field.auto-hiding::before {
  content: 'Auto-hiding in ' attr(data-countdown) 's';
  position: absolute;
  top: -25px;
  right: 0;
  background: rgba(234, 179, 8, 0.9);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 10;
}

/* ==============================================
   SECURE VIEW MODE (BLUR ON IDLE/TAB SWITCH)
   ============================================== */

.sensitive-content.secure-view-blurred {
  filter: blur(20px);
  opacity: 0.3;
  transition: filter 0.5s ease, opacity 0.5s ease;
  pointer-events: none;
}

.sensitive-content.secure-view-blurred::after {
  content: '🔒 Content Hidden\AClick to reveal (auto-hides after idle)';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(220, 38, 38, 0.95);
  color: white;
  padding: 20px 40px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  white-space: pre-wrap;
  z-index: 10000;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.secure-view-indicator {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  background: rgba(34, 197, 94, 0.95);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideInRight 0.3s ease;
}

.secure-view-indicator.warning {
  background: rgba(234, 179, 8, 0.95);
}

.secure-view-indicator.danger {
  background: rgba(220, 38, 38, 0.95);
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ==============================================
   WARNING BANNER
   ============================================== */

.nda-warning-banner {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.95) 0%, rgba(185, 28, 28, 0.95) 100%);
  color: white;
  padding: 16px 24px;
  border-left: 6px solid rgba(255, 255, 255, 0.9);
  margin-bottom: 24px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.nda-warning-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(255, 255, 255, 0.05) 10px,
    rgba(255, 255, 255, 0.05) 20px
  );
  pointer-events: none;
}

.nda-warning-banner .banner-icon {
  font-size: 28px;
  margin-right: 16px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.nda-warning-banner .banner-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.5px;
}

.nda-warning-banner .banner-text {
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.95;
  font-weight: 500;
}

.nda-warning-banner .banner-text strong {
  font-weight: 800;
  text-decoration: underline;
}

/* ==============================================
   SCREENSHOT DETECTION TOAST
   ============================================== */

.screenshot-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 999999;
  background: rgba(220, 38, 38, 0.98);
  color: white;
  padding: 24px 40px;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  text-align: center;
  animation: toastAppear 0.3s ease forwards;
  max-width: 500px;
  border: 3px solid rgba(255, 255, 255, 0.9);
}

@keyframes toastAppear {
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

.screenshot-toast .toast-icon {
  font-size: 48px;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.screenshot-toast .toast-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 12px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.screenshot-toast .toast-message {
  font-size: 16px;
  line-height: 1.5;
  font-weight: 600;
  opacity: 0.95;
}

/* ==============================================
   NDA MODAL / REMINDER
   ============================================== */

.nda-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 999998;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

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

.nda-modal {
  background: white;
  border-radius: 16px;
  box-shadow: 0 24px 96px rgba(0, 0, 0, 0.6);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalSlideUp 0.4s ease;
  position: relative;
}

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

.nda-modal-header {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: white;
  padding: 24px 32px;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  position: relative;
  overflow: hidden;
}

.nda-modal-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 15px,
    rgba(255, 255, 255, 0.05) 15px,
    rgba(255, 255, 255, 0.05) 30px
  );
}

.nda-modal-header .modal-icon {
  font-size: 48px;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.nda-modal-header .modal-title {
  font-size: 28px;
  font-weight: 800;
  margin: 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
}

.nda-modal-body {
  padding: 32px;
}

.nda-modal-body .nda-text {
  font-size: 15px;
  line-height: 1.8;
  color: #374151;
  margin-bottom: 24px;
  text-align: justify;
  border-left: 4px solid #dc2626;
  padding-left: 20px;
  background: rgba(220, 38, 38, 0.02);
  padding: 20px;
  border-radius: 8px;
}

.nda-modal-body .nda-text strong {
  color: #dc2626;
  font-weight: 700;
}

.nda-checkbox-wrapper {
  display: flex;
  align-items: start;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(59, 130, 246, 0.05);
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nda-checkbox-wrapper:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.4);
}

.nda-checkbox-wrapper input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.nda-checkbox-wrapper label {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
  line-height: 1.5;
  user-select: none;
}

.nda-modal-footer {
  padding: 0 32px 32px 32px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.nda-modal-button {
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}

.nda-modal-button.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.nda-modal-button.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.nda-modal-button.primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
}

.nda-modal-button.secondary {
  background: #e5e7eb;
  color: #374151;
}

.nda-modal-button.secondary:hover {
  background: #d1d5db;
}

/* ==============================================
   DARK MODE SUPPORT
   ============================================== */

.dark .sensitive-content::before {
  color: rgba(248, 113, 113, 0.25);
  text-shadow: 
    1px 1px 2px rgba(0, 0, 0, 0.8),
    -1px -1px 2px rgba(0, 0, 0, 0.8),
    2px 2px 4px rgba(255, 255, 255, 0.2);
}

.dark .user-watermark-text {
  color: rgba(96, 165, 250, 0.25);
  text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.8);
}

.dark .nda-modal {
  background: #1f2937;
  color: #f3f4f6;
}

.dark .nda-modal-body .nda-text {
  color: #d1d5db;
  background: rgba(220, 38, 38, 0.05);
}

.dark .nda-checkbox-wrapper {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}

.dark .nda-checkbox-wrapper:hover {
  background: rgba(59, 130, 246, 0.15);
}

.dark .nda-checkbox-wrapper label {
  color: #f3f4f6;
}

/* ==============================================
   PRINT PROTECTION
   ============================================== */

@media print {
  .sensitive-content::before {
    opacity: 0.5 !important;
    font-size: 48px !important;
  }
  
  .user-watermark-overlay {
    display: block !important;
    opacity: 0.3 !important;
  }
}

/* ==============================================
   ACCESSIBILITY
   ============================================== */

.sensitive-content:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.5);
  outline-offset: 4px;
}

.nda-modal-button:focus-visible,
.nda-checkbox-wrapper:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.5);
  outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
