/**
 * VTT (Virtual Tabletop) Styles
 * =============================
 * Styles for the interactive map panel with exploration and combat views.
 */

/* ===========================================================================
   Panel Container
   =========================================================================== */

.vtt-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* ===========================================================================
   Controls Bar
   =========================================================================== */

.vtt-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border-subtle);
}

.vtt-controls__group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.vtt-controls__zoom {
  gap: 0.5rem;
}

.vtt-controls__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.vtt-controls__btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
  border-color: var(--color-border-hover);
}

.vtt-controls__btn:active {
  transform: scale(0.95);
}

.vtt-controls__btn--toggle.active {
  background: var(--color-accent-primary);
  border-color: var(--color-accent-primary);
  color: var(--color-text-primary);
}

.vtt-controls__icon {
  font-size: 1rem;
  font-weight: bold;
  line-height: 1;
}

.vtt-controls__zoom-level {
  min-width: 2.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.vtt-controls__mode-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
}

/* ===========================================================================
   Legend
   =========================================================================== */

.vtt-legend {
  position: absolute;
  top: 3.5rem;
  right: 1rem;
  width: 200px;
  max-height: calc(100% - 5rem);
  overflow-y: auto;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px var(--overlay-medium);
  z-index: 100;
}

.vtt-legend__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.vtt-legend__close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.vtt-legend__close:hover {
  color: var(--color-text-primary);
}

.vtt-legend__content {
  padding: 0.5rem;
}

.vtt-legend__section {
  padding: 0.5rem;
}

.vtt-legend__section:not(:last-child) {
  border-bottom: 1px solid var(--color-border-subtle);
}

.vtt-legend__section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vtt-legend__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.vtt-legend__icon {
  width: 1.25rem;
  text-align: center;
  font-size: 0.875rem;
}

.vtt-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===========================================================================
   Canvas Container
   =========================================================================== */

.vtt-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--color-bg-primary);
}

.vtt-svg-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.vtt-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Canvas overlay for 60fps animations */
.vtt-canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Allow clicks to pass through to SVG */
  z-index: 10; /* Above SVG but below UI elements */
}

/* ===========================================================================
   Background Image
   =========================================================================== */

.vtt-background-image {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.vtt-background-image--loading {
  opacity: 0;
  animation: vtt-bg-fade-in 0.5s ease forwards;
}

.vtt-background-image--removing {
  animation: vtt-bg-fade-out 0.3s ease forwards;
}

@keyframes vtt-bg-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes vtt-bg-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ===========================================================================
   Empty State
   =========================================================================== */

.vtt-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-text-muted);
  text-align: center;
  padding: 2rem;
}

