/* =========================================================================
 * JGVRP NFSU2 Custom Speedometer HUD - Stylesheet
 * (Tanpa Tailwind CDN supaya tetap tampil walau in-game tidak ada internet)
 * ========================================================================= */

:root {
  --cyan-glow: #00f3ff;
  --orange-glow: #ff9100;
  --red-glow: #ff2222;
  --green-glow: #00ff44;
  --blue-glow: #2979ff;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: transparent !important;
  background-color: transparent !important;
  pointer-events: none; /* klik tembus ke game, kecuali di area HUD */
}

/* -------------------------------------------------------------------------
 * HUD container (default: kanan bawah). Posisi bisa dipindah dengan drag.
 * ------------------------------------------------------------------------- */
.hud-container {
  position: fixed;
  right: 1.5vw;
  bottom: 1.5vh;
  width: clamp(340px, 36vw, 640px);
  height: auto;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

/* Hanya bagian HUD yang terlihat (bukan area transparan) yang bisa di-drag */
.hud-container.draggable #nfsu2HudSvg * {
  pointer-events: visiblePainted;
  cursor: grab;
}

.hud-container.dragging #nfsu2HudSvg * {
  cursor: grabbing;
}

/* Selama drag, seluruh halaman menangkap mouse supaya gerakan tidak putus */
html.hud-dragging,
html.hud-dragging body {
  pointer-events: auto;
  cursor: grabbing;
}

.hud-container.dragging {
  outline: 1px dashed rgba(0, 243, 255, 0.55);
  outline-offset: 4px;
}

#nfsu2HudSvg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.85));
}

/* Smooth GPU-accelerated transforms for needles */
#mainNeedleGroup,
#smallNeedleGroup {
  will-change: transform;
}

/* -------------------------------------------------------------------------
 * Typography
 * ------------------------------------------------------------------------- */
.font-racing {
  font-family: 'Chakra Petch', 'Segoe UI', Arial, sans-serif;
  font-style: italic;
  font-weight: 700;
}

.font-orbitron {
  font-family: 'Orbitron', 'Segoe UI', Arial, sans-serif;
}

.fw-semibold {
  font-weight: 600;
}

.fw-extrabold {
  font-weight: 800;
}

/* ========================================================
   MUSIC ICON ON SPEEDOMETER HUD
   ======================================================== */
#control-music {
  color: #00f3ff;
  opacity: 0.78;
  filter: drop-shadow(0 0 4px rgba(0, 243, 255, 0.45));
  transition: color 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
  pointer-events: bounding-box !important;
  cursor: pointer !important;
}

#control-music * {
  pointer-events: auto !important;
  cursor: pointer !important;
}

#control-music:hover,
#control-music.active {
  color: #00f3ff;
  opacity: 1;
  filter: url(#glowCyanIntense);
}

/* ========================================================
   YOUTUBE MUSIC PLAYER POPUP WINDOW (NFSU2 THEME)
   ======================================================== */
:root {
  --music-popup-width: 380px;
}

.music-popup-window {
  position: fixed;
  right: 520px;
  bottom: 20px;
  width: var(--music-popup-width);
  max-width: 90vw;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #0d131a; /* Solid color, zero backdrop-filter to prevent CEF black box bug */
  border: 2px solid #29465b;
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.75), 0 0 14px rgba(0, 243, 255, 0.22);
  padding: 14px 16px;
  color: #e2e8f0;
  font-family: 'Chakra Petch', 'Segoe UI', Arial, sans-serif;
  z-index: 100000;
  pointer-events: auto;
  user-select: none;
  translate: 0 0;
  scale: 1;
  rotate: 0deg;
  opacity: 1;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              scale 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              translate 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.music-popup-window::-webkit-scrollbar {
  width: 5px;
}
.music-popup-window::-webkit-scrollbar-track {
  background: transparent;
}
.music-popup-window::-webkit-scrollbar-thumb {
  background: #29465b;
  border-radius: 4px;
}

.music-popup-window.closed {
  opacity: 0;
  pointer-events: none;
  scale: 0.92;
  translate: 0 12px;
}

/* Header & Drag Handle */
.music-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.18);
  cursor: grab;
}

.music-popup-header:active {
  cursor: grabbing;
}

.music-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Chakra Petch', 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
  font-style: italic;
  color: #00f3ff;
  letter-spacing: 0.5px;
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.45);
}

.music-drag-grip {
  color: #64748b;
  font-size: 16px;
  line-height: 1;
  opacity: 0.7;
  font-style: normal;
}

.music-header-icon {
  font-size: 15px;
  font-style: normal;
}

