/* POLYGON STUDIO PRO - Modern Design */

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

html, body { 
  height: 100%; 
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}

/* TOP BAR */
#topBar {
  height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 1000;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo-section h1 {
  color: white;
  font-size: 1.4em;
  font-weight: 700;
}

.help-hint {
  color: rgba(255,255,255,0.8);
  font-size: 0.85em;
  background: rgba(0,0,0,0.2);
  padding: 4px 10px;
  border-radius: 15px;
}

.import-export-section {
  display: flex;
  gap: 10px;
}

.file-btn {
  background: white;
  color: #667eea;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9em;
}

.file-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9em;
  background: white;
  color: #333;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-primary { background: #667eea; color: white; }
.btn-secondary { background: #6c757d; color: white; }
.btn-success { background: #48bb78; color: white; }
.btn-info { background: #4299e1; color: white; }
.btn-danger { background: #fc8181; color: white; }
.btn-warning { background: #f6ad55; color: white; }
.btn-outline { 
  background: white; 
  color: #667eea; 
  border: 2px solid #667eea; 
}
.btn-sm {
  padding: 4px 8px;
  font-size: 0.85em;
}

.status-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

#statusMessage {
  background: rgba(255,255,255,0.95);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 600;
  min-width: 150px;
  text-align: center;
}

#statusMessage.success {
  background: #d4edda;
  color: #155724;
}

#statusMessage.error {
  background: #f8d7da;
  color: #721c24;
}

#loadingIndicator {
  display: none;
  background: #fff3cd;
  color: #856404;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85em;
}

/* MAIN LAYOUT */
#mainContainer {
  display: grid;
  grid-template-columns: 320px 1fr 450px;
  height: calc(100vh - 60px);
}

/* LEFT PANEL - Controls */
#leftPanel {
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  background: white;
  padding: 15px;
  border-bottom: 2px solid #667eea;
}

.panel-header h3 {
  font-size: 1.1em;
  color: #333;
  margin-bottom: 10px;
}

.view-switcher {
  display: flex;
  gap: 5px;
  background: #f0f2f5;
  padding: 4px;
  border-radius: 8px;
}

.view-switcher button {
  flex: 1;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: #666;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.view-switcher button.active {
  background: #667eea;
  color: white;
}

.panel-controls {
  padding: 15px;
  background: white;
  border-bottom: 1px solid #dee2e6;
}

.search-section {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 0.95em;
}

.search-input:focus {
  outline: none;
  border-color: #667eea;
}

.bulk-actions {
  display: flex;
  gap: 8px;
}

/* REGIONS EDITOR */
.regions-editor {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.regions-section {
  margin-bottom: 20px;
}

.section-header {
  background: linear-gradient(90deg, #667eea, #764ba2);
  color: white;
  padding: 10px 15px;
  border-radius: 8px 8px 0 0;
  font-size: 0.95em;
  font-weight: 600;
}

.regions-list {
  background: white;
  border: 1px solid #dee2e6;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 400px;
  overflow-y: auto;
}

/* REGION ITEM */
.region-item {
  padding: 12px;
  border-bottom: 1px solid #f0f2f5;
  animation: slideIn 0.2s ease;
}

.region-item:hover {
  background: #f8f9fa;
}

.region-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.region-name-section {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.region-id {
  background: #667eea;
  color: white;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.75em;
  font-weight: 600;
}

.region-name-input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 0.9em;
}

.region-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.visibility-toggle {
  position: relative;
  width: 40px;
  height: 22px;
}

.visibility-toggle input {
  display: none;
}

.visibility-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #e9ecef;
  border-radius: 11px;
  transition: 0.3s;
}

.visibility-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .visibility-slider {
  background: #48bb78;
}

input:checked + .visibility-slider:before {
  transform: translateX(18px);
}

.region-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.setting-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-group label {
  font-size: 0.85em;
  color: #666;
  min-width: 40px;
}

.color-input {
  width: 40px;
  height: 30px;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  cursor: pointer;
}

.color-mini {
  width: 30px;
  height: 20px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  margin: 0 4px;
}

.color-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.color-controls label {
  font-size: 0.8em;
  margin: 0;
}

.style-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.style-select {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 0.85em;
  background: white;
}

.style-select:focus {
  outline: none;
  border-color: #667eea;
}

.opacity-slider {
  flex: 1;
  height: 4px;
}

.opacity-value {
  font-size: 0.85em;
  color: #667eea;
  font-weight: 600;
  min-width: 35px;
  text-align: right;
}

/* MAP */
#map {
  position: relative;
  background: #f0f2f5;
}

#map.white-background {
  background: white !important;
}

/* Hide zoom controls */
.leaflet-control-zoom {
  display: none !important;
}

/* RIGHT PANEL - Region Editor */
#rightPanel {
  background: #f8f9fa;
  border-left: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.controls-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
}

