/* ===== Font (paintbrush style) ===== */
@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&display=swap');

:root{
    --brand-font:'Permanent Marker', cursive;
    --bar-bg:rgba(0,0,0,0.60); /* Match sheet-bg for consistent opacity */
    --bar-bg-hover:#ff4081;
    --sep:rgba(255,255,255,0.20);
    --accent:#ff4081;
}

/* Hide selected OpenLayers controls */
.ol-attribution,
.ol-zoom-in,
.ol-zoom-out,
.ol-rotate-reset { display:none!important; }

/* App-like behavior - no text selection, no link cursors */
* {
    user-select: none;
    cursor: default !important;
}

/* Map takes full screen */
html,body{height:100%;margin:0;}
#map{width:100%;height:100%;}

/* Drawer container */
#drawer-container{
    position:fixed;left:0;bottom:-28vh; /* Updated */
    width:100%;height:38vh; /* Updated */
    z-index:1000;
    transition:bottom .35s ease;
    font-family:var(--brand-font);
    background:var(--bar-bg);backdrop-filter:blur(10px);
}
#drawer-container.open{ bottom:0; }

/* Bar (top 10vh) */
#drawer-bar{
    height:10vh; /* Increased height */
    width:100%;
    display:flex;
    /* justify-content:space-between; Removed for more granular control */
    align-items:center;
    padding:0 2vw; 
    box-sizing:border-box;
    cursor:pointer;
    transition:background .25s;
}
#drawer-bar .brand{
    font-size:4vh; /* Increased font size */
    color:#fff;
    margin:0;
    margin-right: auto; /* Pushes other items to the right */
}
/* Info box for clicked grid point - now part of the bar */
#info-box {
  flex-grow: 1;
  margin: 0 1vw;
  padding: 0.5vh 1vw;
  background: rgba(var(--accent), 0.8);
  color: white;
  border-radius: 0.5vh;
  font-family: var(--brand-font);
  display: flex;
  align-items: center;
  max-height: 8vh;
  overflow: hidden;
  /* New styles for flex layout */
  display: flex;
  justify-content: space-between;
  align-items: center;
}


/* New styles for the left and right containers */
.info-box-left {
  width: 50%;
  text-align: left;
  padding-right: 1vw;
  font-size: 2vh;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-box-right {
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: flex-end; /* Pushes legend content to the right */
}

/* Conditional styling for #info-box when it's used for selection */
/* Ensure the info-box in selecting mode allows its child row to fill it */
#info-box.info-box-selecting {
    display: flex; /* keeps it as a flex container */
    flex-direction: column; /* Stack rows if multiple were ever added */
    justify-content: center; /* Center the row vertically */
    align-items: center; /* Center the row horizontally */
}

.date-selector-row,
.time-selector-row {
    display: flex;
    justify-content: space-around; /* Distribute buttons */
    align-items: center;
    width: 100%;
    padding: 0.5vh 0; /* Add some vertical padding if needed */
}

/* Styling for selector items within the new rows */
#info-box.info-box-selecting .layer-item {
    font-size: 1.5vh; /* Slightly larger for better readability */
    padding: 1vh 1vw; /* More padding like other main buttons */
    flex-basis: var(--selector-basis, 15%); /* Allow JS to override */
    flex-grow: 0;     /* Don't grow beyond basis */
    flex-shrink: 0;   /* Don't shrink */
    margin: 0 1%;     /* Margins between items */
    /* background, border-radius, active/hover states are inherited from general .layer-item */
    /* Ensure text is centered if not by default */
    text-align: center;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Specific styling for the title text div, if different from other #info-box > div items */
#info-box .info-box-title-text {
    font-size: 1.6vh; /* Slightly larger for title */
    text-align: left; /* Changed to left */
    width: 100%; /* Ensure it takes full width */
}

.info-label {
    font-size: 1.6vh;
    margin-right: auto;
}


#info-box-close-button {
    cursor: pointer;
    font-size: 3vh; 
    color: #fff;
    margin-left: 1vw; /* Adjusted margin */
    padding: 0.5vh; 
    line-height: 1;
    display: none; /* Hidden by default */
}
#drawer-caret{
    font-size: 3.5vh; /* Increased font size */
    color:#fff;
    transition:transform .3s;
    margin-left: 1vw; /* Ensures spacing from close button if visible */
}
#drawer-container.open #drawer-caret{transform:rotate(180deg);}


/* Hover: hot pink background for bar, brand, and caret */
#drawer-bar:hover {
    background:var(--bar-bg-hover);
}
#drawer-bar:hover .brand, /* Brand color on hover is fine */
#drawer-bar:hover #drawer-caret,
#drawer-bar:hover #info-box-close-button { 
    color:#fff;
}

/* Content (hidden portion) */
#drawer-content{
    height:28vh; /* Updated */
    width:100%;
    display:flex; 
    color:#fff; 
    padding: 0; /* Base padding, specific padding below */
    padding-bottom: 4vh; /* Added */
    box-sizing: border-box; /* Ensured */
}

/* New Panel Styles */
#layer-panel {
    width: 75%; 
    box-sizing: border-box;
    padding: 1vh; /* Maintained */
    border-right: 1px solid white;
    overflow-y: auto; /* Confirmed */
    height: 100%; /* Confirmed */
}

