/**
 * CrewLink Global Course Directory & Race Browser
 * Layout & Discovery Viewport Stylesheet
 * Integrates with: tokens.css, pages.css (header/logo), modals.css (buttons/inputs)
 */

:root {
  --directory-header-height: 64px;
}

body.dir-body {
  margin: 0;
  padding: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--palette-slate-950);
}

/* =========================================================================
   TOP HEADER NAVIGATION BAR
   ========================================================================= */
.dir-header {
  height: var(--directory-header-height);
  flex-shrink: 0;
  padding: 0 var(--space-4);
  background: var(--color-bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border-subtle);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}

.dir-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.dir-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  margin-left: auto;
}

@media (max-width: 650px) {
  .dir-header {
    height: var(--directory-header-height);
    padding: 0 var(--space-3);
    flex-wrap: nowrap;
  }
}

#runner-channel-indicator {
  display: flex;
  align-items: center;
}

#runner-channel-indicator a,
#runner-channel-indicator a:hover,
#runner-channel-indicator a:focus,
#runner-channel-indicator a:visited,
.runner-pill,
.runner-pill:hover,
.runner-pill:focus,
.runner-pill:visited {
  text-decoration: none !important;
}

.runner-pill .runner-pill-name {
  text-decoration: none !important;
}

.dir-runner-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 var(--space-3);
  background: rgba(var(--palette-lime-rgb), 0.12);
  border: 1px solid rgba(var(--palette-lime-rgb), 0.35);
  border-radius: var(--radius-full);
  color: var(--palette-lime);
  font-size: 0.82rem;
  font-weight: 600;
}

.dir-runner-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--palette-lime);
}

.dir-btn-sync.syncing {
  opacity: 0.75;
  pointer-events: none;
}

.dir-btn-sync.syncing .dir-sync-icon {
  animation: dirSpin 0.8s linear infinite;
}

/* Visibility helper */
.is-hidden {
  display: none !important;
}

/* =========================================================================
   SEARCH & FILTER TOOLBAR
   ========================================================================= */
.dir-toolbar {
  flex-shrink: 0;
  background: var(--palette-slate-900);
  border-bottom: 1px solid var(--color-border-subtle);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.dir-toolbar-top {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.dir-search-wrap {
  flex: 0 1 280px;
  width: 280px;
  max-width: 320px;
  min-width: 180px;
  position: relative;
  display: flex;
  align-items: center;
  height: 40px;
}

.dir-search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--palette-slate-400);
  pointer-events: none;
}

.dir-search-input {
  width: 100%;
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
  padding: 0 40px 0 42px;
  background: var(--color-bg-glass-input);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  color: var(--palette-slate-100);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dir-search-input:focus {
  border-color: var(--palette-sky);
  box-shadow: 0 0 0 3px rgba(var(--palette-sky-rgb), 0.25);
}

.dir-search-clear {
  position: absolute;
  right: 10px;
  min-width: 28px;
  min-height: 28px;
  background: transparent;
  border: none;
  color: var(--palette-slate-400);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dir-search-clear:hover {
  color: var(--palette-white);
  background: var(--palette-slate-700);
}

/* Filter Dropdown Groups */
.dir-filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  height: 40px;
}

.dir-select-filter {
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
  padding: 0 var(--space-3);
  background: var(--color-bg-glass-input);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  color: var(--palette-slate-200);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dir-select-filter:hover {
  border-color: var(--color-border-strong);
}

.dir-select-filter:focus {
  border-color: var(--palette-sky);
  box-shadow: 0 0 0 3px rgba(var(--palette-sky-rgb), 0.25);
}

/* RHS Toolbar Actions (Add Course & Sync Catalog) */
.dir-toolbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.dir-toolbar-actions .btn-action {
  height: 40px !important;
  min-height: 40px !important;
  box-sizing: border-box !important;
  padding: 0 14px !important;
  font-size: 0.88rem !important;
}

/* Custom Date Inputs */
.dir-date-range-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: var(--space-1);
  height: 40px;
}

.dir-date-range-wrap.is-hidden {
  display: none !important;
}

.dir-date-separator {
  font-size: 0.78rem;
  color: var(--palette-slate-500);
}

.dir-date-input {
  width: 135px;
  min-width: 130px;
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
  padding: 0 var(--space-2);
  background: var(--color-bg-glass-input);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  color: var(--palette-slate-200);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  color-scheme: dark;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dir-date-input:focus {
  border-color: var(--palette-sky);
  box-shadow: 0 0 0 3px rgba(var(--palette-sky-rgb), 0.25);
}

.dir-date-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(0.85);
  opacity: 0.85;
  margin-left: 4px;
}

.dir-date-input::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* Filter Pills Rows */
.dir-filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.dir-filter-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  white-space: nowrap;
  cursor: pointer;
}

