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

html {
  height: 100%;
  overflow: hidden;
  max-width: 100vw;
}

body,
html,
#map {
  width: 100%;
  height: 100%;
}

body {
  position: relative;
  display: flex;
  justify-content: center;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background-color: #f1f1f1;
  overflow: hidden;
  max-width: 100vw;
}

.main-container {
  display: flex;
  flex-direction: row;
  height: 100vh;
  width: 100vw;
  max-width: 100vw;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
}

.mapid {
  flex: 1;
  min-height: 0; /* Important for flex children to shrink */
  position: relative;
}

.flex {
  display: flex;
  flex-direction: row;
}

/* Update map and sidebar to use flex instead of fixed widths */
.leftcol, #map {
  flex: 1;
  min-width: 300px; /* Minimum width */
  max-width: calc(100vw - 250px - 8px); /* Ensure it doesn't exceed viewport */
  height: 100%;
  overflow: hidden;
  position: relative;
}

.rightcol, #sidebar {
  flex: 0 0 400px; /* Fixed basis of 400px, but can shrink/grow */
  min-width: 250px; /* Minimum width */
  max-width: 70%; /* Prevent sidebar from taking over */
  background: #fff;
  text-align: right;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* Resizable divider styles */
.divider {
  width: 8px;
  background: linear-gradient(90deg, #e0e0e0, #f5f5f5, #e0e0e0);
  cursor: ew-resize;
  position: relative;
  border-left: 1px solid #ccc;
  border-right: 1px solid #ccc;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.divider:hover {
  background: linear-gradient(90deg, #d0d0d0, #e5e5e5, #d0d0d0);
}

.divider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 30px;
  background: #999;
  border-radius: 2px;
  pointer-events: none;
}

.divider:hover .divider-handle {
  background: #666;
}

.sidebar-el {
  padding: 5px 10px;
  background: #fff;
  cursor: pointer;
}

.sidebar-el:hover {
  background: #f1f1f1;
}

.leftcol {
   flex: 1;
   min-width: 300px;
   overflow: hidden;
   height: 100%;
   display: flex;
   flex-direction: column;
}

.rightcol {
   padding: 10px;
   display: flex;
   flex-direction: column;
   box-sizing: border-box;
}

/* Flexible icon buttons layout */
.icons-row {
   display: flex;
   flex-wrap: wrap;
   gap: 5px;
   margin-bottom: 10px;
   align-items: center;
}

.icon-button {
   flex: 0 0 auto;
   min-width: 40px; /* Minimum width for each button */
}

/* Content area */
.content-area {
   flex: 1;
   display: flex;
   flex-direction: column;
   min-height: 0; /* Important for flex children to shrink */
   overflow: hidden;
}

/* Ensure only the text content is scrollable and takes remaining space */
.text-content {
   flex: 1;
   overflow-y: auto;
   padding: 10px 0;
   text-align: right;
   min-height: 0;
}

.textcol {
   height: 400px;
   overflow-y: scroll;
}

/* Stretch sidebar_content to fill remaining space */
#sidebar_content {
   flex: 1;
   display: flex;
   flex-direction: column;
   min-height: 0; /* Important for flex children to shrink */
   overflow: hidden;
}

#sidebar_content_text {
   flex: 1;
   overflow-y: auto;
   padding: 10px 0;
   min-height: 0; /* Important for flex children to shrink */
   width: 100%; /* Ensure full width */
}

/* New styles for sidebar header and content */
.sidebar-header {
   flex-shrink: 0;
   flex-grow: 0;
   margin-bottom: 10px;
   padding: 0;
}

.header-navigation {
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 10px;
   margin: 0;
   padding: 5px 0;
}

.nav-button {
   flex: 0 0 auto;
}

.header-title {
   flex: 1;
   text-align: center;
   font-weight: bold;
   margin: 0;
   padding: 0;
}

.text-content {
   flex: 1;
   overflow-y: auto;
   padding: 0;
   text-align: right;
   min-height: 0;
   align-self: flex-start;
}