#settings-grid-panel {
    width: 25%; 
    box-sizing: border-box;
    padding: 1vh; /* Maintained */
    overflow-y: auto; /* Confirmed */
    height: 100%; /* Confirmed */
    display: flex; 
    flex-direction: column;
}

/* Layer Grid (15 items in layer-panel) */
#layer-grid {
    display: grid;
    width: 100%; 
    height: 100%; 
    grid-template-columns: repeat(5, 1fr); /* 5 columns */
    grid-template-rows: repeat(3, 1fr);    /* 3 rows */
    gap: 1vh; 
}

/* Layer Items (General, applies to both grids unless overridden) */
.layer-item {
    padding: 0.75vh 1vh; 
    border-radius: 0.5vh; 
    cursor: pointer;
    font-size: 1.8vh; /* Increased font size */
    transition: background-color 0.2s, color 0.2s;
    background-color: rgba(0, 0, 0, 0.7); 
    backdrop-filter: blur(10px); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
}

.layer-item:hover {
    background-color: rgba(255, 255, 255, 0.2); 
}

.layer-item.active {
    background-color: var(--accent); 
    color: white;
}

/* Not implemented layer items */

/* Settings Grid (3 items in settings-grid-panel) */
#settings-grid {
    display: grid;
    width: 100%;
    flex-grow: 1; /* Allows it to fill height of settings-grid-panel */
    grid-template-columns: 1fr; /* Single column */
    grid-template-rows: repeat(3, 1fr); /* 3 rows */
    gap: 1vh;
}

/* Specific overrides for control buttons in settings-grid */
#settings-grid #day-control-button,
#settings-grid #time-control-button {
    background-color: var(--accent); /* Hot pink */
}
#settings-grid #day-control-button:hover,
#settings-grid #time-control-button:hover {
    background-color: #e03770; /* Slightly darker pink for hover */
}

/* Toggle Button Styling */
.toggle-button {
    position: relative;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 0.5vh;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 1.8vh;
    transition: all 0.3s ease;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 60%;
    height: 100%;
    background-color: var(--accent);
    border-radius: 0.5vh;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.toggle-button.smooth .toggle-slider {
    left: 40%;
    width: 60%;
}

.toggle-label {
    position: absolute;
    z-index: 2;
    color: white;
    font-weight: bold;
    transition: color 0.3s ease;
    pointer-events: none;
    width: 40%;
    text-align: center;
}

.toggle-label.left {
    left: 0;
}

.toggle-label.right {
    right: 0;
}

.toggle-button.smooth .toggle-label.left {
    color: rgba(255, 255, 255, 0.7);
}

.toggle-button.smooth .toggle-label.right {
    color: white;
}

/* Disabled toggle button styling */
.toggle-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: rgba(0, 0, 0, 0.3);
}

.toggle-button.disabled .toggle-slider {
    background-color: rgba(128, 128, 128, 0.5);
}

.toggle-button.disabled .toggle-label {
    color: rgba(255, 255, 255, 0.4);
}


.brand.flash-error,
#drawer-caret.flash-error {
  color: #ff0033 !important;
  transition: color 0.5s cubic-bezier(.66,.09,1,.42);
}

/* Info box styling is now part of #drawer-bar section above */
/* #info-box > div styling is now part of #drawer-bar section above */

/* Simple legend for collapsed info box */
.legend {
    display: flex;
    align-items: center;
    font-size: 1.3vh;
}
.legend-bar {
    flex-grow: 1;
    min-width: 10vw; /* Ensures visibility */
    height: 3vh;
    margin: 0 0.5vw;
    border: 1.5px solid rgba(255,255,255);
}

/* Map click popup */
.popup {
    position: absolute;
    background: rgba(0, 0, 0, 0.85); /* Updated background opacity */
    color: white;
    padding: 1vh 1.5vw; /* Updated padding */
    border-radius: 0.5vh;
    pointer-events: none;
    transform: translate(-50%, -100%);
    font-family: var(--brand-font);
    font-size: 1.5vh;
    width: 35vw; /* Wider popup for residual table */
    box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.5); /* Added drop shadow */
}

.popup::after {
    content: '';
    position: absolute;
    bottom: -10px; /* Adjust to control the arrow's position relative to the popup bottom */
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent; /* Size of the arrow */
    border-right: 10px solid transparent; /* Size of the arrow */
    border-top: 10px solid rgba(0, 0, 0, 0.85); /* Color of the arrow, matches anticipated popup bg */
    pointer-events: none; /* Ensure arrow doesn't interfere with clicks */
}

.popup-close-button {
    position: absolute;
    top: 5px; /* Adjust as needed */
    right: 10px; /* Adjust as needed */
    color: white;
    font-size: 20px; /* Adjust as needed */
    font-weight: bold;
    cursor: pointer !important; /* Ensure cursor is pointer */
    z-index: 10; /* Ensure it's above popup-content if content is positioned */
    pointer-events: auto; /* Make sure it can receive click events */
}
.popup-close-button:hover {
    color: #ff4081; /* Accent color on hover, or any other suitable hover effect */
}

/* Table inside popup showing residuals */
.popup-table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 0.5vh;
}
.popup-table th,
.popup-table td {
    border: 1px solid white;
    padding: 0.2vh 0.5vw;
    font-size: 1.4vh;
}
.popup-table th {
    font-weight: bold;
}