/* Template Selector Modal */

.template-selector-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.template-selector-overlay.closing {
  animation: fadeOut 0.2s ease-out forwards;
}

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

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

.template-selector-modal {
  background: #1a1a1a;
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideUp 0.2s ease-out;
}

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

.template-selector-overlay.closing .template-selector-modal {
  animation: slideDown 0.2s ease-out forwards;
}

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

/* Header */
.template-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.template-selector-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.template-selector-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.template-selector-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Content */
.template-selector-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-height: 300px;
}

/* Loading */
.template-selector-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 16px;
  color: rgba(255, 255, 255, 0.6);
}

.template-selector-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(180, 255, 57, 0.2);
  border-top-color: #b4ff39;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Empty state */
.template-selector-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 16px;
}

/* Error state */
.template-selector-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 16px;
  color: rgba(255, 255, 255, 0.5);
}

.template-selector-retry {
  background: #b4ff39;
  color: #000;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-selector-retry:hover {
  background: #a0e635;
}

/* Section */
.template-selector-section {
  margin-bottom: 32px;
}

.template-selector-section:last-child {
  margin-bottom: 0;
}

.template-selector-section-title {
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Grid */
.template-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

/* Card */
.template-selector-card {
  position: relative;
  background: #252525;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.template-selector-card:hover {
  border-color: #b4ff39;
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Card media */
.template-selector-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #1a1a1a;
}

.template-selector-card-video,
.template-selector-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-selector-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: rgba(255, 255, 255, 0.2);
}

/* Card title */
.template-selector-card-title {
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card model badge */
.template-selector-card-model {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #b4ff39;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .template-selector-overlay {
    padding: 0;
    align-items: flex-end;
  }
  
  .template-selector-modal {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
  }
  
  .template-selector-header {
    padding: 16px 20px;
  }
  
  .template-selector-title {
    font-size: 18px;
  }
  
  .template-selector-content {
    padding: 16px;
  }
  
  .template-selector-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .template-selector-card-title {
    padding: 10px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .template-selector-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .template-selector-card-model {
    font-size: 9px;
    padding: 3px 6px;
  }
}