.dir-pill {
  min-height: 36px;
  padding: 0 var(--space-3);
  background: var(--palette-slate-800);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-full);
  color: var(--palette-slate-300);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.dir-pill:hover {
  background: var(--palette-slate-750);
  color: var(--palette-white);
  border-color: var(--palette-slate-600);
}

.dir-pill.active {
  background: rgba(var(--palette-cyan-rgb), 0.15);
  border-color: var(--palette-cyan);
  color: var(--palette-cyan);
  font-weight: 600;
}

/* Custom Date Inputs */
.dir-date-range-wrap {
  display: none;
  align-items: center;
  gap: var(--space-2);
  margin-left: var(--space-2);
}

.dir-date-separator,
.dir-results-provider {
  font-size: 0.78rem;
  color: var(--palette-slate-500);
}

.dir-date-input {
  min-height: 36px;
  padding: 0 var(--space-2);
  background: var(--color-bg-glass-input);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  color: var(--palette-slate-200);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  outline: none;
}

.dir-date-input:focus {
  border-color: var(--palette-sky);
}

/* =========================================================================
   MAIN LAYOUT CONTAINER (SPLIT VIEW)
   ========================================================================= */
.dir-main-container {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  overflow: hidden;
  position: relative;
  height: auto;
}

/* Left Pane: Course List */
.dir-list-pane {
  flex: 0 0 460px;
  max-width: 520px;
  min-height: 0;
  height: 100%;
  border-right: 1px solid var(--color-border-subtle);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--palette-slate-950);
}

.dir-list-header {
  flex-shrink: 0;
  padding: 8px var(--space-4);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--palette-slate-400);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--palette-slate-900);
  z-index: 10;
  gap: var(--space-2);
}

.dir-course-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: var(--space-2);
  gap: var(--space-2);
}

/* Course Card (Refined & Compact) */
.dir-course-card {
  background: var(--palette-slate-850);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.dir-course-card:hover {
  background: var(--palette-slate-800);
  border-color: var(--palette-slate-500);
  transform: translateY(-1px);
}

.dir-course-card.selected {
  border-color: var(--palette-cyan);
  background: rgba(var(--palette-cyan-rgb), 0.08);
  box-shadow: 0 0 0 1px var(--palette-cyan);
}

.dir-card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
}

.dir-card-meta-left {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--palette-slate-400);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dir-card-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--palette-sky);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.dir-card-loc {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--palette-slate-400);
}

.dir-card-dist-away {
  color: var(--palette-sky);
  font-weight: 600;
  flex-shrink: 0;
}

.dir-card-meta-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dir-card-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--palette-slate-200);
  font-weight: 600;
  font-size: 0.8rem;
}

.dir-card-stat svg {
  width: 13px;
  height: 13px;
  color: var(--palette-slate-400);
  flex-shrink: 0;
}

.dir-card-itra {
  color: var(--palette-amber-400, #fbbf24);
  font-weight: 700;
  font-size: 0.74rem;
}

.dir-card-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--palette-white);
  line-height: 1.3;
}

/* Empty / Loading State */
.dir-state-container {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--palette-slate-400);
}

.dir-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(var(--palette-cyan-rgb), 0.2);
  border-top-color: var(--palette-cyan);
  border-radius: var(--radius-full);
  animation: dirSpin 0.8s linear infinite;
}

@keyframes dirSpin {
  to { transform: rotate(360deg); }
}

/* =========================================================================
   RIGHT PANE: LIVE VECTOR PREVIEW (MAP & ELEVATION)
   ========================================================================= */
.dir-preview-pane {
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--palette-slate-900);
  position: relative;
  overflow: hidden;
}

.dir-preview-header {
  flex-shrink: 0;
  padding: 10px 16px;
  background: var(--palette-slate-850);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.dir-preview-title-row {
  width: 100%;
  min-width: 0;
}

.dir-preview-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--palette-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.3;
}

.dir-preview-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.dir-preview-subtitle {
  font-size: 0.82rem;
  color: var(--palette-slate-400);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.dir-preview-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--palette-slate-200);
  font-weight: 600;
}

.dir-preview-stat svg {
  width: 13px;
  height: 13px;
  color: var(--palette-slate-400);
}

