/* ==========================================
   POWERZONER BASE STYLES
   Complete standalone CSS for PowerZoner
   No dependencies on shared CSS files
   ========================================== */

/* ───────── GLOBAL RESETS & FUNDAMENTALS ───────── */
html, body {
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* ───────── LAYOUT GRID (DESKTOP) ───────── */
#layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
}

#sidebar {
  grid-column: 1;
  grid-row: 1;
  overflow-y: auto;
  background: #fafafa;
  border-right: 1px solid #ccc;
}

#map {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  min-height: 200px;
  overflow: hidden;
}

/* ───────── HAMBURGER MENU COLOR OVERRIDE ───────── */
/* Mobile hamburger behavior is handled by common.css */
/* This only overrides the color to PowerZoner purple */
#hamburger-btn {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
}

/* ───────── MOBILE LAYOUT FIXES ───────── */
@media (max-width: 900px) {
  /* Reset grid layout on mobile */
  #layout {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    height: 100vh !important;
  }

  /* Map takes full screen on mobile */
  #map {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* Floating buttons positioning */
  .left-floating-buttons {
    position: fixed !important;
    bottom: max(15px, env(safe-area-inset-bottom)) !important;
    left: max(15px, env(safe-area-inset-left)) !important;
    z-index: 1000 !important;
  }

  .floating-3d-button {
    position: fixed !important;
    bottom: 15px !important;
    right: 20px !important;
    z-index: 1000 !important;
  }

  /* Hide DEM legend on mobile */
  .dem-legend {
    display: none !important;
  }
}

/* ───────── SCROLLBAR STYLING ───────── */
#sidebar::-webkit-scrollbar {
  width: 8px;
}

#sidebar::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#sidebar::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ───────── TAB SYSTEM ───────── */
/* Tab system styles are in powerzoner-ui-components.css */

/* ───────── COMMON UI COMPONENTS ───────── */

