/* ── New Sidebar & Bottom Sheet Layout ── */

.app-container {
  display: flex;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ── Sidebar Base ── */
.sidebar {
  width: 340px;
  min-width: 240px;
  max-width: 600px;
  background: #fcfcfc;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  z-index: 999;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
  position: relative;
  flex-shrink: 0;
}

.sidebar.right-sidebar {
  border-right: none;
  border-left: 1px solid #ddd;
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0;
  overflow: hidden;
  border: none !important;
}

/* ── Sidebar Header ── */
.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #f5f5f5;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #333;
}

.sidebar-title i {
  color: #4f46e5;
}

.sidebar-close-btn {
  display: none;
  background: #eee;
  border: 1px solid #ddd;
  color: #333;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.2s;
  padding: 0;
  line-height: 1;
}

.sidebar-close-btn:hover {
  background: #e0e0e0;
  border-color: #4f46e5;
  color: #4f46e5;
}

/* ── Sidebar Content ── */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
}

/* ── Toggle Buttons ── */
.sidebar-toggle-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 44px;
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1001;
  color: #555;
  border-radius: 0 6px 6px 0;
  transition: all 0.2s;
  padding: 0;
  font-size: 0.8rem;
}

.sidebar-toggle-btn:hover {
  background: #f5f5f5;
  color: #4f46e5;
}

.left-toggle-btn {
  left: 340px;
}

.left-toggle-btn.collapsed-layout {
  left: 0 !important;
}

.right-toggle-btn {
  right: 340px;
  border-radius: 6px 0 0 6px;
}

.right-toggle-btn.collapsed-layout {
  right: 0;
}
.right-toggle-btn i {
  font-size: 1.3rem;
}

/* ── Sidebar Resizer ── */
.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 1000;
  background: transparent;
  transition: background 0.2s;
}

.sidebar-resizer:hover,
.sidebar-resizer.dragging {
  background: rgba(99, 102, 241, 0.4) !important;
}

body.dragging-sidebar .sidebar,
body.dragging-sidebar .left-toggle-btn {
  transition: none !important;
}

/* ── Map Wrapper ── */
.map-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ── Dashboard Empty State (Right Sidebar) ── */
.dashboard-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.dashboard-empty-state i {
  font-size: 2.5rem;
  color: #4f46e5;
  opacity: 0.5;
}

.dashboard-empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #555;
  margin: 0;
}

.dashboard-empty-state p {
  font-size: 0.85rem;
  color: #888;
  margin: 0;
  line-height: 1.4;
}

/* ── Mobile Bottom Sheet ── */
.mobile-bottom-sheet {
  display: none;
}

/* ── Responsive ── */

@media (max-width: 1024px) {
  .sidebar-close-btn {
    display: flex;
  }

  .sidebar {
    position: fixed;
    height: 100vh;
    top: 0;
    box-shadow: -5px 0 25px rgba(0,0,0,0.15);
    z-index: 1010;
  }

  .sidebar.left-sidebar {
    left: 0;
    transform: translateX(0);
    padding-top: 50px;
  }

  .sidebar.left-sidebar.collapsed {
    transform: translateX(-100%);
    width: 340px !important;
  }

  .sidebar.right-sidebar {
    right: 0;
    transform: translateX(0);
  }

  .sidebar.right-sidebar.collapsed {
    transform: translateX(100%);
    width: 340px !important;
  }

  .left-toggle-btn {
    left: 340px;
  }

  .left-toggle-btn.collapsed-layout {
    left: 0;
  }

  .right-toggle-btn {
    right: 340px;
  }

  .right-toggle-btn.collapsed-layout {
    right: 0;
  }
}

@media (max-width: 768px) {
  .sidebar,
  .sidebar-toggle-btn {
    display: none !important;
  }

  .map-toolbox {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .toolbox-items {
    flex-direction: column !important;
    max-height: 50vh !important;
    overflow-y: auto !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
    border-left: none !important;
    border-top: 1px solid #e2e8f0 !important;
    padding-top: 4px !important;
    margin-top: 4px !important;
  }

  .toolbox-open .toolbox-items {
    animation: toolboxFadeInVertical 0.2s ease-out !important;
  }

  .toolbox-item .leaflet-control-zoom {
    flex-direction: column !important;
  }

  .mobile-bottom-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid #ddd;
    box-shadow: 0 -8px 25px rgba(0,0,0,0.1);
    z-index: 1020;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border-radius: 14px 14px 0 0;
  }

  .mobile-bottom-sheet.expanded {
    height: 60vh;
  }

  .sheet-drag-handle {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 34px;
    height: 4px;
    background: #ccc;
    opacity: 0.5;
    border-radius: 2px;
    z-index: 1021;
    pointer-events: none;
  }

  .sheet-header {
    height: 60px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
  }

  .sheet-tabs {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .sheet-tab {
    background: none;
    border: none;
    color: #888;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
  }

  .sheet-tab:hover {
    color: #555;
    background: #f0f0f0;
  }

  .sheet-tab.active {
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  }

  .sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
  }

  .sheet-panel {
    display: none;
    height: 100%;
  }

  .sheet-panel.active {
    display: block;
  }

  /* Push minimap up above the bottom sheet */
  .leaflet-control-minimap {
    margin-bottom: 70px !important;
  }
}

