/* Tesla Gallery Styles - Dark theme matching TFIA.FUN */

:root {
  --gallery-accent: #00e0ff;
  --gallery-bg: #121212;
  --gallery-border: #272727;
  --gallery-text: #f4f4f4;
  --gallery-subtle: #bdbdbd;
}

/* Gallery Controls */
.gallery-controls {
  margin: 32px 0;
  padding: 0;
}

.model-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 20px;
  background: var(--gallery-bg);
  border: 1px solid var(--gallery-border);
  border-radius: 12px;
  max-width: 100%;
  overflow-x: auto;
}

.category-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-right: 1px solid var(--gallery-border);
  padding-right: 16px;
  margin-right: 8px;
}

.category-group:last-child {
  border-right: none;
  margin-right: 0;
  padding-right: 0;
}

.category-label {
  color: var(--gallery-accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-right: 8px;
  white-space: nowrap;
  opacity: 0.8;
}

@media (max-width: 768px) {
  .model-selector {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .category-group {
    flex-shrink: 0;
    min-width: max-content;
  }
}

.model-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--gallery-border);
  background: transparent;
  color: var(--gallery-subtle);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-btn:hover {
  border-color: var(--gallery-accent);
  color: var(--gallery-accent);
  transform: translateY(-2px);
}

.model-btn.active {
  background: linear-gradient(90deg, #00e0ff, #2b8cff);
  border-color: var(--gallery-accent);
  color: #061318;
}

.model-btn:focus {
  outline: 2px solid var(--gallery-accent);
  outline-offset: 2px;
}

/* Loading & Error States */
.loading-indicator {
  text-align: center;
  padding: 60px 20px;
  color: var(--gallery-subtle);
}

.loading-indicator.hidden {
  display: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--gallery-border);
  border-top-color: var(--gallery-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

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

.error-message {
  padding: 20px;
  background: #2a1a1a;
  border: 1px solid #ff4444;
  border-radius: 12px;
  color: #ff6666;
  margin: 20px 0;
  text-align: center;
}

.error-message.hidden {
  display: none;
}

.retry-btn {
  margin-top: 12px;
  padding: 8px 16px;
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.retry-btn:hover {
  background: #ff6666;
}

/* Gallery Grid - Masonry Layout */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin: 32px 0;
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

@media (min-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  }
}

/* Gallery Card */
.gallery-card {
  background: var(--gallery-bg);
  border: 1px solid var(--gallery-border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 224, 255, 0.2);
  border-color: var(--gallery-accent);
}

.gallery-card:focus {
  outline: 2px solid var(--gallery-accent);
  outline-offset: 2px;
}

.card-image-wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #0b0b0b;
}

.card-image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-card:hover .card-image-wrapper img {
  transform: scale(1.05);
}

.card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
  padding: 20px 16px 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gallery-card:hover .card-overlay {
  opacity: 1;
}

.card-model {
  color: var(--gallery-accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card-title {
  color: var(--gallery-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

/* Load More Button */
.load-more-container {
  text-align: center;
  margin: 40px 0;
}

.load-more-btn {
  padding: 14px 32px;
  border-radius: 10px;
  border: 1px solid var(--gallery-accent);
  background: transparent;
  color: var(--gallery-accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
}

.load-more-btn:hover {
  background: var(--gallery-accent);
  color: #061318;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 224, 255, 0.3);
}

.load-more-btn.hidden {
  display: none;
}

/* Lightbox Modal */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  animation: fadeIn 0.3s ease;
}

.lightbox.hidden {
  display: none;
}

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

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--gallery-bg);
  border: 1px solid var(--gallery-border);
  border-radius: 12px;
  padding: 20px;
  overflow: auto;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-info {
  text-align: center;
  color: var(--gallery-text);
}

.lightbox-info h3 {
  margin: 0 0 8px;
  color: var(--gallery-accent);
  font-size: 20px;
}

.lightbox-credit {
  color: var(--gallery-subtle);
  font-size: 14px;
  margin: 0 0 16px;
}

.download-btn {
  display: inline-block;
  padding: 10px 20px;
  background: linear-gradient(90deg, #00e0ff, #2b8cff);
  color: #061318;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: transform 0.2s ease;
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 224, 255, 0.3);
}

/* Lightbox Controls */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--gallery-border);
  color: var(--gallery-text);
  font-size: 32px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10001;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: var(--gallery-accent);
  color: #061318;
  border-color: var(--gallery-accent);
  transform: scale(1.1);
}

.lightbox-close {
  top: 20px;
  right: 20px;
  font-size: 36px;
  line-height: 1;
}

.lightbox-prev {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev:disabled,
.lightbox-next:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.lightbox-prev:disabled:hover,
.lightbox-next:disabled:hover {
  transform: translateY(-50%) scale(1);
  background: rgba(0, 0, 0, 0.7);
  color: var(--gallery-text);
}

/* Gallery Footer */
.gallery-footer {
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--gallery-border);
  text-align: center;
  color: var(--gallery-subtle);
  font-size: 13px;
}

.gallery-footer p {
  margin: 8px 0;
}

.gallery-footer a {
  color: var(--gallery-accent);
  text-decoration: none;
}

.gallery-footer a:hover {
  text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .model-selector {
    padding: 16px;
  }
  
  .model-btn {
    padding: 8px 16px;
    font-size: 12px;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
  
  .lightbox-content {
    max-width: 95vw;
    padding: 16px;
  }
  
  .lightbox-close,
  .lightbox-prev,
  .lightbox-next {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
  
  .lightbox-close {
    top: 10px;
    right: 10px;
  }
  
  .lightbox-prev {
    left: 10px;
  }
  
  .lightbox-next {
    right: 10px;
  }
}

