:root {
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.5);
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.4);
  --bg: #0b0f1a;
  --glass: rgba(23, 31, 52, 0.72);
  --glass-heavy: rgba(15, 23, 42, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.15);
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --font: 'Inter', system-ui, sans-serif;
  --radius-lg: 1.25rem;
  --radius-md: 0.75rem;
  --radius-sm: 0.5rem;
  --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  letter-spacing: -0.011em;
}

#map {
  height: 100vh;
  width: 100%;
  z-index: 1;
}

/* UI Panels */
.ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none; /* Allows clicking map through empty spaces */
}

.panel {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-premium);
  z-index: 2000; /* Higher than map controls */
  overflow: hidden;
  position: absolute;
  pointer-events: auto !important; /* Forces panel to capture mouse */
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
}

.panel.horizontal {
  width: calc(100vw - 3rem) !important;
  height: auto !important;
  min-height: 60px;
  left: 1.5rem !important;
  top: 1.5rem !important;
}

.panel.horizontal .panel-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  overflow-x: auto;
  overflow-y: hidden;
}

.panel.horizontal .brand, 
.panel.horizontal .stats,
.panel.horizontal .btn-secondary:not(#admin-portal-btn) {
  display: none !important;
}

.panel.horizontal .form {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.panel.horizontal .form-group {
  margin-bottom: 0;
  min-width: 140px;
}

.panel.horizontal .btn {
  padding: 0.6rem 1rem;
  width: auto;
}

.panel.docked {
  position: fixed !important;
  width: 400px !important;
  height: 100vh !important;
  left: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  border-radius: 0 !important;
  border-left: none !important;
  border-top: none !important;
  border-bottom: none !important;
  box-shadow: 10px 0 30px rgba(0,0,0,0.5) !important;
  transform: none !important;
  z-index: 3000 !important;
}

.panel.docked .drag-handle {
  cursor: default !important;
}

.panel.docked .panel-content {
  height: calc(100vh - 45px);
  overflow-y: auto !important;
}

.layout-toggle-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.layout-toggle-btn:hover {
  color: var(--primary);
}

.panel:hover {
  border-color: var(--border-bright);
}

.panel-content {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1; /* Grow to fill panel space */
}

/* Resize Handle */
.resize-handle {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.15) 50%);
  border-radius: 0 0 var(--radius-lg) 0;
  z-index: 1001;
}

.resize-handle:hover {
  background: linear-gradient(135deg, transparent 50%, var(--primary) 50%);
}

.drag-handle {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem 1.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  cursor: grab;
  border-bottom: 1px solid var(--border);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.drag-handle:active {
  cursor: grabbing;
}

.province-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.province-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 10px 20px -10px var(--primary-glow);
}

.brand {
  margin-bottom: 1.5rem;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #fff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand p {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  color: var(--text-dim); /* Brighter than muted */
}

input, select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05); /* Brighter background */
  border: 1px solid rgba(255, 255, 255, 0.15); /* More defined border */
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s;
}

input::placeholder {
  color: var(--text-dim);
  opacity: 0.7;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.geo-select {
  margin-bottom: 0.5rem;
  background: var(--glass-heavy) !important;
}

.geo-select:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  filter: grayscale(1);
}

.explorer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.explorer-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--accent);
  transform: translateX(6px);
  box-shadow: 0 4px 20px -5px var(--accent-glow);
}

.count-pill {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 0.5rem;
  font-weight: 800;
  color: white;
  min-width: 25px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.count-pill.res { background: var(--primary); }
.count-pill.dist { background: var(--accent); }

input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.875rem;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -10px var(--primary-glow);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: var(--border-bright);
}

.btn-emerald {
  background: var(--accent);
}

.btn-emerald:hover {
  background: #059669;
  box-shadow: 0 10px 20px -10px var(--accent-glow);
}

/* Legend/Stats */
.stats {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 2rem;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.available { background: rgba(34, 197, 94, 0.1); color: var(--accent); }
.taken { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

/* Custom Map Marker */
.reseller-marker {
  width: 14px;
  height: 14px;
  background: var(--primary);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 15px var(--primary-glow);
}

/* Territory Circle Styling */
.territory-circle {
  fill: var(--primary);
  fill-opacity: 0.12;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-dasharray: 6, 4;
}

.territory-circle-conflict {
  fill: var(--danger);
  fill-opacity: 0.3;
  stroke: var(--danger);
}

/* Legend Panel */
.legend-panel {
  position: absolute;
  bottom: 2rem;
  right: 1.5rem;
  z-index: 1000;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
