/* ========================================================
   TrailTrack Stories - Gallery CSS
   ======================================================== */

/* ---- 3D Gallery Container ---- */
.gallery-3d-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9000;
  background: #000;
}

.gallery-3d-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- Gallery Overlay UI ---- */
.gallery-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9001;
}

.gallery-overlay * {
  pointer-events: auto;
}

/* Top bar */
.gallery-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
  gap: 12px;
  flex-wrap: wrap;
}

.gallery-top-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gallery-top-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.gallery-top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gallery-exit-btn {
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.gallery-exit-btn:hover {
  background: rgba(239, 68, 68, 1);
}

.gallery-type-btn {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.gallery-type-btn:hover {
  background: rgba(255,255,255,0.2);
}

.gallery-type-btn.active {
  background: rgba(16, 185, 129, 0.6);
  border-color: rgba(16, 185, 129, 0.8);
}

.gallery-select {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
}

.gallery-select option {
  background: #1a1a2e;
  color: #fff;
}

.gallery-submit-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.gallery-submit-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

/* Bulk upload */
.bulk-drop-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}

.bulk-drop-zone:hover {
  border-color: var(--green);
  background: rgba(16, 185, 129, 0.03);
}

.bulk-drag-over {
  border-color: var(--green-light) !important;
  background: rgba(16, 185, 129, 0.08) !important;
}

.bulk-drop-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Bottom bar */
.gallery-bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(0deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
  gap: 16px;
}

.gallery-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gallery-mode-btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.gallery-mode-btn:hover {
  background: rgba(255,255,255,0.25);
}

.gallery-mode-btn.active {
  background: rgba(99, 102, 241, 0.6);
  border-color: rgba(99, 102, 241, 0.8);
}

.gallery-speed-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
}

.gallery-speed-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  outline: none;
}

.gallery-speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #10b981;
  cursor: pointer;
}

.gallery-photo-count {
  color: rgba(255,255,255,0.6);
  font-size: 0.8rem;
  white-space: nowrap;
}

.gallery-view-toggle {
  color: rgba(255,255,255,0.6);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
}

.gallery-view-toggle:hover {
  color: #fff;
}

/* ---- Mini Map ---- */
.gallery-minimap {
  position: absolute;
  bottom: 70px;
  right: 20px;
  width: 120px;
  height: 120px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  overflow: hidden;
}

.gallery-minimap-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.gallery-minimap-ring {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
}

.gallery-minimap-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
  transform: translate(-50%, -50%);
  transition: all 0.1s;
}

.gallery-minimap-fov {
  position: absolute;
  width: 0;
  height: 0;
  transform-origin: center center;
}

/* ---- Loading Indicator ---- */
.gallery-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #fff;
  font-size: 1.1rem;
}

.gallery-loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: gallery-spin 0.8s linear infinite;
}

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

/* ---- Photo Lightbox (Gallery) ---- */
.gallery-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9100;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.gallery-lightbox.active {
  opacity: 1;
}

.gallery-lightbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 90vw;
  max-height: 90vh;
}

.gallery-lightbox-img {
  max-width: 80vw;
  max-height: 65vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  object-fit: contain;
}

.gallery-lightbox-info {
  text-align: center;
  color: #fff;
}

.gallery-lightbox-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.gallery-lightbox-user {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 8px;
}

.gallery-lightbox-desc {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 12px;
  max-width: 500px;
}

.gallery-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.gallery-vote-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.gallery-vote-btn:hover {
  background: rgba(255,255,255,0.2);
}

.gallery-vote-btn.voted {
  background: rgba(16, 185, 129, 0.3);
  border-color: rgba(16, 185, 129, 0.6);
  color: #10b981;
}

.gallery-lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.gallery-lightbox-close:hover {
  background: rgba(255,255,255,0.3);
}

