/**
 * Background Filter Modal - Draggable Pattern
 * Follows the same draggable pattern as chat and caption modals
 * Supports ghost mode (semi-transparent background) and pinning
 */

/* Draggable Modal Container */
#backgroundFilterModal {
  z-index: 14;
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 680px;
  min-width: 420px;
  min-height: 500px;
  max-width: 90vw;
  max-height: 85vh;
  background: var(--msger-bg);
  border: var(--border);
  resize: both;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: var(--box-shadow);
  transition: opacity 0.3s ease-in-out;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}

#backgroundFilterModal.show {
  display: flex;
}

/* Ghost Mode - Default layout with semi-transparent background */
#backgroundFilterModal.ghost-mode {
  background: rgba(26, 26, 26, 0.85);
  backdrop-filter: blur(10px);
}

/* Main Panel Structure */
.teams-filter-panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header - Draggable */
.teams-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-bottom: 1px solid #333333;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.2);
  cursor: move;
}

.teams-filter-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.teams-filter-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
}

.teams-filter-header-options {
  display: flex;
  gap: 5px;
}

.teams-filter-header-options button {
  padding: 5px;
  border: none;
  font-size: 1rem;
  background: transparent;
  color: #fff;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease-in-out;
}

.teams-filter-header-options button:hover {
  background: var(--body-bg);
}

.teams-background-close {
  background: none;
  border: none;
  color: #cccccc;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.teams-background-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.teams-background-close:focus {
  outline: 2px solid #5059C9;
  outline-offset: 2px;
}

.teams-background-close svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Video Preview Section */
.teams-filter-preview-section {
  flex-shrink: 0;
  height: 300px;
  background: #000;
  position: relative;
  overflow: hidden;
}

.teams-filter-preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Options Section */
.teams-filter-options-section {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  min-height: 200px;
  background: #2a2a2a;
}

/* Background Options Grid */
.teams-background-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.teams-background-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #e1e5e9;
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/9;
}

.teams-background-option:hover {
  border-color: #FE7E00;
  transform: scale(1.02);
}

.teams-background-option.selected {
  border-color: #FE7E00;
  box-shadow: 0 0 0 2px rgba(254, 126, 0, 0.2);
}

.teams-background-preview {
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e1e5e9;
}

.teams-background-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* None Option */
.teams-background-none {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border: 2px dashed #e1dfdd;
  border-radius: 6px;
}

.teams-background-none svg {
  width: 24px;
  height: 24px;
  color: #616161;
}

/* Blur Option */
.teams-background-blur {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
  position: relative;
  overflow: hidden;
}

.teams-blur-circles {
  display: flex;
  gap: 8px;
}

.teams-blur-circle {
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  filter: blur(2px);
}

/* Labels */
.teams-background-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
  padding: 8px;
  font-size: 12px;
  text-align: center;
  display: none;
}

/* Footer */
.teams-filter-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 20px 24px;
  border-top: 1px solid #333333;
  flex-shrink: 0;
  background: #1a1a1a;
}

.teams-filter-footer .teams-button {
  padding: 10px 24px;
  border: 1px solid #e1dfdd;
  border-radius: 4px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.teams-filter-footer .teams-button:focus {
  outline: 2px solid #5059C9;
  outline-offset: 2px;
}

.teams-filter-footer .teams-button-primary {
  background: #FE7E00;
  color: #ffffff;
  border-color: #FE7E00;
}

.teams-filter-footer .teams-button-primary:hover {
  background: #ff9933;
  border-color: #ff9933;
}

.teams-filter-footer .teams-button-secondary {
  background: #d13438;
  color: #ffffff;
  border-color: #d13438;
}

.teams-filter-footer .teams-button-secondary:hover {
  background: #b71c1c;
  border-color: #b71c1c;
}

/* Pinned Mode - Opaque background when pinned */
#backgroundFilterModal.pinned {
  background: #1a1a1a;
  backdrop-filter: none;
}

/* Animations */
@keyframes filterModalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Scrollbar Styling */
.teams-filter-options-section::-webkit-scrollbar {
  width: 8px;
}

.teams-filter-options-section::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.teams-filter-options-section::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.teams-filter-options-section::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .teams-filter-panel {
    width: 95vw;
    max-height: 90vh;
    border-radius: 12px;
  }
  
  .teams-filter-preview-section {
    height: 200px;
  }
  
  .teams-filter-header {
    padding: 16px;
  }
  
  .teams-filter-header h3 {
    font-size: 16px;
  }
  
  .teams-filter-options-section {
    padding: 16px;
  }
  
  .teams-background-options {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .teams-filter-footer {
    padding: 16px;
    gap: 8px;
    flex-direction: column;
  }
  
  .teams-filter-footer .teams-button {
    padding: 12px 16px;
    font-size: 14px;
    width: 100%;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  #backgroundFilterModal,
  .teams-filter-panel,
  .teams-background-option {
    animation: none !important;
    transition: none !important;
  }
}