.vtt-empty-state__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.vtt-empty-state__text {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.vtt-empty-state__hint {
  font-size: 0.875rem;
  margin: 0;
  opacity: 0.7;
}

/* ===========================================================================
   Status Bar
   =========================================================================== */

.vtt-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 1rem;
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border-subtle);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.vtt-status__coordinates {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.vtt-status__connection {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.vtt-status__connection.vtt--connected {
  color: var(--color-accent-secondary);
}

.vtt-status__connection.vtt--disconnected {
  color: var(--color-accent-warning);
}

/* ===========================================================================
   SVG Layers
   =========================================================================== */

.vtt-layer {
  /* Base layer styles */
}

.vtt-layer--background {
  /* Background image layer - behind terrain */
}

.vtt-background-image {
  /* Background image - fills the map area */
  opacity: 0.9;
}

.vtt-layer--terrain {
  /* Terrain base layer */
}

.vtt-layer--grid {
  pointer-events: none;
}

.vtt-layer--territory {
  pointer-events: none;
}

.vtt-layer--token {
  /* Token layer - interactive */
}

.vtt-layer--marker {
  /* Marker layer */
}

.vtt-layer--fog {
  pointer-events: none;
}

.vtt-layer--ui {
  pointer-events: none;
}

/* ===========================================================================
   Tokens
   =========================================================================== */

.vtt-token {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.vtt-token:hover {
  transform: scale(1.1);
}

.vtt-token--hover {
  filter: brightness(1.2);
}

.vtt-token--selected {
  filter: drop-shadow(0 0 4px var(--color-accent-primary));
}

.vtt-token--dragging {
  opacity: 0.5;
  pointer-events: none;
}

.vtt-token--removing {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Token types */
.vtt-token--location {
  /* Location pin styling - larger, more prominent */
}

.vtt-token--location circle {
  filter: drop-shadow(0 2px 4px var(--overlay-medium));
}

.vtt-token--npc {
  /* NPC token styling - slightly smaller, offset from locations */
}

.vtt-token--Character {
  /* Player character token styling */
}

.vtt-token--EncounterMonster {
  /* Monster token styling */
}

/* NPC Status indicators */
.vtt-token--status-injured {
  /* Injured NPCs have reduced opacity and red tint */
  opacity: 0.85;
}

.vtt-token--status-hiding {
  /* Hiding NPCs are semi-transparent */
  opacity: 0.6;
}

.vtt-token--status-hiding:hover {
  opacity: 0.9;
}

.vtt-token--status-fled {
  /* Fled NPCs are very faint */
  opacity: 0.3;
  pointer-events: none;
}

.vtt-token--status-transformed {
  /* Transformed NPCs have a glow effect */
  filter: drop-shadow(0 0 4px var(--color-accent-primary));
}

/* Discovery visibility states */
.vtt-token--dimmed {
  /* Discovered but not visited - faded appearance */
  opacity: 0.5;
  filter: saturate(0.5);
}

.vtt-token--dimmed:hover {
  opacity: 0.75;
  filter: saturate(0.7);
}

.vtt-token--appearing {
  /* Animation for newly discovered tokens */
  animation: vtt-token-appear 0.5s ease forwards;
}

@keyframes vtt-token-appear {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.2);
  }
  100% {
    opacity: 0.5;
    transform: scale(1);
  }
}

/* ===========================================================================
   HP Bars
   =========================================================================== */

.vtt-hp-bar {
  pointer-events: none;
}

.vtt-hp-bar__bg {
  /* Background of HP bar - dark */
}

.vtt-hp-bar__fill {
  /* HP fill - animated on change */
  transition: width 0.3s ease-out, fill 0.3s ease-out;
}

.vtt-hp-bar__border {
  /* Border around HP bar */
}

/* HP bar color states - applied via fill attribute, but CSS for hover effects */
.vtt-hp-bar--healthy .vtt-hp-bar__fill {
  fill: #4CAF50; /* Green */
}

.vtt-hp-bar--wounded .vtt-hp-bar__fill {
  fill: #FFC107; /* Yellow/Amber */
}

.vtt-hp-bar--critical .vtt-hp-bar__fill {
  fill: #F44336; /* Red */
  animation: hp-bar-critical-pulse 1s ease-in-out infinite;
}

@keyframes hp-bar-critical-pulse {
  0%, 100% {
    fill-opacity: 1;
  }
  50% {
    fill-opacity: 0.7;
  }
}

/* Show HP text on hover (optional enhancement) */
.vtt-token:hover .vtt-hp-bar__fill {
  filter: brightness(1.2);
}

/* HP bar update animation */
.vtt-hp-bar--updating .vtt-hp-bar__fill {
  animation: hp-bar-update 0.3s ease-out;
}

@keyframes hp-bar-update {
  0% {
    filter: brightness(1.5);
  }
  100% {
    filter: brightness(1);
  }
}

/* HP bar damage flash */
.vtt-hp-bar--damage .vtt-hp-bar__fill {
  animation: hp-bar-damage 0.4s ease-out;
}

@keyframes hp-bar-damage {
  0% {
    filter: brightness(1);
  }
  25% {
    filter: brightness(0.5) saturate(2);
  }
  100% {
    filter: brightness(1);
  }
}

/* HP bar heal flash */
.vtt-hp-bar--heal .vtt-hp-bar__fill {
  animation: hp-bar-heal 0.4s ease-out;
}

@keyframes hp-bar-heal {
  0% {
    filter: brightness(1);
  }
  25% {
    filter: brightness(1.8) saturate(1.5);
  }
  100% {
    filter: brightness(1);
  }
}

/* ===========================================================================
   Tactical Grid Cells
   =========================================================================== */

.vtt-cell {
  cursor: pointer;
  transition: fill 0.1s ease;
}

.vtt-cell:hover {
  filter: brightness(1.2);
}

.vtt-cell--floor {
  /* Floor cell */
}

.vtt-cell--wall {
  cursor: not-allowed;
}

.vtt-cell--water {
  /* Water cell */
}

.vtt-cell--difficult {
  /* Difficult terrain */
}

.vtt-cell--door {
  /* Door cell */
}

.vtt-cell--pit {
  cursor: not-allowed;
}

/* ===========================================================================
   Fog of War
   =========================================================================== */

.vtt-fog-cell {
  transition: fill-opacity 0.5s ease;
}

.vtt-fog-cell--unexplored {
  /* Full fog - never seen */
  fill-opacity: 1;
}

.vtt-fog-cell--explored {
  /* Dim fog - previously seen */
  fill-opacity: 0.5;
}

.vtt-fog-cell--visible,
.vtt-fog-cell--revealed {
  /* No fog - currently visible */
  fill-opacity: 0;
}

/* Location-based fog for exploration mode */
.vtt-fog-location {
  transition: opacity 0.5s ease, fill-opacity 0.5s ease;
}

.vtt-fog-location--hidden {
  /* Full fog over undiscovered locations */
  opacity: 1;
}

.vtt-fog-location--dimmed {
  /* Partial fog over discovered-but-not-visited locations */
  opacity: 1;
}

.vtt-fog-location--revealing {
  /* Animation state when fog is being lifted */
  animation: vtt-fog-reveal 0.5s ease forwards;
}

@keyframes vtt-fog-reveal {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.1);
  }
  100% {
    opacity: 0;
    transform: scale(1.2);
  }
}