.dir-preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dir-btn-close-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  color: var(--palette-slate-400);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-default);
  cursor: pointer;
  transition: all 0.15s ease;
}

.dir-btn-close-preview:hover {
  color: var(--palette-white);
  background: var(--palette-slate-700);
  border-color: var(--palette-slate-500);
}

/* Map Section */
.dir-map-wrap {
  flex: 1 1 0;
  min-height: 200px;
  position: relative;
  overflow: hidden;
}

#preview-map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: var(--palette-slate-950);
}

/* Elevation Profile Section */
.dir-elevation-wrap {
  flex-shrink: 0;
  height: 150px;
  background: var(--palette-slate-950);
  border-top: 1px solid var(--color-border-subtle);
  position: relative;
  padding: 6px 12px;
}

#preview-elevation-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Waypoints / Aid Stations Chip Strip */
.dir-waypoints-strip {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--palette-slate-900);
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dir-wpt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--palette-slate-800);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  font-size: 0.78rem;
  color: var(--palette-slate-200);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.dir-wpt-chip:hover {
  background: var(--palette-slate-700);
  border-color: var(--palette-cyan);
  color: var(--palette-white);
}

.dir-wpt-chip.active {
  background: rgba(var(--palette-cyan-rgb), 0.2);
  border-color: var(--palette-cyan);
  color: var(--palette-cyan);
}

.dir-wpt-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
}

/* Preview Subtitle Metadata */
.dir-preview-source {
  color: var(--palette-slate-400);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Empty / Error state typography */
.dir-empty-title {
  font-size: 0.95rem;
  color: var(--palette-slate-300);
}

.dir-empty-sub {
  font-size: 0.8rem;
  color: var(--palette-slate-500);
}

.dir-error-title {
  color: var(--color-status-alert);
}

.dir-error-sub {
  font-size: 0.8rem;
  color: var(--palette-slate-400);
}

.dir-chip-distance {
  color: var(--palette-sky);
  border-color: rgba(var(--palette-sky-rgb), 0.3);
}

.dir-wpt-chip-dist {
  color: var(--palette-sky);
  font-size: 0.72rem;
  font-weight: 700;
}

/* =========================================================================
   RESPONSIVE MEDIA QUERIES (MOBILE FIRST)
   ========================================================================= */
@media (max-width: 900px) {
  .dir-main-container {
    flex: 1 1 0;
    min-height: 0;
    flex-direction: column;
    height: auto;
  }

  .dir-list-pane {
    flex: 1 1 0;
    min-height: 0;
    max-width: 100%;
    border-right: none;
    border-bottom: none;
  }

  .dir-preview-pane {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: none; /* toggled via JS */
  }

  .dir-preview-pane.mobile-open {
    display: flex;
  }

  .dir-map-wrap {
    flex: 1 1 0;
    min-height: 200px;
    position: relative;
  }

  .dir-elevation-wrap {
    flex-shrink: 0;
    height: 130px;
  }
}

/* =========================================================================
   SORT CONTROLS (IN LIST HEADER - SUBTLE & COMPACT)
   ========================================================================= */
.dir-list-header .dir-sort-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.dir-list-header .dir-sort-label {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--palette-slate-400);
  white-space: nowrap;
}