.control-group {
  background: white;
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.control-group h4 {
  font-size: 0.95em;
  color: #333;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #f0f2f5;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sub-group {
  margin-bottom: 12px;
}

.sub-group label {
  display: block;
  font-size: 0.85em;
  color: #666;
  margin-bottom: 6px;
}

.inline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.value-display {
  background: #f0f2f5;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85em;
  min-width: 50px;
  text-align: center;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #e9ecef;
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
}

.slider-value {
  display: inline-block;
  background: #667eea;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  margin-left: 8px;
}

.full-width {
  width: 100%;
  margin-top: 8px;
}

/* LABELS - Complete Leaflet Icon Override */
.polygon-label {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Kill all Leaflet icon styles */
.leaflet-div-icon.polygon-label,
.leaflet-marker-icon.polygon-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  margin-left: 0 !important;
  margin-top: 0 !important;
  width: auto !important;
  height: auto !important;
}

/* Remove any Leaflet pseudo-elements */
.polygon-label::before,
.polygon-label::after {
  content: none !important;
  display: none !important;
}

/* Pure label text styling */
.polygon-text {
  user-select: none;
  white-space: nowrap;
  font-weight: 700;
  display: inline-block;
  margin: 0;
  padding: 0;
  line-height: 1.2;
  position: relative;
  transform-origin: center center;
}

/* Base label styles */
.label-style-box {
  border-radius: 0 !important;
  padding: 4px 10px !important;
  border: 2px solid currentColor !important;
}

.label-style-rounded {
  border-radius: 12px !important;
  padding: 6px 12px !important;
  border: 2px solid currentColor !important;
}

.label-style-pill {
  border-radius: 20px !important;
  padding: 4px 16px !important;
  border: 2px solid currentColor !important;
}

.label-style-arrow {
  border-radius: 6px !important;
  padding: 4px 10px !important;
  border: 2px solid currentColor !important;
  position: relative;
}

.label-style-arrow::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  margin-top: -4px;
  border-left: 8px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.label-style-simple {
  background: transparent !important;
  border: none !important;
  padding: 2px 4px !important;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.label-style-badge {
  border-radius: 4px 12px 12px 4px !important;
  padding: 4px 12px !important;
  border: none !important;
  position: relative;
}

.label-style-badge::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  border-top: 12px solid currentColor;
  border-bottom: 12px solid currentColor;
  border-left: 8px solid transparent;
}

/* Base label styles from original version */
.style-box {
  border-radius: 4px;
  padding: 6px 12px;
  border: 2px solid;
  border-color: inherit;
}

.style-rounded {
  border-radius: 12px;
  padding: 6px 12px;
  border: 2px solid;
  border-color: inherit;
}

.style-pill {
  border-radius: 20px;
  padding: 4px 16px;
  border: 2px solid;
  border-color: inherit;
}

.style-arrow {
  position: relative;
  margin-right: 15px;
  padding: 6px 12px;
  border: 2px solid;
  border-color: inherit;
  border-radius: 4px;
}

/* Variable length arrow pointing directly to region center */
.style-arrow::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  margin-top: -4px;
  width: var(--arrow-length, 15px);
  height: 0;
  border-left: var(--arrow-length, 15px) solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: var(--arrow-transform, rotate(0deg));
  transform-origin: left center;
  transition: all 0.3s ease;
  z-index: 1;
}

.style-simple {
  background: transparent;
  border: none;
  padding: 2px 4px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.9), -1px -1px 2px rgba(255,255,255,0.8);
  box-shadow: none;
}

.style-badge {
  position: relative;
  padding: 6px 12px 6px 18px;
  border: 2px solid;
  border-color: inherit;
  border-radius: 4px 12px 12px 4px;
}

.style-badge::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 100%;
  border-top: 50% solid transparent;
  border-bottom: 50% solid transparent;
  border-right: 8px solid;
  border-right-color: inherit;
  z-index: -1;
}

/* Overlay label styles */
.label-style-tilted {
  transform: rotate(-5deg) !important;
  transform-origin: center;
  border-radius: 8px !important;
  padding: 5px 12px !important;
  border: 2px solid #fff !important;
}

.label-style-neon {
  border-radius: 6px !important;
  padding: 4px 10px !important;
  border: 2px solid currentColor !important;
  box-shadow: 0 0 10px currentColor, inset 0 0 5px rgba(255,255,255,0.2) !important;
  text-shadow: 0 0 5px currentColor;
}

/* Animations */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f0f2f5;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* Responsive */
@media (max-width: 1400px) {
  #mainContainer {
    grid-template-columns: 280px 1fr 400px;
  }
}

@media (max-width: 1200px) {
  #mainContainer {
    grid-template-columns: 250px 1fr 350px;
  }
}

@media (max-width: 980px) {
  #mainContainer {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  
  #leftPanel, #rightPanel {
    display: none;
  }
}

@media print {
  #topBar, #leftPanel, #rightPanel {
    display: none;
  }
  
  #map {
    width: 100vw;
    height: 100vh;
  }
}