/* ===========================================================================
   Territories
   =========================================================================== */

.vtt-territory {
  transition: fill-opacity 0.2s ease;
}

.vtt-territory:hover {
  fill-opacity: 0.25;
}

/* ===========================================================================
   Markers
   =========================================================================== */

.vtt-marker {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.vtt-marker:hover {
  transform: scale(1.2);
}

.vtt-marker--quest {
  /* Quest marker */
}

.vtt-marker--rumor {
  /* Rumor marker */
}

.vtt-marker--treasure {
  /* Treasure marker */
}

.vtt-marker--danger {
  /* Danger marker */
}

/* ===========================================================================
   Path Preview
   =========================================================================== */

.vtt-path-preview {
  fill: none;
  stroke: var(--color-accent-primary);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  stroke-opacity: 0.8;
}

.vtt-path-preview--pending {
  stroke: var(--color-accent-primary);
  stroke-dasharray: 8 4;
  stroke-opacity: 0.5;
  animation: path-dash 0.5s linear infinite;
}

.vtt-path-preview--valid {
  stroke: #4CAF50;
  stroke-dasharray: none;
}

.vtt-path-preview--invalid,
.vtt-path-preview.path-invalid {
  stroke: #F44336;
  stroke-dasharray: 5 5;
}

@keyframes path-dash {
  to {
    stroke-dashoffset: -12;
  }
}

/* ===========================================================================
   Reachable Overlay
   =========================================================================== */

.vtt-reachable-overlay {
  pointer-events: none;
}

.vtt-reachable-cell {
  transition: fill-opacity 0.2s ease;
}

/* ===========================================================================
   Combat Overlays
   =========================================================================== */

.vtt-layer--combat-overlays,
.vtt-combat-overlays {
  pointer-events: none;
}

/* Threat Zones */
.vtt-threat-overlay {
  pointer-events: none;
}

.vtt-threat-cell {
  transition: fill-opacity 0.3s ease;
}

/* Attack Range */
.vtt-range-overlay {
  pointer-events: none;
}

.vtt-range-cell {
  transition: fill-opacity 0.2s ease;
}

.vtt-range-cell--valid {
  cursor: crosshair;
  pointer-events: auto;
}

/* ===========================================================================
   Spell Templates
   =========================================================================== */

.vtt-spell-template {
  pointer-events: none;
}

.vtt-spell-cell {
  transition: fill-opacity 0.3s ease;
}

.vtt-spell-cell--circle,
.vtt-spell-cell--sphere {
  animation: spell-pulse 1.5s ease-in-out infinite;
}

.vtt-spell-cell--cone {
  animation: spell-sweep 0.8s ease-out;
}

.vtt-spell-cell--line {
  animation: spell-bolt 0.4s ease-out;
}

@keyframes spell-pulse {
  0%, 100% {
    fill-opacity: 0.3;
  }
  50% {
    fill-opacity: 0.5;
  }
}

@keyframes spell-sweep {
  0% {
    fill-opacity: 0;
    transform: scale(0.5);
  }
  100% {
    fill-opacity: 0.4;
    transform: scale(1);
  }
}

@keyframes spell-bolt {
  0% {
    fill-opacity: 0;
  }
  50% {
    fill-opacity: 0.8;
  }
  100% {
    fill-opacity: 0.4;
  }
}

.vtt-spell-origin {
  animation: origin-pulse 1s ease-in-out infinite;
}

@keyframes origin-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

.vtt-spell-direction {
  stroke-dasharray: 4 2;
  animation: direction-dash 0.5s linear infinite;
}

@keyframes direction-dash {
  to {
    stroke-dashoffset: -6;
  }
}

/* ===========================================================================
   Opportunity Attack Warnings
   =========================================================================== */

.vtt-oa-warnings {
  pointer-events: none;
}

.vtt-oa-warning circle {
  animation: oa-pulse 0.8s ease-in-out infinite;
}

@keyframes oa-pulse {
  0%, 100% {
    transform: scale(1);
    fill-opacity: 1;
  }
  50% {
    transform: scale(1.3);
    fill-opacity: 0.7;
  }
}

/* ===========================================================================
   Cost Labels
   =========================================================================== */

.vtt-cost-label {
  pointer-events: none;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
}

/* ===========================================================================
   Route Preview (Travel Routes)
   =========================================================================== */

.vtt-route-preview {
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.vtt-route-preview--appearing {
  animation: vtt-route-appear 0.5s ease forwards;
}

.vtt-route-preview--fading {
  opacity: 0;
}

@keyframes vtt-route-appear {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.vtt-route-path {
  stroke-dashoffset: 0;
  animation: vtt-route-dash 20s linear infinite;
}

@keyframes vtt-route-dash {
  to {
    stroke-dashoffset: -100;
  }
}

.vtt-route-waypoint {
  /* Waypoint markers along the route */
}

.vtt-route-endpoint {
  /* Start/end markers */
}

.vtt-route-endpoint--start circle {
  fill: #2196F3; /* Blue for start */
}

.vtt-route-endpoint--end circle {
  fill: #4CAF50; /* Green for destination */
}

.vtt-route-label {
  /* Travel time/difficulty label */
  font-family: var(--font-mono);
}

.vtt-route-label text {
  fill: var(--color-text-primary);
}

/* ===========================================================================
   Measurement Tool
   =========================================================================== */

.vtt--measuring {
  cursor: crosshair;
}

.vtt--measuring .vtt-canvas-container {
  cursor: crosshair;
}

.vtt-controls__tools {
  gap: 0.5rem;
}

.vtt-controls__measure-display {
  font-size: 0.875rem;
  font-family: var(--font-mono);
  color: var(--color-accent-primary);
  min-width: 80px;
}

.vtt-measurement {
  pointer-events: none;
}

.vtt-measurement__line {
  stroke: #FFD700;
  stroke-width: 3;
  stroke-dasharray: 8 4;
  stroke-linecap: round;
  animation: vtt-measurement-dash 0.5s linear infinite;
}

@keyframes vtt-measurement-dash {
  to {
    stroke-dashoffset: -12;
  }
}

.vtt-measurement__start,
.vtt-measurement__end {
  fill: #FFD700;
  filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.6));
}

.vtt-measurement__label {
  fill: #FFD700;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.vtt-measurement__label-bg {
  fill: rgba(0, 0, 0, 0.8);
  rx: 4;
}

/* ===========================================================================
   Selection Box
   =========================================================================== */

.vtt-selection-box {
  fill: var(--color-accent-primary);
  fill-opacity: 0.1;
  stroke: var(--color-accent-primary);
  stroke-width: 1;
  stroke-dasharray: 3 2;
  pointer-events: none;
}

/* ===========================================================================
   Drag Ghost
   =========================================================================== */

.vtt-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
}