.music-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.music-action-btn {
  background: #16222f;
  border: 1px solid #29465b;
  color: #7dd3fc;
  border-radius: 8px;
  padding: 3px 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.music-action-btn:hover,
.music-action-btn.active {
  background: #1e3346;
  color: #fff;
  border-color: #00f3ff;
  box-shadow: 0 0 8px rgba(0, 243, 255, 0.35);
}

.music-action-btn.close {
  padding: 3px 7px;
  font-size: 12px;
}

.music-action-btn.close:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

/* Search & Link Section */
.music-search-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.music-search-form {
  display: flex;
  gap: 6px;
}

.music-search-input {
  flex: 1;
  background: #080c11;
  border: 1.5px solid #29465b;
  border-radius: 10px;
  padding: 8px 12px;
  color: #e2e8f0;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 12px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.music-search-input:focus {
  border-color: #00f3ff;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.35);
}

.music-search-input::placeholder {
  color: rgba(148, 163, 184, 0.65);
}

.music-play-btn {
  background: #00b8d4;
  border: 1px solid #00f3ff;
  border-radius: 10px;
  padding: 8px 14px;
  color: #041016;
  font-family: 'Chakra Petch', 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
  transition: all 0.15s ease;
}

.music-play-btn:hover {
  background: #00f3ff;
  box-shadow: 0 0 14px rgba(0, 243, 255, 0.7);
  scale: 1.03;
}

.music-play-btn:active {
  scale: 0.97;
}

/* Quick Chips */
.music-quick-chips {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.music-chip {
  background: #14202c;
  border: 1px solid #263e52;
  border-radius: 10px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  color: #93c5fd;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.music-chip:hover {
  background: #1d3142;
  border-color: #00f3ff;
  color: #fff;
}

/* ========================================================
   YOUTUBE SEARCH RESULTS SELECTION LIST
   ======================================================== */
.music-results-container {
  background: #080c11;
  border: 1.5px solid #29465b;
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
}

.music-results-container.hidden {
  display: none !important;
}

.music-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.14);
}

.results-count-title {
  font-size: 11px;
  font-weight: 700;
  color: #00f3ff;
}

.results-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.results-close-btn:hover {
  color: #ef4444;
}

.music-results-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 180px;
  padding-right: 4px;
}

.music-results-list::-webkit-scrollbar {
  width: 5px;
}
.music-results-list::-webkit-scrollbar-track {
  background: #0d131a;
  border-radius: 4px;
}
.music-results-list::-webkit-scrollbar-thumb {
  background: #29465b;
  border-radius: 4px;
}
.music-results-list::-webkit-scrollbar-thumb:hover {
  background: #00f3ff;
}

.yt-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 8px;
  background: #131d28;
  border: 1px solid #223546;
  cursor: pointer;
  transition: all 0.15s ease;
}

.yt-result-item:hover {
  background: #1a2938;
  border-color: #00f3ff;
  box-shadow: 0 0 8px rgba(0, 243, 255, 0.25);
  translate: 2px 0;
}

.yt-thumb-wrap {
  position: relative;
  width: 64px;
  height: 40px;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  background: #05080b;
}

.yt-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.yt-duration-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 9px;
  font-family: monospace;
  padding: 1px 3px;
  border-radius: 3px;
}

.yt-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.yt-title {
  font-size: 11px;
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yt-author {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yt-play-arrow {
  color: #00f3ff;
  font-size: 12px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s ease, scale 0.15s ease;
}

.yt-result-item:hover .yt-play-arrow {
  opacity: 1;
  color: #00ff44;
  scale: 1.2;
}

/* Loading & Empty state */
.music-results-status {
  padding: 14px;
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Now Playing Bar */
.music-now-playing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #132230;
  border: 1px solid #29465b;
  border-radius: 10px;
  padding: 5px 10px;
  margin-bottom: 8px;
  font-size: 11px;
}

.music-now-playing.hidden {
  display: none !important;
}

.now-playing-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.now-playing-icon {
  font-size: 13px;
  animation: pulse-music 1.2s infinite alternate;
}

@keyframes pulse-music {
  0% { scale: 0.95; color: #7dd3fc; }
  100% { scale: 1.15; color: #00f3ff; }
}

.now-playing-text {
  color: #e2e8f0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.change-video-btn {
  background: #080c11;
  border: 1px solid #29465b;
  color: #00f3ff;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  transition: all 0.15s ease;
}

.change-video-btn:hover {
  background: #1a2d3d;
  color: #fff;
  border-color: #00f3ff;
}

/* Player View Container */
.music-player-view {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #080c11;
  border-radius: 12px;
  border: 1.5px solid #29465b;
  overflow: hidden;
  margin-bottom: 12px;
  transition: aspect-ratio 0.25s ease, height 0.25s ease;
}

.music-popup-window.mini .music-player-view {
  aspect-ratio: unset;
  height: 60px;
}

.music-player-view iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.music-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  color: #94a3b8;
  background: #080c11;
  gap: 6px;
  pointer-events: none;
}

.music-placeholder.hidden {
  display: none;
}

.placeholder-icon {
  font-size: 26px;
  filter: drop-shadow(0 0 6px #00f3ff);
}

.music-placeholder p {
  font-size: 11px;
  line-height: 1.4;
}

/* Customization Bar (Ukuran & Tata Letak) */
.music-customization-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 243, 255, 0.14);
  font-size: 11px;
}

.music-adjust-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.adjust-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.adjust-label {
  color: #00f3ff;
  font-weight: 700;
  font-size: 11px;
}

.adjust-val {
  color: #e2e8f0;
  font-family: monospace;
  font-size: 11px;
}

.music-slider {
  width: 100%;
  accent-color: #00f3ff;
  cursor: pointer;
  height: 5px;
}

.music-layout-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.music-preset-btns {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.music-pos-btn {
  flex: 1;
  min-width: 70px;
  background: #14202c;
  border: 1px solid #29465b;
  color: #93c5fd;
  padding: 4px 6px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.music-pos-btn:hover {
  background: #1e3346;
  color: #fff;
  border-color: #00f3ff;
}

.music-pos-btn.active {
  background: #00b8d4;
  color: #041016;
  border-color: #00f3ff;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(0, 243, 255, 0.45);
}
