:root {
  --primary-color: #d4af37;
  --secondary-color: #b58d20;
  --accent-color: #d4af37;
  --bg-color: #070707;
  --glass-bg: rgba(13, 13, 15, 0.9);
  --glass-border: rgba(212, 175, 55, 0.2);
  --text-main: #f0f0f0;
  --text-muted: #888888;
  --sidebar-width: 350px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', 'Inter', system-ui, sans-serif;
}

body {
  background-color: var(--bg-color);
  background-image: radial-gradient(circle at top left, #1a1a1a, transparent),
                    radial-gradient(circle at bottom right, #070707, transparent);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 10;
}

/* Sidebar Scrollbar Styling */
.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-track {
  background: #050505;
}

.sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
}

.sidebar-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
}

.logo {
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  font-weight: 800;
  text-shadow: 2px 2px 5px rgba(0,0,0,0.8);
  text-decoration: none;
  color: #fff;
  display: inline-block;
  letter-spacing: 1px;
  transition: all 0.3s ease;
}

.logo:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.gold-text {
  color: var(--primary-color);
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

.section {
  margin-bottom: 2rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--glass-border);
}

.section h2 {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Form Controls */
.field {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

input, select {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  color: #fff;
  outline: none;
  transition: all 0.2s;
  font-size: 0.85rem;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--primary-color) 50%),
                    linear-gradient(135deg, var(--primary-color) 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(1em + 2px),
                       calc(100% - 15px) calc(1em + 2px);
  background-size: 5px 5px,
                   5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

select option {
  background: #0d0d0f;
  color: #fff;
  padding: 10px;
}

input:focus, select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

button {
  cursor: pointer;
  border: none;
  padding: 0.8rem 1.2rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  filter: brightness(1.2);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--glass-bg);
}

.btn-success {
  background: var(--accent-color);
  color: white;
}

.btn-success:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* Map Content */
.main-content {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  overflow-y: auto;
}

.toolbar {
  padding: 1rem 2rem;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.map-container {
  flex: 1; /* Allow content to fill and scroll correctly */
  position: relative;
  padding: 30px;
  display: flex;
  cursor: crosshair;
  min-height: 50vh;
  overflow: auto; /* Enable scrolling for zoomed canvas */
}

#map-canvas {
  background: #000;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: block;
  margin: auto; /* Centers when small, aligns to start when large (Scroll fix) */
  max-width: none; /* Disable constraints to allow zooming beyond screen size */
  max-height: none;
  height: auto;
  width: auto;
  transition: width 0.1s ease-out, height 0.1s ease-out; /* Smooth zooming */
}

/* Visibility Filters */
.vis-filters {
  display: flex;
  gap: 0.5rem;
}

.vis-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  width: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
}

.vis-check {
  width: 14px;
  height: 14px;
  border: 1px solid var(--glass-border);
  border-radius: 3px;
  background: rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.vis-btn.active .vis-check::after {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 8px;
  color: white;
}

.vis-btn i { font-size: 0.85rem; }
.vis-btn.active { color: white; border-color: rgba(255,255,255,0.2); }
.vis-btn.active[data-type="m"] { background: rgba(239, 68, 68, 0.4); }
.vis-btn.active[data-type="n"] { background: rgba(59, 130, 246, 0.4); }
.vis-btn.active[data-type="s"] { background: rgba(251, 191, 36, 0.4); }

.vis-btn.active[data-type="m"] .vis-check { background: var(--crimson, #8b0000); border-color: var(--crimson, #8b0000); }
.vis-btn.active[data-type="n"] .vis-check { background: var(--primary-color); border-color: var(--primary-color); }
.vis-btn.active[data-type="s"] .vis-check { background: #ffd700; border-color: #ffd700; }

.vis-btn:not(.active) { opacity: 0.6; filter: grayscale(0.5); }
.vis-btn:hover { border-color: var(--primary-color); transform: translateY(-1px); }

/* Zoom Control */
.zoom-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.4rem 1rem;
  border-radius: 2rem;
  border: 1px solid var(--glass-border);
}

.zoom-control i { font-size: 0.8rem; color: var(--text-muted); }
#zoom-label { font-size: 0.7rem; min-width: 40px; text-align: right; color: var(--primary-color); font-weight: 600; }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  background: var(--glass-border);
  border-radius: 2px;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 12px;
  width: 12px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* Entity Types */
.entity-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.25rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  flex: 1;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  border-radius: 0.4rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: var(--primary-color);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 15px var(--glass-border);
}

/* History / List */
.entity-item {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.8rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 0px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  border-left: 4px solid transparent;
  max-width: 600px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.entity-item.type-m { border-left-color: #8b0000; }
.entity-item.type-n { border-left-color: #d4af37; }
.entity-item.type-s { border-left-color: #ffd700; }

.entity-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.delete-btn {
  color: #ef4444;
  cursor: pointer;
  padding: 0.2rem;
}

/* Added Section Below Map */
.added-section {
  padding: 2rem 2.5rem 4rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  background: rgba(13, 13, 15, 0.5);
  border-top: 1px solid var(--glass-border);
  min-height: 400px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h2 {
  margin-bottom: 0;
}

.entity-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.column {
  margin-bottom: 2rem;
  min-height: 200px;
}

.column h3 {
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-main);
  letter-spacing: 0.1em;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.entity-list-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.entity-list-vertical::-webkit-scrollbar {
  width: 4px;
}

.entity-list-vertical::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 10px;
}

.export-container {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--glass-border);
  padding-top: 1.5rem;
}

#export-btn {
  width: auto;
  min-width: 250px;
  padding: 1rem 2rem;
  font-size: 1rem;
}

/* Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary-color);
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  display: none;
  animation: slideUp 0.3s ease-out;
}

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