/* ============================================
   Lucas — style.css
   ============================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --sidebar-width: 340px;
  --bg-dark: #1a1a2e;
  --bg-sidebar: #16213e;
  --bg-card: #0f3460;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0b0;
  --border-color: #2a2a4a;
  --radius: 8px;
  --transition: 0.3s ease;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
}

body {
  display: flex;
}

/* ---------- Sidebar Toggle Button ---------- */
.sidebar-toggle {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1100;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), left var(--transition);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:hover {
  background: var(--bg-card);
}

/* When sidebar is open, push toggle offscreen (hidden behind sidebar) */
body:not(.sidebar-collapsed) .sidebar-toggle {
  left: -50px;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  z-index: 1000;
  transition: margin-left var(--transition), opacity var(--transition);
}

body.sidebar-collapsed #sidebar {
  margin-left: calc(-1 * var(--sidebar-width));
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition);
}

.sidebar-close:hover {
  color: var(--accent);
}

.sidebar-header .subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
}

.player-count {
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ---------- Theme Selector ---------- */
.theme-selector {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-selector label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Custom dropdown */
.custom-dropdown {
  position: relative;
  flex: 1;
}

.dropdown-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  user-select: none;
}

.dropdown-selected:hover {
  border-color: var(--accent-hover);
}

.dropdown-selected.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.dropdown-selected svg {
  flex-shrink: 0;
  transition: transform var(--transition);
}

.dropdown-selected.open svg {
  transform: rotate(180deg);
}

.dropdown-options {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 2000;
  list-style: none;
  background: var(--bg-dark);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: dropdownSlide 0.2s ease;
}

.dropdown-options.visible {
  display: block;
}

@keyframes dropdownSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-options li {
  padding: 9px 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.dropdown-options li:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.dropdown-options li.active {
  color: var(--accent);
  font-weight: 600;
  background: rgba(233, 69, 96, 0.1);
}

/* ---------- Player List ---------- */
.player-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.player-list::-webkit-scrollbar {
  width: 6px;
}

.player-list::-webkit-scrollbar-track {
  background: var(--bg-sidebar);
}

.player-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* Region group */
.region-group {
  margin-bottom: 16px;
}

.region-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  padding: 6px 8px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.region-title:hover {
  background: rgba(233, 69, 96, 0.15);
}

.region-title .count-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

/* Player card */
.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.player-card:hover {
  background: var(--bg-card);
  transform: translateX(4px);
}

.player-card.active {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
}

.player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

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

.player-pseudo {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-meta {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.player-meta .city {
  color: var(--text-secondary);
}

.player-meta .role {
  color: var(--accent-hover);
  font-weight: 600;
}

/* ---------- Map ---------- */
#map {
  flex: 1;
  height: 100vh;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
  background: var(--bg-sidebar);
  color: var(--text-primary);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.leaflet-popup-tip {
  background: var(--bg-sidebar);
}

.leaflet-popup-content {
  margin: 10px 14px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.popup-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.popup-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.popup-detail strong {
  color: var(--text-primary);
}

/* ---------- MarkerCluster theme ---------- */
.marker-cluster {
  border-radius: 50%;
}

.marker-cluster div {
  width: 32px;
  height: 32px;
  margin: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
}

.marker-cluster-small {
  background: rgba(233, 69, 96, 0.45);
}
.marker-cluster-small div {
  background: var(--accent);
}

.marker-cluster-medium {
  background: rgba(233, 69, 96, 0.55);
}
.marker-cluster-medium div {
  background: #c73a52;
}

.marker-cluster-large {
  background: rgba(233, 69, 96, 0.65);
}
.marker-cluster-large div {
  background: #a92e42;
}

/* ---------- Mobile Navbar ---------- */
.mobile-navbar {
  display: none;
}

/* ---------- Konami Rainbow Mode ---------- */
@keyframes rainbowText {
  0%   { color: #ff0000; }
  14%  { color: #ff8800; }
  28%  { color: #ffff00; }
  42%  { color: #00ff00; }
  57%  { color: #0088ff; }
  71%  { color: #8800ff; }
  85%  { color: #ff00ff; }
  100% { color: #ff0000; }
}

@keyframes rainbowBg {
  0%   { background: #ff0000; }
  14%  { background: #ff8800; }
  28%  { background: #ffff00; }
  42%  { background: #00ff00; }
  57%  { background: #0088ff; }
  71%  { background: #8800ff; }
  85%  { background: #ff00ff; }
  100% { background: #ff0000; }
}

@keyframes rainbowFill {
  0%   { fill: #ff0000; }
  14%  { fill: #ff8800; }
  28%  { fill: #ffff00; }
  42%  { fill: #00ff00; }
  57%  { fill: #0088ff; }
  71%  { fill: #8800ff; }
  85%  { fill: #ff00ff; }
  100% { fill: #ff0000; }
}

@keyframes rainbowBorder {
  0%   { border-color: #ff0000; }
  14%  { border-color: #ff8800; }
  28%  { border-color: #ffff00; }
  42%  { border-color: #00ff00; }
  57%  { border-color: #0088ff; }
  71%  { border-color: #8800ff; }
  85%  { border-color: #ff00ff; }
  100% { border-color: #ff0000; }
}

@keyframes rainbowShadow {
  0%   { filter: drop-shadow(0 0 6px #ff0000); }
  14%  { filter: drop-shadow(0 0 6px #ff8800); }
  28%  { filter: drop-shadow(0 0 6px #ffff00); }
  42%  { filter: drop-shadow(0 0 6px #00ff00); }
  57%  { filter: drop-shadow(0 0 6px #0088ff); }
  71%  { filter: drop-shadow(0 0 6px #8800ff); }
  85%  { filter: drop-shadow(0 0 6px #ff00ff); }
  100% { filter: drop-shadow(0 0 6px #ff0000); }
}

/* Pin SVG path — rainbow fill + glow */
body.konami-rainbow .custom-pin svg path {
  animation: rainbowFill 2s linear infinite;
}

body.konami-rainbow .custom-pin svg {
  animation: rainbowShadow 2s linear infinite;
}

/* Cluster bubbles */
body.konami-rainbow .marker-cluster div {
  animation: rainbowBg 2s linear infinite;
}

body.konami-rainbow .marker-cluster-small,
body.konami-rainbow .marker-cluster-medium,
body.konami-rainbow .marker-cluster-large {
  animation: rainbowBg 2s linear infinite;
  background: none !important;
}

/* Sidebar text */
body.konami-rainbow .player-pseudo {
  animation: rainbowText 2s linear infinite;
}

body.konami-rainbow .region-title {
  animation: rainbowText 2.5s linear infinite;
}

body.konami-rainbow .region-title .count-badge {
  animation: rainbowBg 2s linear infinite;
}

body.konami-rainbow .player-avatar {
  animation: rainbowBg 2s linear infinite;
}

body.konami-rainbow .player-card.active {
  animation: rainbowBorder 2s linear infinite;
}

/* Popup */
body.konami-rainbow .popup-title {
  animation: rainbowText 2s linear infinite;
}

body.konami-rainbow .sidebar-header h1 {
  animation: rainbowText 2s linear infinite;
}

/* Toast notification */
.konami-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: linear-gradient(90deg, #ff0000, #ff8800, #ffff00, #00ff00, #0088ff, #8800ff, #ff00ff);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 12px 28px;
  border-radius: 12px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.konami-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .mobile-navbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    z-index: 1200;
    flex-shrink: 0;
  }

  .mobile-brand {
    font-size: 1.2rem;
    font-weight: 700;
  }

  .mobile-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
  }

  /* Hide desktop toggle on mobile */
  .sidebar-toggle {
    display: none !important;
  }

  body {
    flex-direction: column;
    overflow: hidden;
  }

  #sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    transition: max-height var(--transition), opacity var(--transition);
    margin-left: 0 !important;
    overflow: hidden;
  }

  body.sidebar-collapsed #sidebar {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    border-bottom: none;
    margin-left: 0 !important;
    margin-top: 0;
  }

  /* Hide the close X inside sidebar on mobile (navbar handles it) */
  .sidebar-close {
    display: none;
  }

  /* Hide sidebar title row on mobile (navbar already shows brand) */
  .sidebar-title-row h1 {
    display: none;
  }

  .sidebar-title-row {
    display: none;
  }

  #map {
    flex: 1;
    height: auto;
    width: 100%;
  }
}
