/**
 * TableCrafter Collaboration Styles
 * Real-time collaboration UI components and animations
 */

/* User Presence Indicator */
.tc-user-presence {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tc-user-presence:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.tc-presence-icon {
  font-size: 16px;
}

.tc-presence-count {
  background: #3b82f6;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.tc-presence-tooltip {
  position: absolute;
  top: 100%;
  right: 0;
  background: #1f2937;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 8px;
  min-width: 150px;
  font-size: 12px;
  opacity: 0;
  transform: translateY(-5px);
  pointer-events: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tc-presence-tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  right: 12px;
  border: 5px solid transparent;
  border-bottom-color: #1f2937;
}

.tc-user-presence:hover .tc-presence-tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tc-presence-tooltip div {
  padding: 2px 0;
  border-bottom: 1px solid #374151;
}

.tc-presence-tooltip div:last-child {
  border-bottom: none;
}

/* Collaboration Controls */
.tc-collaboration-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  z-index: 1000;
}

.tc-collaboration-controls button {
  background: #fff;
  border: 1px solid #e1e5e9;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tc-collaboration-controls button:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.tc-sync-toggle[data-enabled="true"] {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.tc-sync-toggle[data-enabled="true"]:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.tc-leave-session {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.tc-leave-session:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Collaborator Cursors */
.tc-collaborator-cursor {
  position: absolute;
  pointer-events: none;
  z-index: 9999;
  transition: all 0.1s ease-out;
}

.tc-cursor-pointer {
  width: 14px;
  height: 14px;
  background: #3b82f6;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative;
}

.tc-cursor-pointer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-left-color: #3b82f6;
  transform: translate(-50%, -50%) rotate(-45deg);
  margin-left: 7px;
  margin-top: -2px;
}

.tc-cursor-label {
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tc-cursor-label::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1f2937;
}

/* Multiple cursor colors */
.tc-collaborator-cursor:nth-child(2n) .tc-cursor-pointer {
  background: #10b981;
}

.tc-collaborator-cursor:nth-child(2n) .tc-cursor-pointer::after {
  border-left-color: #10b981;
}

.tc-collaborator-cursor:nth-child(3n) .tc-cursor-pointer {
  background: #f59e0b;
}

.tc-collaborator-cursor:nth-child(3n) .tc-cursor-pointer::after {
  border-left-color: #f59e0b;
}

.tc-collaborator-cursor:nth-child(4n) .tc-cursor-pointer {
  background: #ef4444;
}

.tc-collaborator-cursor:nth-child(4n) .tc-cursor-pointer::after {
  border-left-color: #ef4444;
}

.tc-collaborator-cursor:nth-child(5n) .tc-cursor-pointer {
  background: #8b5cf6;
}

.tc-collaborator-cursor:nth-child(5n) .tc-cursor-pointer::after {
  border-left-color: #8b5cf6;
}

/* Collaboration Notifications */
.tc-collaboration-notification {
  position: fixed;
  top: 50px;
  right: 20px;
  background: #1f2937;
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: tc-slide-in 0.3s ease-out, tc-fade-out 0.3s ease-in 2.7s forwards;
}

@keyframes tc-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes tc-fade-out {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* Collaboration Status Indicators */
.tc-collaboration-active {
  position: relative;
}

.tc-collaboration-active::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(90deg, #3b82f6, #10b981, #f59e0b, #ef4444);
  background-size: 200% 200%;
  border-radius: inherit;
  z-index: -1;
  animation: tc-collaboration-pulse 3s ease-in-out infinite;
}

@keyframes tc-collaboration-pulse {
  0%, 100% {
    background-position: 0% 50%;
    opacity: 0.7;
  }
  50% {
    background-position: 100% 50%;
    opacity: 1;
  }
}

/* Sync Status Indicator */
.tc-sync-status {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 12px;
  color: #6b7280;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tc-sync-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: tc-pulse 1.5s ease-in-out infinite;
}

.tc-sync-indicator.tc-syncing {
  background: #3b82f6;
  animation: tc-spin 1s linear infinite;
}

.tc-sync-indicator.tc-error {
  background: #ef4444;
  animation: none;
}

@keyframes tc-pulse {
  0%, 100% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

@keyframes tc-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Row Highlighting for Collaborative Comments */
.tc-row-commented {
  position: relative;
  background: #fef3c7 !important;
  border-left: 3px solid #f59e0b;
}

.tc-row-commented::after {
  content: '💬';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.7;
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
  .tc-user-presence {
    top: 5px;
    right: 5px;
    padding: 6px 8px;
    font-size: 12px;
  }
  
  .tc-collaboration-controls {
    top: 5px;
    left: 5px;
    flex-direction: column;
  }
  
  .tc-collaboration-controls button {
    padding: 6px 8px;
    font-size: 12px;
  }
  
  .tc-cursor-label {
    display: none; /* Hide cursor labels on mobile */
  }
  
  .tc-collaboration-notification {
    top: 20px;
    right: 10px;
    left: 10px;
    font-size: 13px;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .tc-user-presence,
  .tc-collaboration-controls button {
    border-width: 2px;
  }
  
  .tc-collaborator-cursor .tc-cursor-pointer {
    border-width: 3px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .tc-collaborator-cursor,
  .tc-user-presence,
  .tc-collaboration-controls button,
  .tc-collaboration-notification {
    transition: none;
  }
  
  @keyframes tc-collaboration-pulse,
  @keyframes tc-pulse,
  @keyframes tc-spin,
  @keyframes tc-slide-in,
  @keyframes tc-fade-out {
    animation-duration: 0.01s;
  }
}