/* ── Map Toolbox ── */

.map-toolbox {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 2px;
  background: #fff;
  border-radius: 10px;
  padding: 4px 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transition: box-shadow 0.2s;
}

.map-toolbox:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}

.toolbox-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  color: #475569;
  transition: background 0.2s, color 0.2s;
}
.toolbox-toggle-btn i {
  font-size: 1.4rem;
}

.toolbox-toggle-btn:hover {
  background: #f1f5f9;
  color: #4f46e5;
}

.toolbox-items {
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  padding-left: 4px;
  border-left: 1px solid #e2e8f0;
  margin-left: 4px;
}

.toolbox-open .toolbox-items {
  display: flex;
  animation: toolboxFadeIn 0.2s ease-out;
}

@keyframes toolboxFadeIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toolboxFadeInVertical {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toolbox-item {
  display: flex;
  align-items: center;
}

/* ── Unified button/link reset inside toolbox ── */

.toolbox-item .leaflet-control-zoom {
  display: flex;
  flex-direction: row;
  position: static;
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  border: none;
}

.toolbox-item button,
.toolbox-item .leaflet-control-zoom a,
.toolbox-item .easy-button-button {
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  font-size: 1.15rem !important;
  border: none !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-decoration: none !important;
  text-align: center !important;
  color: #475569 !important;
  background: transparent !important;
  cursor: pointer !important;
  padding: 0 !important;
  margin: 0 !important;
  transition: background 0.2s, color 0.2s !important;
}

.toolbox-item .leaflet-control-fullscreen a {
  width: 40px !important;
  height: 40px !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-decoration: none !important;
  color: #475569 !important;
  font-size: 1.15rem !important;
  transition: background-color 0.2s !important;
}

.toolbox-item .leaflet-control-fullscreen a:hover {
  background-color: #f1f5f9 !important;
  color: #4f46e5 !important;
}

.toolbox-item .leaflet-control-easyPrint a {
  width: 40px !important;
  height: 40px !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-size: 20px 40px !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  transition: background-color 0.2s !important;
}

.toolbox-item .leaflet-control-easyPrint a:hover {
  background-color: #f1f5f9 !important;
}

.toolbox-item button:hover,
.toolbox-item .leaflet-control-zoom a:hover,
.toolbox-item .easy-button-button:hover {
  background: #f1f5f9 !important;
  color: #4f46e5 !important;
}

.toolbox-item .leaflet-control-zoom a.leaflet-disabled,
.toolbox-item a.leaflet-disabled {
  color: #cbd5e1 !important;
  cursor: default !important;
}

.toolbox-item i,
.toolbox-item svg,
.toolbox-item .fa,
.toolbox-item .fas,
.toolbox-item .far {
  vertical-align: middle !important;
  line-height: 1 !important;
  font-size: 1.4rem !important;
}

/* ── Basemap Selector ── */

.basemap-selector-btn {
  position: absolute;
  bottom: 80px;
  left: 24px;
  z-index: 1000;
}

.basemap-selector-btn .nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-weight: 700;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: #333;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: all 0.2s;
}

.basemap-selector-btn .nav-btn:hover {
  border-color: #4f46e5;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.15);
}

.basemap-selector-btn .nav-btn i {
  color: #4f46e5;
}

.basemap-dropdown {
  position: absolute;
  bottom: 132px;
  left: 24px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  display: none;
  grid-template-columns: repeat(2, 120px);
  gap: 8px;
  z-index: 1000;
  animation: fadeInUp 0.25s ease-out;
}

.basemap-dropdown.active {
  display: grid;
}

.basemap-option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.basemap-thumb {
  height: 64px;
  border-radius: 6px;
  border: 2px solid transparent;
  background-size: cover;
  background-position: center;
  transition: all 0.2s;
}

.basemap-option:hover .basemap-thumb,
.basemap-option.active .basemap-thumb {
  border-color: #4f46e5;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.basemap-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #555;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#project-info-chevron.rotated {
  transform: rotate(180deg);
}

#sidebar-project-info p {
  margin-bottom: 8px;
}