.dir-list-header .dir-select-sort {
  height: 28px;
  min-height: 28px;
  box-sizing: border-box;
  padding: 0 8px;
  background: var(--color-bg-glass-input);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  color: var(--palette-slate-200);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dir-list-header .dir-select-sort:hover {
  border-color: var(--color-border-strong);
}

.dir-list-header .dir-select-sort:focus {
  border-color: var(--palette-sky);
  box-shadow: 0 0 0 2px rgba(var(--palette-sky-rgb), 0.25);
}

/* =========================================================================
   FLOATING SPATIAL "SEARCH THIS AREA" BUTTON
   ========================================================================= */
.dir-btn-search-area {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  box-sizing: border-box;
  background: var(--color-bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-full);
  color: var(--palette-slate-100);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  animation: dirFadeInDown 0.25s ease-out;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.dir-btn-search-area svg {
  color: var(--palette-sky);
  flex-shrink: 0;
}

.dir-btn-search-area:hover {
  background: var(--color-bg-surface-elevated);
  border-color: var(--palette-sky);
  color: var(--palette-white);
  transform: translate(-50%, -1px) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55), 0 0 12px rgba(var(--palette-sky-rgb), 0.25);
}

.dir-btn-search-area:active {
  transform: translate(-50%, 0) !important;
}

@keyframes dirFadeInDown {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* =========================================================================
   MAP RESULT PIN MARKERS
   ========================================================================= */
.dir-pin-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--palette-slate-900);
  border: 2px solid var(--palette-sky);
  color: var(--palette-white);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dir-pin-marker:hover,
.dir-pin-marker.highlighted {
  transform: scale(1.22);
  border-color: var(--palette-lime);
  background: var(--palette-slate-800);
  box-shadow: 0 0 12px rgba(var(--palette-lime-rgb), 0.6);
  z-index: 1000 !important;
}

.dir-pin-marker.selected {
  transform: scale(1.15);
  border-color: var(--palette-cyan);
  background: var(--palette-slate-800);
  color: var(--palette-cyan);
  box-shadow: 0 0 10px rgba(var(--palette-cyan-rgb), 0.5);
  z-index: 1001 !important;
}

.dir-pin-badge {
  pointer-events: none;
}

/* =========================================================================
   MAP PIN INSTANT HOVER TOOLTIP (DARK OBSIDIAN GLASS)
   ========================================================================= */
.leaflet-tooltip.dir-pin-tooltip {
  background: rgba(15, 23, 42, 0.96) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid var(--color-border-default) !important;
  border-radius: var(--radius-md) !important;
  padding: 8px 14px !important;
  color: var(--color-text-primary) !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65) !important;
  pointer-events: none !important;
  white-space: normal !important;
  min-width: 280px !important;
  max-width: 480px !important;
  width: max-content !important;
}

.leaflet-tooltip.dir-pin-tooltip::before {
  border-top-color: var(--color-border-default) !important;
}

.dir-pin-tooltip-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 460px;
}

.dir-pin-tooltip-title {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--palette-white);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dir-pin-tooltip-meta {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.dir-pin-tooltip-dist {
  color: var(--palette-lime);
  font-weight: 700;
}

.dir-pin-tooltip-elev {
  color: var(--palette-slate-300);
  font-weight: 500;
}

.dir-pin-tooltip-date {
  color: var(--color-text-muted);
}

.dir-pin-tooltip-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.74rem;
  color: var(--palette-slate-400);
  margin-top: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 4px;
}

.dir-pin-tooltip-loc {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dir-pin-tooltip-away {
  flex-shrink: 0;
  white-space: nowrap;
  color: var(--palette-sky);
  font-weight: 600;
}

/* =========================================================================
   MOBILE VIEW TOGGLE & PEEK CARD
   ========================================================================= */
.dir-btn-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2500; /* Must float strictly above .dir-preview-pane (z-index: 2000) */
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  background: var(--palette-slate-900);
  border: 1px solid rgba(var(--palette-lime-rgb), 0.5);
  color: var(--palette-white);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dir-btn-mobile-toggle:hover {
  background: var(--palette-slate-800);
  border-color: var(--palette-lime);
}

.dir-btn-mobile-toggle svg {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex-shrink: 0;
}

/* =========================================================================
   ADMIN ADD COURSE MODAL
   ========================================================================= */
.modal-admin-course {
  max-width: 620px;
  width: 95%;
}

.admin-tab-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border-subtle);
  padding-bottom: 8px;
}

.admin-tab {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--palette-slate-400);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.admin-tab:hover {
  color: var(--palette-slate-200);
}

.admin-tab.active {
  background: var(--palette-slate-800);
  color: var(--palette-lime);
  border-color: rgba(var(--palette-lime-rgb), 0.3);
}

.admin-course-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-url-row .form-input {
  flex: 1;
  min-width: 0;
}

.admin-url-row .btn-action {
  flex-shrink: 0;
  white-space: nowrap;
}

.admin-file-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--palette-slate-800);
  border: 1px solid var(--color-border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  max-width: 100%;
}

.admin-file-icon {
  color: var(--palette-lime);
  flex-shrink: 0;
}

.admin-filename-text {
  color: var(--color-text-main);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-file-meta {
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1.2fr 1.5fr 0.8fr;
  gap: 12px;
}

.admin-form-status {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
}

.admin-form-status.status-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #fca5a5;
}

.admin-form-status.status-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  color: #6ee7b7;
}

@media (max-width: 900px) {
  .dir-btn-mobile-toggle {
    display: inline-flex;
    bottom: 12px;
  }

  .dir-btn-mobile-toggle.elevation-raised {
    bottom: 144px;
  }

  .dir-search-wrap {
    flex: 1 1 240px;
    max-width: 100%;
  }

  .form-row-2,
  .form-row-3 {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

@media (max-width: 650px) {
  .dir-toolbar-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }
}