/* Header */
.header {
  font-size: 18px;
  padding: 12px 16px;
  background: #1f2937;
  color: #fff;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.fullscreen-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}

.fullscreen-btn i {
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.fullscreen-btn:active {
  transform: scale(0.95);
}

/* Section */
section {
  padding: 8px 14px;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: white;
  border-color: #7c3aed;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-success {
  background: #10b981;
  color: white;
  border-color: #10b981;
}

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-danger {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

/* Input fields */
input[type="text"],
input[type="number"],
select,
textarea {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  transition: border-color 0.2s ease;
  width: 100%;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

/* Labels */
label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
}

label.toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  margin: 0.3em 0;
}

label.toggle input {
  margin: 0;
}

/* Row layout */
.row {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.row input[type="range"] {
  flex: 1;
}

/* Sections */
.section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

/* Info boxes */
.info-box {
  padding: 12px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  font-size: 12px;
  color: #0c4a6e;
  margin: 12px 0;
}

.info-box i {
  margin-right: 6px;
  color: #0284c7;
}

.warning-box {
  padding: 12px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
  color: #78350f;
  margin: 12px 0;
}

.warning-box i {
  margin-right: 6px;
  color: #f59e0b;
}

.error-box {
  padding: 12px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 12px;
  color: #7f1d1d;
  margin: 12px 0;
}

.error-box i {
  margin-right: 6px;
  color: #dc2626;
}

/* ───────── SEARCH BOX ───────── */
.search-container {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: 280px;
}

.search-box {
  width: 100%;
  padding: 10px 40px 10px 15px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  font-size: 14px;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
}

.search-box:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
  background: rgba(255, 255, 255, 1);
}

.search-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.search-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(15px);
  border: 1px solid #e5e7eb;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 1001;
}

.search-suggestion {
  padding: 12px 15px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  transition: all 0.2s ease;
}

.search-suggestion:hover {
  background: rgba(124, 58, 237, 0.05);
}

.search-suggestion:last-child {
  border-bottom: none;
}

.suggestion-name {
  font-weight: 500;
  color: #374151;
  margin-bottom: 2px;
}

.suggestion-address {
  color: #6b7280;
  font-size: 12px;
}

/* ───────── UTILITY CLASSES ───────── */
.text-center {
  text-align: center;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.w-full {
  width: 100%;
}

/* ───────── MOBILE ADJUSTMENTS ───────── */
@media (max-width: 900px) {
  /* Move search box on mobile */
  .search-container {
    top: 70px;
    width: calc(100% - 30px);
    max-width: 320px;
  }

  /* Hide DEM legend on mobile (takes up too much space) */
  .dem-legend {
    display: none !important;
  }
}

/* ───────── DETAILS/ACCORDION ───────── */
details {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 8px;
  background: #fff;
  overflow: hidden;
}

summary {
  padding: 10px 12px;
  font-weight: 600;
  font-size: 13px;
  background: #f9fafb;
  cursor: pointer;
  transition: background 0.2s ease;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: '\f054'; /* FontAwesome right arrow */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 10px;
  color: #6b7280;
  transition: transform 0.2s ease;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

details[open] > summary {
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
}

details > *:not(summary) {
  padding: 12px;
}

/* ───────── OPENLAYERS POPUP ───────── */
.ol-popup {
  position: absolute;
  background: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  min-width: 140px;
  z-index: 1000;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ol-popup * {
  margin: 0;
  padding: 0;
  line-height: 1.4;
}

.ol-popup:before,
.ol-popup:after {
  display: none;
}

/* ───────── MEASUREMENT RESULT POPUPS ───────── */
.measurement-popup {
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0;
  font-size: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  max-width: 280px;
  overflow: hidden;
}

.measurement-popup-header {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: white;
  padding: 8px 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.measurement-popup-header i {
  font-size: 14px;
  opacity: 0.9;
}

.measurement-popup-content {
  padding: 12px;
}

.measurement-value {
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 4px;
}

.measurement-unit {
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 8px;
}

.measurement-actions {
  border-top: 1px solid #f1f5f9;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.measurement-clear-btn {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.measurement-clear-btn:hover {
  background: #f8fafc;
  color: #374151;
}

.measurement-clear-btn i {
  font-size: 11px;
}

.measurement-units {
  margin-bottom: 8px;
}

.measurement-unit-select {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}

.measurement-unit-select:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}

/* ───────── DEM LEGEND ───────── */
.dem-legend {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 10px;
  z-index: 1000;
  font-size: 12px;
  max-width: 100px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.dem-legend-title {
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
  color: #374151;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dem-legend-gradient {
  height: 15px;
  margin-bottom: 8px;
  background: linear-gradient(to right,
    #0000ff 0%, #00ffff 20%, #00ff00 40%,
    #ffff00 60%, #ffa500 80%, #ff0000 100%);
  border: 1px solid #d1d5db;
  border-radius: 3px;
}

.dem-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #6b7280;
}

/* ───────── MAP TOOLS POPOVER ───────── */
.tools-popover {
  position: absolute;
  bottom: 70px;
  left: 120px;
  z-index: 9999;
  background: #fff;
  border: 2px solid #333;
  border-radius: 6px;
  padding: 12px;
  width: 240px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s ease;
}

.tools-popover.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.tools-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ddd;
}

.tools-popover-title {
  font-weight: 600;
  font-size: 16px;
  color: #374151;
}

.tools-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  color: #666;
  transition: all 0.2s ease;
}

.tools-close-btn:hover {
  background: #eee;
  color: #000;
}

.tools-popover-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  background: #fff;
}

.tool-item:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.tool-item.active {
  background: rgba(124, 58, 237, 0.1);
  border-color: #7c3aed;
  color: #7c3aed;
}

.tool-item i {
  font-size: 16px;
  color: #6b7280;
  width: 20px;
  transition: color 0.2s ease;
}

.tool-item.active i {
  color: #7c3aed;
}

.tool-item-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

.tool-item.active .tool-item-label {
  color: #7c3aed;
}

/* ───────── USER MANUAL MODAL ───────── */
.manual-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

.manual-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  width: 90%;
  height: 90%;
  max-width: 1200px;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
  overflow: hidden;
}

.manual-modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  border-radius: 12px 12px 0 0;
  flex-shrink: 0;
}

.manual-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.manual-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.manual-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .manual-modal {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .manual-modal-header {
    border-radius: 0;
  }
}

/* ───────── VIEWER HIDE UTILITY ───────── */
.viewer-hide {
  display: none !important;
}

.legacy-base {
  display: none;
}
