/**
 * Mini-Interactions Panel Styling
 * Beautiful, modern design for interactive activities
 */

/* ============================================
   MINI-INTERACTIONS PANEL
   ============================================ */

.mini-interactions-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 360px;
  max-height: 280px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 900;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.mini-interactions-panel.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.mini-interactions-panel.collapsed .panel-content {
  max-height: 0;
  padding: 0;
  opacity: 0;
}

.mini-interactions-panel.collapsed {
  max-height: 60px;
}

.mini-interactions-panel.collapsed .panel-collapse-btn span {
  transform: rotate(180deg);
}

/* Panel Header */
.mini-interactions-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  user-select: none;
}

.mini-interactions-panel .panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.mini-interactions-panel .panel-icon {
  font-size: 18px;
  animation: float 3s ease-in-out infinite;
}

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

.mini-interactions-panel .panel-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.mini-interactions-panel .panel-collapse-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-interactions-panel .panel-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.mini-interactions-panel .panel-collapse-btn span {
  transition: transform 0.3s ease;
  display: inline-block;
}

/* Panel Content */
.mini-interactions-panel .panel-content {
  padding: 12px;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-interactions-panel .panel-content::-webkit-scrollbar {
  width: 6px;
}

.mini-interactions-panel .panel-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 3px;
}

.mini-interactions-panel .panel-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.mini-interactions-panel .panel-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* ============================================
   INTERACTION TILES
   ============================================ */

.interaction-tile {
  position: relative;
  width: calc(50% - 4px);
  min-height: 80px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.interaction-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  border-color: #667eea;
}

.interaction-tile.ready {
  background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
}

.interaction-tile.failed {
  background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
  opacity: 0.7;
  cursor: not-allowed;
}

.interaction-tile.generating {
  background: linear-gradient(135deg, #dfe6e9 0%, #b2bec3 100%);
  cursor: wait;
}

/* Glow effect for task execution */
.interaction-tile.glowing {
  animation: glow-pulse 5s ease-in-out;
}

@keyframes glow-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    border-color: transparent;
  }
  10%, 30%, 50% {
    box-shadow: 
      0 0 20px rgba(102, 126, 234, 0.5),
      0 0 40px rgba(102, 126, 234, 0.3),
      0 0 60px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
  }
  20%, 40% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    border-color: transparent;
  }
}

/* Tile Content */
.tile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tile-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tile-status.ready {
  background: rgba(16, 185, 129, 0.2);
  color: #059669;
}

.tile-status.generating {
  background: rgba(59, 130, 246, 0.2);
  color: #2563eb;
}

.tile-status.failed {
  background: rgba(239, 68, 68, 0.2);
  color: #dc2626;
}

.tile-dismiss {
  background: rgba(0, 0, 0, 0.1);
  border: none;
  color: rgba(0, 0, 0, 0.6);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tile-dismiss:hover {
  background: rgba(0, 0, 0, 0.2);
  color: rgba(0, 0, 0, 0.8);
}

.tile-objective {
  font-size: 13px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.85);
  line-height: 1.4;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-priority {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.5);
  font-weight: 500;
}

.tile-priority.high {
  color: #dc2626;
}

.tile-priority.medium {
  color: #f59e0b;
}

.tile-priority.low {
  color: #6b7280;
}

/* Loading animation for generating tiles */
.interaction-tile.generating::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ============================================
   INTERACTION MODAL (FULL-SCREEN)
   ============================================ */

.interaction-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

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

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.modal-container {
  position: relative;
  width: 90%;
  max-width: 1200px;
  height: 90vh;
  max-height: 800px;
  background: white;
  border-radius: 20px;
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.25),
    0 10px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-slide-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-slide-in {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

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

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

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

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

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

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

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

/* Modal content sandbox styling */
.modal-content iframe {
  border: none;
  width: 100%;
  height: 100%;
  min-height: 600px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

@media (max-width: 768px) {
  .mini-interactions-panel {
    bottom: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-width: none;
  }

  .interaction-tile {
    width: 100%;
  }

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

  .modal-header {
    padding: 16px 20px;
  }

  .modal-title {
    font-size: 18px;
  }

  .modal-content {
    padding: 20px;
  }
}

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

.interaction-tile:focus,
.modal-close-btn:focus,
.panel-collapse-btn:focus,
.tile-dismiss:focus {
  outline: 3px solid #667eea;
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .mini-interactions-panel,
  .interaction-tile,
  .modal-container,
  .panel-collapse-btn span,
  .tile-dismiss {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================
   LOCKED/UNLOCKED STATES
   ============================================ */

/* Locked tile (task not yet executed) */
.interaction-tile.locked {
  opacity: 0.5;
  filter: grayscale(70%);
  position: relative;
}

.interaction-tile.locked:hover {
  transform: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.interaction-tile.locked .tile-objective {
  color: #9ca3af;
}

/* Lock indicator */
.tile-lock-indicator {
  position: absolute;
  bottom: 8px;
  left: 12px;
  right: 12px;
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  font-weight: 500;
}

/* Unlocked tile (task executed) */
.interaction-tile.unlocked {
  opacity: 1;
  filter: none;
}

/* Shake animation for locked tiles when clicked */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-4px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(4px);
  }
}

/* ============================================
   VIEW CODE BUTTON & CODE MODAL
   ============================================ */

/* Modal Header Actions (View Code and Retry buttons) */
.modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-view-code-btn,
.modal-retry-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;
}

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

.modal-view-code-btn svg,
.modal-retry-btn svg {
  flex-shrink: 0;
}

/* Retry button specific styling */
.modal-retry-btn {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.4);
}

.modal-retry-btn:hover {
  background: rgba(248, 113, 113, 0.3);
  border-color: rgba(248, 113, 113, 0.6);
}

.modal-retry-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.modal-retry-btn.hidden {
  display: none;
}

/* Code View Modal */
.code-view-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;
}

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

.code-modal-container {
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
}

.code-content {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 20px;
  border-radius: 8px;
  overflow: auto;
  max-height: calc(90vh - 120px);
  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;
}

