/**
 * NesaMate - 3D Digital Twin Map UI Styles
 * Desain sistem konsisten dengan tema Safari Dark Forest Nesa
 */

/* ================================================================
   CONTAINER 3D MAP FULLSCREEN
   ================================================================ */

.map-3d-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: none;
  z-index: 1; /* sama level dengan map 2D */
  background: #0d1a11;
}

.map-3d-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none; /* OrbitControls butuh ini agar pinch/drag tidak di-intercept */
}

/* ================================================================
   TOGGLE PILL 2D / 3D — Muncul di Top Bar Free Mode
   ================================================================ */

.map-view-toggle-pill {
  display: flex;
  align-items: center;
  background: rgba(30, 59, 47, 0.78);
  border: 1.5px solid rgba(200, 180, 138, 0.45);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.toggle-pill-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 5px 13px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: rgba(245, 240, 230, 0.6);
  transition: all 0.22s cubic-bezier(0.25, 1, 0.5, 1);
  min-width: 36px;
}

.toggle-pill-btn.is-active {
  background: var(--color-gold, #C8B48A);
  color: var(--color-primary, #1E3B2F);
  box-shadow: 0 2px 10px rgba(200, 180, 138, 0.42);
}

.toggle-pill-btn:not(.is-active):hover {
  background: rgba(200, 180, 138, 0.18);
  color: var(--color-cream, #F5F0E6);
}

/* ================================================================
   3D QUICK CONTROLS BAR — Muncul di bagian bawah saat mode 3D
   ================================================================ */

.map-3d-quick-controls {
  position: absolute;
  bottom: 70px; /* Di atas bottom nav bar */
  left: 12px;
  right: 12px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 30;
}

.pill-btn-3d-action {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-main);
  font-size: 11.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid rgba(200, 180, 138, 0.5);
  cursor: pointer;
  color: var(--color-cream, #F5F0E6);
  background: rgba(30, 59, 47, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: var(--transition-smooth);
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.pill-btn-3d-action:hover {
  background: rgba(200, 180, 138, 0.25);
  border-color: rgba(200, 180, 138, 0.75);
}

.pill-btn-3d-action span {
  font-size: 14px;
}

.route-select-3d-wrap {
  flex: 1;
}

.select-3d-route {
  width: 100%;
  font-family: var(--font-main);
  font-size: 11.5px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1.5px solid rgba(200, 180, 138, 0.5);
  color: var(--color-cream, #F5F0E6);
  background: rgba(30, 59, 47, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: var(--transition-smooth);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23C8B48A' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.select-3d-route option {
  background: #1E3B2F;
  color: #F5F0E6;
  font-weight: 600;
}

.select-3d-route:focus {
  border-color: var(--color-gold, #C8B48A);
}

/* ================================================================
   LOADING OVERLAY — Tampil saat model 3D sedang dimuat
   ================================================================ */

.map3d-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 26, 17, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10;
  pointer-events: none;
}

.map3d-spinner-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 32px;
  background: rgba(30, 59, 47, 0.75);
  border: 1.5px solid rgba(200, 180, 138, 0.35);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  max-width: 260px;
  text-align: center;
}

.map3d-spinner {
  width: 42px;
  height: 42px;
  border: 3.5px solid rgba(200, 180, 138, 0.2);
  border-top-color: #C8B48A;
  border-radius: 50%;
  animation: map3d-spin 0.85s linear infinite;
}

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

.map3d-loading-text {
  font-family: var(--font-main, sans-serif);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-cream, #F5F0E6);
  line-height: 1.4;
}

.map3d-loading-sub {
  font-family: var(--font-main, sans-serif);
  font-size: 10px;
  font-weight: 500;
  color: rgba(200, 180, 138, 0.7);
  letter-spacing: 0.5px;
}

/* ================================================================
   ERROR OVERLAY — Tampil jika file model 3D gagal dimuat
   ================================================================ */

.map3d-error-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(13, 26, 17, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10;
}

.map3d-error-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 24px;
  background: rgba(30, 59, 47, 0.85);
  border: 1.5px solid rgba(200, 100, 100, 0.4);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  max-width: 280px;
  text-align: center;
}

.map3d-error-icon {
  font-size: 36px;
}

.map3d-error-box h4 {
  font-family: var(--font-main, sans-serif);
  font-size: 14px;
  font-weight: 800;
  color: var(--color-cream, #F5F0E6);
}

.map3d-error-desc {
  font-family: var(--font-main, sans-serif);
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(245, 240, 230, 0.75);
  line-height: 1.5;
}

.map3d-error-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.map3d-retry-btn,
.map3d-fallback-btn {
  font-family: var(--font-main, sans-serif);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.map3d-retry-btn {
  background: var(--color-gold, #C8B48A);
  color: var(--color-primary, #1E3B2F);
}

.map3d-retry-btn:hover {
  background: #d9c89a;
  transform: translateY(-1px);
}

.map3d-fallback-btn {
  background: rgba(200, 180, 138, 0.15);
  color: var(--color-cream, #F5F0E6);
  border: 1px solid rgba(200, 180, 138, 0.35);
}

.map3d-fallback-btn:hover {
  background: rgba(200, 180, 138, 0.25);
}

/* ================================================================
   ADJUSTMENT: Top Bar title pill agar lebih rapat saat toggle ada
   ================================================================ */

#screen-free-mode .top-bar-row {
  gap: 6px;
}

#screen-free-mode .title-pill-badge {
  font-size: 11px;
  padding: 5px 10px;
}

/* ================================================================
   RESPONSIF — Jaga proporsi tampilan 3D pada layar kecil
   ================================================================ */

@media (max-width: 400px) {
  .map-3d-quick-controls {
    bottom: 60px;
    gap: 7px;
  }

  .pill-btn-3d-action {
    font-size: 10.5px;
    padding: 7px 10px;
  }

  .select-3d-route {
    font-size: 10.5px;
    padding: 7px 10px;
  }

  .toggle-pill-btn {
    font-size: 10px;
    padding: 5px 10px;
  }
}

.map-view-toggle-floating {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}
