/**
 * Mini-Interactions for Meets Tutor
 * Shared-screen overlay experience with auto-popup
 */

/* ============================================
   VISUAL CUE (Countdown before modal)
   ============================================ */

.interaction-cue {
  position: absolute; /* Changed from fixed - positions relative to shared-screen container */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 9998;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  /* Ensure perfect centering */
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
}

.interaction-cue.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.cue-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 32px 48px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
  /* Ensure content doesn't overflow and stays centered */
  max-width: 90vw;
  margin: 0 auto;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 25px 70px rgba(102, 126, 234, 0.5);
  }
}

.cue-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.cue-text {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.3px;
}

.cue-countdown {
  font-size: 18px;
  opacity: 0.9;
}

.countdown {
  font-weight: 700;
  font-size: 28px;
  color: #fbbf24;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ============================================
   MODAL (Large, Centered, Shared-Screen)
   ============================================ */

.meets-interaction-modal {
  position: absolute; /* Changed from fixed to absolute - positions relative to shared-screen */
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
  /* Add padding from screen share edges */
  padding: 4px 0;
}

.meets-interaction-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.interaction-backdrop {
  position: absolute;
  inset: 0;
  background: transparent; /* Changed from rgba(0, 0, 0, 0.85) to transparent */
  backdrop-filter: none; /* Removed blur effect */
  pointer-events: none; /* Allow clicks to pass through */
}

.interaction-container {
  position: relative;
  width: 85%;
  max-width: 1400px;
  height: calc(100% - 64px); /* Subtract the padding (32px top + 32px bottom) */
  max-height: 900px;
  background: white;
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  animation: modal-enter 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ============================================
   HEADER
   ============================================ */

.interaction-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px; /* Further reduced from 16px to 12px */
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 24px 24px 0 0;
}

.interaction-title-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.interaction-icon {
  font-size: 24px; /* Reduced from 32px */
  animation: float 3s ease-in-out infinite;
}

.interaction-title {
  margin: 0;
  font-size: 20px; /* Reduced from 28px */
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Header Actions */
.interaction-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.interaction-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  color: white;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.interaction-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.interaction-btn svg {
  flex-shrink: 0;
}

.interaction-close-btn {
  padding: 10px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
}

.interaction-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.interaction-close-btn:active {
  transform: scale(0.95);
}

/* ============================================
   CONTENT (JSX Render Area)
   ============================================ */

.interaction-content {
  flex: 1;
  overflow: auto;
  padding: 32px;
  background: #f8fafc;
}

.interaction-content iframe {
  width: 100%;
  height: 100%;
  min-height: 600px;
  border: none;
  border-radius: 16px;
  background: white;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.interaction-content::-webkit-scrollbar {
  width: 10px;
}

.interaction-content::-webkit-scrollbar-track {
  background: #e2e8f0;
}

.interaction-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 5px;
}

.interaction-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ============================================
   FOOTER
   ============================================ */

.interaction-footer {
  padding: 12px 32px; /* Further reduced from 16px to 12px */
  background: white;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: center;
  border-radius: 0 0 24px 24px;
}

.interaction-action-btn {
  padding: 12px 40px; /* Reduced from 14px 48px to 12px 40px */
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.interaction-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.interaction-action-btn:active {
  transform: translateY(0);
}

/* ============================================
   CODE VIEW MODAL
   ============================================ */

.interaction-code-modal {
  position: fixed;
  inset: 0;
  z-index: 10001; /* Above interaction modal */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.interaction-code-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.code-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
}

.code-container {
  position: relative;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  background: #1e1e1e;
  border-radius: 20px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: #2d2d2d;
  border-bottom: 1px solid #3d3d3d;
}

.code-header h3 {
  margin: 0;
  color: #e2e8f0;
  font-size: 18px;
  font-weight: 600;
}

.code-close-btn {
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-close-btn:hover {
  color: white;
  transform: rotate(90deg);
}

.code-content {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 24px;
  overflow: auto;
  max-height: calc(90vh - 80px);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.code-content code {
  color: inherit;
  font-family: inherit;
}

.code-content::-webkit-scrollbar {
  width: 12px;
}

.code-content::-webkit-scrollbar-track {
  background: #2d2d2d;
}

.code-content::-webkit-scrollbar-thumb {
  background: #4d4d4d;
  border-radius: 6px;
}

.code-content::-webkit-scrollbar-thumb:hover {
  background: #5d5d5d;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
  .cue-content {
    padding: 24px 32px;
  }

  .cue-icon {
    font-size: 48px;
  }

  .cue-text {
    font-size: 20px;
  }

  .cue-countdown {
    font-size: 16px;
  }

  .countdown {
    font-size: 24px;
  }

  .meets-interaction-modal {
    /* Reduce padding on mobile */
    padding: 16px 0;
  }

  .interaction-container {
    width: 95%;
    height: calc(100% - 32px); /* Subtract reduced padding (16px top + 16px bottom) */
    border-radius: 16px;
  }

  .interaction-header {
    padding: 10px 20px; /* Further reduced from 12px to 10px for mobile */
  }

  .interaction-title {
    font-size: 18px; /* Reduced from 20px for mobile */
  }

  .interaction-icon {
    font-size: 20px; /* Reduced from 24px for mobile */
  }

  .interaction-btn {
    font-size: 0.85rem;
    padding: 8px 14px;
  }

  .interaction-content {
    padding: 20px;
  }

  .interaction-action-btn {
    font-size: 16px;
    padding: 12px 36px;
  }

  .code-container {
    width: 95%;
    max-height: 95vh;
    border-radius: 16px;
  }
}

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

.interaction-btn:focus,
.interaction-close-btn:focus,
.interaction-action-btn:focus,
.code-close-btn:focus {
  outline: 3px solid #667eea;
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .interaction-cue,
  .interaction-container,
  .cue-icon,
  .interaction-icon,
  .interaction-btn,
  .interaction-close-btn,
  .code-close-btn {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================
   LOADING STATE
   ============================================ */

.interaction-loading {
  padding: 60px;
  text-align: center;
  color: #667eea;
}

.interaction-loading .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.interaction-loading h2 {
  margin: 0 0 12px 0;
  font-size: 24px;
  font-weight: 600;
}

.interaction-loading p {
  margin: 0;
  color: #6b7280;
  font-size: 16px;
}

/* ============================================
   ERROR STATE
   ============================================ */

.interaction-error {
  padding: 60px;
  text-align: center;
  color: #dc2626;
}

.interaction-error h2 {
  margin: 0 0 12px 0;
  font-size: 24px;
  font-weight: 600;
}

.interaction-error p {
  margin: 0 0 20px 0;
  color: #6b7280;
  font-size: 16px;
}

.interaction-error .retry-btn {
  padding: 12px 32px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.interaction-error .retry-btn:hover {
  background: #b91c1c;
  transform: translateY(-2px);
}