.vtt-drag-ghost__content {
  padding: 0.5rem 1rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-accent-primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px var(--overlay-medium-plus);
}

.vtt-drag-ghost__name {
  font-size: 0.875rem;
  color: var(--color-text-primary);
  white-space: nowrap;
}

/* ===========================================================================
   Panning State
   =========================================================================== */

.vtt-panel.vtt--panning {
  cursor: grabbing;
}

.vtt-panel.vtt--panning .vtt-canvas {
  cursor: grabbing;
}

/* ===========================================================================
   Connection States
   =========================================================================== */

.vtt-panel.vtt--connected .vtt-status__connection {
  color: var(--color-accent-secondary);
}

.vtt-panel.vtt--connected .vtt-status__connection::before {
  content: "⬤ ";
}

.vtt-panel.vtt--disconnected .vtt-status__connection {
  color: var(--color-accent-warning);
}

/* ===========================================================================
   Responsive
   =========================================================================== */

@media (max-width: 768px) {
  .vtt-controls {
    flex-wrap: wrap;
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .vtt-controls__group {
    flex: 1;
    justify-content: center;
  }

  .vtt-controls__layers {
    order: 3;
    width: 100%;
  }
}

/* ===========================================================================
   DM Toolbar (Phase F)
   =========================================================================== */

.vtt-dm-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border-subtle);
  border-top: 1px dashed var(--color-accent-primary);
}

