/**
 * Skills Addon - Map Widget Styles
 * v7.0.0 FINAL (header fuera, popup centrado, limpio)
 */

/* ==================== 0. RESET ==================== */
.skills-map-wrapper,
.skills-map-wrapper * {
  box-sizing: border-box;
}

.skills-map-wrapper button,
.skills-map-wrapper a {
  -webkit-tap-highlight-color: transparent;
}

.skills-map-wrapper :focus-visible {
  outline: 2px solid rgba(74, 144, 217, 0.5);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ==================== 1. VARIABLES ==================== */
.skills-map-wrapper {
  --tmap-blue: #4a90d9;
  --tmap-blue-dark: #3a7bc8;
  --tmap-blue-light: #e3f2fd;
  --tmap-orange: #e8923a;
  --tmap-white: #ffffff;
  --tmap-bg: #f5f7fa;
  --tmap-text: #2d3748;
  --tmap-text-light: #718096;
  --tmap-border: rgba(0, 0, 0, 0.08);
  --tmap-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  --tmap-radius: 16px;

  --tmap-height: 550px;

  --popup-width: 340px;
  --popup-max-width: 92vw;
  --popup-max-height: 480px;
}

/* ==================== 2. WRAPPER ==================== */
.skills-map-wrapper {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  width: 100%;
  position: relative;
  border-radius: var(--tmap-radius);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  background: var(--tmap-white);
}

/* ==================== 3. HEADER FUERA DEL MAPA ==================== */
.tmap-header-outer {
  position: relative;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--tmap-blue), var(--tmap-blue-dark));
  border-radius: var(--tmap-radius) var(--tmap-radius) 0 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 68px;
}

.tmap-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.tmap-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 6px;
}

.tmap-icon svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
}

.tmap-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tmap-header-btns {
  display: flex;
  gap: 8px;
}

.tmap-btn {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tmap-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.tmap-btn-ghost {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.tmap-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

.tmap-btn-primary {
  background: #fff;
  color: var(--tmap-blue);
  border: 1px solid transparent;
}

.tmap-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ==================== 4. MAP SECTION ==================== */
.tmap-map-section {
  position: relative;
  width: 100%;
  height: var(--tmap-height);
  background: #e8eef3;
  overflow: hidden;
  z-index: 1;
}

.tmap-container {
  width: 100%;
  height: 100%;
}

/* Mapbox controls nativos */
.skills-map-wrapper .mapboxgl-ctrl-top-right,
.skills-map-wrapper .mapboxgl-ctrl-bottom-right {
  z-index: 5;
}

.skills-map-wrapper .mapboxgl-ctrl-group {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  border: none;
}

.skills-map-wrapper .mapboxgl-ctrl-group button {
  width: 32px;
  height: 32px;
  border-radius: 0;
}

.skills-map-wrapper .mapboxgl-ctrl-group button:first-child {
  border-radius: 8px 8px 0 0;
}

.skills-map-wrapper .mapboxgl-ctrl-group button:last-child {
  border-radius: 0 0 8px 8px;
}

.skills-map-wrapper .mapboxgl-ctrl-group button + button {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* ==================== 5. LOADING ==================== */
.tmap-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  z-index: 100;
  transition: opacity 0.3s ease;
}

.tmap-loading.hide {
  opacity: 0;
  pointer-events: none;
}

.tmap-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--tmap-blue-light);
  border-top-color: var(--tmap-blue);
  border-radius: 50%;
  animation: tmap-spin 0.8s linear infinite;
}

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

/* ==================== 6. MARKERS ==================== */
.tmap-marker-main,
.tmap-marker-entry {
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  transition: transform 0.2s ease;
}

.tmap-marker-main:hover {
  transform: scale(1.05);
}

.tmap-marker-entry:hover {
  transform: translateY(-2px);
}

.tmap-pin {
  width: 48px;
  height: 62px;
  position: relative;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.2));
}

.tmap-pin-head {
  width: 48px;
  height: 48px;
  background: #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 3px solid var(--tmap-blue);
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
}

.tmap-pin-img {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transform: rotate(45deg) scale(1.4);
}

.tmap-pin-point {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.tmap-entry-chip {
  background: #fff;
  border: 2px solid var(--tmap-orange);
  color: var(--tmap-text);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.tmap-entry-line {
  width: 2px;
  height: 12px;
  background: var(--tmap-orange);
  margin: 2px auto;
}

.tmap-entry-dot {
  width: 10px;
  height: 10px;
  background: var(--tmap-orange);
  border-radius: 50%;
  margin: 0 auto;
  border: 2px solid #fff;
}

/* ==================== 7. POPUP NATIVO MAPBOX ==================== */
.tmap-mapboxgl-custom-popup.mapboxgl-popup {
  z-index: 50 !important;
  max-width: none !important;
}

.tmap-mapboxgl-custom-popup .mapboxgl-popup-content {
  padding: 0;
  border-radius: 16px;
  border: 2px solid var(--tmap-blue);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  width: min(var(--popup-width), var(--popup-max-width));
  max-height: min(var(--popup-max-height), calc(var(--tmap-height) - 24px), 80vh);
  background: #fff;
  display: flex;
  flex-direction: column;
}

.tmap-mapboxgl-custom-popup .mapboxgl-popup-tip {
  border-top-color: var(--tmap-blue) !important;
  border-width: 12px;
}

.tmap-mapboxgl-custom-popup .mapboxgl-popup-close-button {
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 18px;
  line-height: 26px;
  padding: 0;
  transition: all 0.2s ease;
  z-index: 10;
}

.tmap-mapboxgl-custom-popup .mapboxgl-popup-close-button:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.tmap-popup-custom-content {
  display: flex;
  flex-direction: column;
  background: #fff;
  max-height: inherit;
  height: 100%;
  min-height: 0;
}

.tmap-popup-header {
  height: 120px;
  background-size: cover;
  background-position: center;
  position: sticky;
  top: 0;
  z-index: 2;
  flex: 0 0 120px;
  background-color: var(--tmap-bg);
}

.tmap-popup-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 5px 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tmap-popup-body {
  padding: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.tmap-popup-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--tmap-text);
}

.tmap-popup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tmap-popup-tag {
  background: var(--tmap-blue-light);
  color: var(--tmap-blue);
  font-size: 11px;
  font-weight: 600;
  border-radius: 5px;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.tmap-popup-notes {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--tmap-text-light);
  line-height: 1.5;
}

.tmap-popup-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f0f4f8;
}