.gallery-lightbox-delete {
  background: rgba(239, 68, 68, 0.3);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.gallery-lightbox-delete:hover {
  background: rgba(239, 68, 68, 0.5);
}

/* ---- Submit Modal ---- */
.gallery-submit-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9200;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.gallery-submit-modal.active {
  opacity: 1;
}

.gallery-submit-card {
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 32px;
  max-width: 480px;
  width: 90vw;
  color: #fff;
}

.gallery-submit-card h2 {
  margin: 0 0 20px;
  font-size: 1.3rem;
}

.gallery-submit-card .form-group {
  margin-bottom: 14px;
}

.gallery-submit-card label {
  display: block;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 4px;
  font-weight: 600;
}

.gallery-submit-card input,
.gallery-submit-card select,
.gallery-submit-card textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  box-sizing: border-box;
}

.gallery-submit-card textarea {
  resize: vertical;
  min-height: 60px;
}

.gallery-submit-card input:focus,
.gallery-submit-card select:focus,
.gallery-submit-card textarea:focus {
  border-color: rgba(16, 185, 129, 0.6);
}

.gallery-submit-card select option {
  background: #1a1a2e;
}

.gallery-dropzone {
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 14px;
}

.gallery-dropzone:hover,
.gallery-dropzone.dragover {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.05);
  color: #10b981;
}

.gallery-dropzone-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  margin-top: 10px;
}

.gallery-submit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.gallery-submit-actions button {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.gallery-submit-actions .cancel-btn {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.gallery-submit-actions .submit-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.gallery-submit-actions .submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- 2D Grid View ---- */
.gallery-grid-container {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.gallery-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.gallery-grid-header h1 {
  font-size: 1.5rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.gallery-grid-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.gallery-grid-filters select,
.gallery-grid-filters button {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  border: 1px solid var(--border, #333);
  background: var(--surface, #1a1a2e);
  color: var(--text, #fff);
  cursor: pointer;
}

.gallery-grid-filters button.active {
  background: var(--green, #10b981);
  border-color: var(--green, #10b981);
  color: #fff;
}

.gallery-masonry {
  columns: 4;
  column-gap: 16px;
}

@media (max-width: 1200px) { .gallery-masonry { columns: 3; } }
@media (max-width: 900px) { .gallery-masonry { columns: 2; } }
@media (max-width: 600px) { .gallery-masonry { columns: 1; } }

.gallery-grid-card {
  break-inside: avoid;
  margin-bottom: 16px;
  background: var(--surface, #1e1e30);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-grid-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.gallery-grid-card img {
  width: 100%;
  display: block;
  cursor: pointer;
}

.gallery-grid-card-info {
  padding: 12px;
}

.gallery-grid-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.gallery-grid-card-user {
  font-size: 0.75rem;
  color: var(--text-muted, rgba(255,255,255,0.5));
  margin-bottom: 8px;
}

.gallery-grid-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gallery-grid-vote-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  color: var(--text-secondary, rgba(255,255,255,0.6));
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.gallery-grid-vote-btn:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
  color: #10b981;
}

.gallery-grid-vote-btn.voted {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #10b981;
}

.gallery-grid-load-more {
  display: block;
  margin: 24px auto;
  padding: 12px 32px;
  background: var(--surface, #1e1e30);
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  color: var(--text, #fff);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.gallery-grid-load-more:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
}

/* ---- Crosshair ---- */
.gallery-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 50%;
  pointer-events: none;
  display: none;
}

/* ---- Hover tooltip ---- */
.gallery-hover-tooltip {
  position: absolute;
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  pointer-events: none;
  transform: translate(-50%, -110%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9050;
}

.gallery-hover-tooltip.visible {
  opacity: 1;
}

/* ---- Help text ---- */
.gallery-help {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.4);
  font-size: 0.75rem;
  text-align: center;
  pointer-events: none;
  transition: opacity 2s;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .gallery-top-bar {
    padding: 8px 12px;
  }
  .gallery-type-btn {
    padding: 6px 10px;
    font-size: 0.7rem;
  }
  .gallery-minimap {
    width: 80px;
    height: 80px;
    bottom: 60px;
    right: 12px;
  }
  .gallery-bottom-bar {
    padding: 8px 12px;
    flex-wrap: wrap;
  }
}