.dm-toolbar__section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dm-toolbar__tools {
  padding-right: 1rem;
  border-right: 1px solid var(--color-border-default);
}

.dm-toolbar__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.875rem;
}

.dm-toolbar__btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
  border-color: var(--color-border-hover);
}

.dm-toolbar__btn:active {
  transform: scale(0.95);
}

.dm-toolbar__btn.active {
  background: var(--color-accent-primary);
  border-color: var(--color-accent-primary);
  color: var(--color-text-primary);
}

.dm-toolbar__btn--small {
  min-width: 1.75rem;
  height: 1.75rem;
  font-size: 0.75rem;
}

.dm-toolbar__btn--quick {
  padding: 0 0.75rem;
  gap: 0.25rem;
  font-size: 0.75rem;
}

.dm-toolbar__icon {
  font-size: 1rem;
  line-height: 1;
}

.dm-toolbar__label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.dm-toolbar__slider {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: var(--color-bg-tertiary);
  border-radius: 2px;
  outline: none;
}

.dm-toolbar__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--color-accent-primary);
  border-radius: 50%;
  cursor: pointer;
}

.dm-toolbar__slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--color-accent-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.dm-toolbar__fog-options {
  padding: 0 0.5rem;
  border-right: 1px solid var(--color-border-default);
}

.dm-toolbar__quick-actions {
  gap: 0.25rem;
}

.dm-toolbar__status {
  flex: 1;
  justify-content: flex-end;
}

