/**
 * 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-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===========================================================================
   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--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));
}

/* ===========================================================================
   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: opacity 0.5s ease;
}

.vtt-fog-cell--revealed {
  opacity: 0;
}

/* ===========================================================================
   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: 2;
  stroke-dasharray: 5 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.vtt-path-preview.path-invalid {
  stroke: var(--color-accent-error);
}

/* ===========================================================================
   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;
  }
}