.tmap-popup-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1px solid #e0e7ef;
  border-radius: 8px;
  text-decoration: none;
  color: var(--tmap-text);
  font-size: 12px;
  font-weight: 700;
  transition: all 0.2s ease;
  background: #fff;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.tmap-popup-nav-btn span{
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tmap-popup-nav-btn:hover {
  background: var(--tmap-blue);
  color: #fff;
  border-color: var(--tmap-blue);
  transform: translateY(-1px);
}

.tmap-popup-nav-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ==================== 8. NAV + MODAL ==================== */
.tmap-nav-section {
  background: #fff;
  padding: 14px 18px;
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--tmap-border);
  border-radius: 0 0 var(--tmap-radius) var(--tmap-radius);
  position: relative;
  z-index: 10;
}

.tmap-nav-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--tmap-bg);
  border: 1px solid #e0e7ef;
  border-radius: 10px;
  color: var(--tmap-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tmap-nav-btn:hover {
  border-color: var(--tmap-blue);
  background: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tmap-nav-btn img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.tmap-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}

.tmap-modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tmap-modal {
  width: min(440px, calc(100% - 32px));
  max-height: min(80vh, 600px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { 
    opacity: 0;
    transform: translateY(20px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

.tmap-modal-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, #f8fbff, #fff);
  border-bottom: 1px solid #e9eff8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 2;
}

.tmap-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--tmap-text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tmap-modal-title img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.tmap-modal-close {
  border: none;
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  color: #8a97a8;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.tmap-modal-close:hover {
  background: #f0f4f8;
  color: var(--tmap-text);
}

.tmap-modal-close svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.tmap-modal-body {
  max-height: calc(80vh - 70px);
  overflow: auto;
}

.tmap-dest-card {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #f1f5fb;
  transition: background 0.15s ease;
}

.tmap-dest-card:hover {
  background: #f8fbff;
}

.tmap-dest-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  background-color: #eef2f7;
  flex-shrink: 0;
}

.tmap-dest-info {
  flex: 1;
  min-width: 0;
}

.tmap-dest-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--tmap-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.tmap-dest-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tmap-dest-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #eef3fa;
  color: #4c5a6c;
}

.tmap-dest-arrow {
  color: var(--tmap-blue);
  font-size: 18px;
  flex-shrink: 0;
}

/* ==================== 9. TOUCH HINT ==================== */
.tmap-touch-hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  padding: 10px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 60;
}

.tmap-touch-hint.show {
  opacity: 1;
}

/* ==================== 10. FULLSCREEN ==================== */
.tmap-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99999 !important;
  border-radius: 0 !important;
}

.tmap-fullscreen .tmap-header-outer {
  border-radius: 0 !important;
}

.tmap-fullscreen .tmap-map-section {
  height: calc(100vh - 68px - 58px) !important;
}

.tmap-fullscreen .tmap-nav-section {
  border-radius: 0 !important;
}

/* ==================== 11. RESPONSIVE ==================== */
@media (max-width: 768px) {
  .tmap-header-outer {
    min-height: 60px;
    padding: 12px 16px;
  }

  .tmap-title {
    font-size: 16px;
  }

  .tmap-btn {
    padding: 7px 12px;
    font-size: 12px;
  }

  .tmap-btn-text {
    display: none;
  }

  .skills-map-wrapper {
  --popup-width: min(92vw, 420px);
  --popup-max-height: min(70vh, calc(var(--tmap-height) - 20px));
}

  /* ✅ POPUP: Imagen más pequeña en móvil */
  .tmap-popup-header {
    height: 100px; /* 140px → 100px */
  }

  /* ✅ BOTONES: Siempre horizontales (1 línea) */
  .tmap-popup-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

 .tmap-popup-nav-btn {
  padding: 8px 6px;
  font-size: 10px;
  gap: 4px;
}

  .tmap-popup-nav-btn img {
    width: 16px;
    height: 16px;
  }

  /* ✅ BODY: Más scroll, menos padding */
  .tmap-popup-body {
    padding: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .tmap-nav-section {
    flex-wrap: wrap;
    gap: 8px;
  }

  .tmap-nav-btn {
    min-width: calc(50% - 4px);
    padding: 10px 12px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .skills-map-wrapper {
  --popup-width: min(94vw, 380px);
  --popup-max-height: min(72vh, calc(var(--tmap-height) - 16px));
}

  .tmap-popup-header {
    height: 90px; /* Aún más pequeña */
  }

  .tmap-popup-body {
    padding: 10px;
  }

  .tmap-popup-title {
    font-size: 15px;
  }

  .tmap-popup-tag {
    font-size: 10px;
    padding: 3px 6px;
  }

  .tmap-popup-notes {
    font-size: 12px;
  }
}