.dm-toolbar__status-text {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.dm-toolbar__status--info {
  color: var(--color-text-secondary);
}

.dm-toolbar__status--error {
  color: var(--color-accent-error);
}

.dm-toolbar__status--success {
  color: var(--color-accent-secondary);
}

/* DM Toolbar responsive */
@media (max-width: 1024px) {
  .vtt-dm-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .dm-toolbar__quick-actions {
    order: 4;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .vtt-dm-toolbar {
    padding: 0.5rem;
  }

  .dm-toolbar__fog-options {
    display: none;
  }

  .dm-toolbar__quick-actions .dm-toolbar__btn--quick span:not(.dm-toolbar__icon) {
    display: none;
  }
}

/* ===========================================================================
   Mobile-Optimized Toolbar (Phase 6)
   44px minimum touch targets, responsive layout, touch-friendly interactions
   =========================================================================== */

/* Tablet breakpoint - improve spacing and touch targets */
@media (max-width: 768px) {
  /* Minimum 44px touch targets per Apple/Google HIG */
  .vtt-controls__btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  .vtt-controls__icon {
    font-size: 1.125rem;
  }

  .vtt-controls {
    gap: 0.5rem;
    padding: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .vtt-controls__group {
    gap: 0.5rem;
  }

  .vtt-controls__zoom {
    order: 1;
  }

  .vtt-controls__layers {
    order: 2;
  }

  .vtt-controls__tools {
    order: 3;
  }

  .vtt-controls__mode {
    order: 4;
    width: 100%;
    justify-content: center;
  }

  .vtt-controls__zoom-level {
    font-size: 1rem;
    min-width: 3rem;
  }

  .vtt-controls__mode-label {
    font-size: 0.875rem;
  }

  /* DM Toolbar mobile optimizations */
  .dm-toolbar__btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  .dm-toolbar__btn--quick {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
  }

  .dm-toolbar__btn--small {
    min-width: 40px;
    min-height: 40px;
  }

  /* VTT Legend mobile */
  .vtt-legend {
    max-width: 280px;
    max-height: 60vh;
  }

  .vtt-legend__close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* VTT Status bar mobile */
  .vtt-status {
    font-size: 0.875rem;
    padding: 0.5rem;
  }
}

/* Mobile phone breakpoint - maximize touch targets and simplify UI */
@media (max-width: 480px) {
  .vtt-panel {
    border-radius: 0;
    border: none;
  }

  .vtt-controls {
    padding: 0.5rem;
    gap: 0.25rem;
  }

  /* Stack controls vertically on very small screens */
  .vtt-controls__group {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Larger touch targets for phone */
  .vtt-controls__btn {
    min-width: 48px;
    min-height: 48px;
    width: 48px;
    height: 48px;
  }

  .vtt-controls__icon {
    font-size: 1.25rem;
  }

  .vtt-controls__zoom-level {
    font-size: 1.125rem;
    min-width: 3.5rem;
  }

  /* Hide mode label on very small screens - save space */
  .vtt-controls__mode {
    display: none;
  }

  /* Simplify DM toolbar on phone */
  .vtt-dm-toolbar {
    padding: 0.25rem 0.5rem;
    gap: 0.25rem;
  }

  .dm-toolbar__btn {
    min-width: 48px;
    min-height: 48px;
  }

  .dm-toolbar__btn--quick {
    min-width: 48px;
    padding: 0.5rem;
    gap: 0.25rem;
  }

  /* Hide text labels on quick actions, show only icons */
  .dm-toolbar__btn--quick span:last-child {
    display: none;
  }

  .dm-toolbar__section {
    gap: 0.25rem;
  }

  /* Hide non-essential sections on phone */
  .dm-toolbar__status {
    display: none;
  }

  /* VTT Legend - full width on phone */
  .vtt-legend {
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    max-width: 100%;
    max-height: 40vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  /* Status bar more compact */
  .vtt-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Touch-friendly states */
@media (pointer: coarse) {
  /* Larger hit areas for touch devices */
  .vtt-controls__btn,
  .dm-toolbar__btn {
    position: relative;
  }

  /* Expand touch target beyond visible button */
  .vtt-controls__btn::before,
  .dm-toolbar__btn::before {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    bottom: -4px;
    left: -4px;
  }

  /* Disable hover states on touch devices - use active instead */
  .vtt-controls__btn:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border-color: var(--color-border-default);
  }

  .vtt-controls__btn:active {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
    border-color: var(--color-border-hover);
    transform: scale(0.95);
  }

  .dm-toolbar__btn:hover {
    background: var(--color-bg-tertiary);
  }

  .dm-toolbar__btn:active {
    background: var(--color-bg-hover);
    transform: scale(0.95);
  }

  /* Prevent text selection on touch */
  .vtt-controls,
  .vtt-dm-toolbar {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }

  /* VTT canvas touch handling */
  .vtt-canvas-container {
    touch-action: none; /* Disable browser handling - we manage gestures */
    user-select: none;
    -webkit-user-select: none;
  }
}

/* Pinch-to-zoom visual feedback */
.vtt--pinching .vtt-canvas-container {
  cursor: zoom-in;
}

.vtt--pinching .vtt-controls__zoom-level {
  color: var(--color-accent-primary);
  font-weight: bold;
}

/* Touch panning indicator */
.vtt--touch-panning .vtt-canvas-container {
  cursor: grabbing;
}

/* Landscape phone optimization */
@media (max-width: 768px) and (max-height: 480px) and (orientation: landscape) {
  .vtt-controls {
    padding: 0.25rem 0.5rem;
    gap: 0.25rem;
  }

  .vtt-controls__btn {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
  }

  .vtt-dm-toolbar {
    padding: 0.25rem 0.5rem;
  }

  .dm-toolbar__btn {
    min-width: 40px;
    min-height: 40px;
  }

  /* Single row toolbar in landscape */
  .vtt-dm-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
  }

  .vtt-dm-toolbar::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }
}
