:root {
    --bg-dark: #121212;
    --panel-dark: #1e1e1e;
    --accent: #1abc9c;
    --text-main: #e0e0e0;
    --text-dim: #999;
    --border: #333;
}

body { 
    margin: 0; 
    padding: 0; 
    font-family: 'Inter', sans-serif; 
    background-color: var(--bg-dark);
    color: var(--text-main);
}

#main-container {
    position: relative; /* Essential for absolute positioning of the button */
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* When collapsed, we slide the sidebar out of view using a negative margin */
#main-container.collapsed #sidebar {
    margin-left: -340px;
}

#main-container.collapsed #toggle-btn {
    left: 4px; /* Pin it to the very left of the screen when sidebar is hidden */
}

#sidebar {
    position: relative;
    min-width: 320px;       /* Minimum room for labels */
    width: fit-content;     /* Expands based on the widest filter row */
    max-width: 450px;       /* Prevents it from taking over the screen */
    height: 100vh;
    overflow-y: auto;
    padding: 20px;
    background: #222;
    color: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.5); /* Adds depth over the map */
    z-index: 10;            /* Ensures it stays on top */
    transition: margin-left 0.3s ease;
}  

#map {
    flex-grow: 1; /* Map takes up all available space */
    height: 100vh;
}

/* Style the toggle button */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 30px; /* Adjust this value to your liking */
}

/* New styling for the floating button */
#toggle-btn {
    position: absolute;
    left: 340px; /* Same as sidebar width */
    top: 20px;
    z-index: 1001; /* Stay above the sidebar and map */
    background: var(--accent);
    border: none;
    color: white;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 10px 10px 10px 10px; /* Rounded only on the right side */
    transition: left 0.3s ease; /* Match the sidebar slide speed */
    box-shadow: 2px 0 5px rgba(0,0,0,0.3);
}

.map-title { font-size: 1.25rem; font-weight: 700; margin: 0; color: var(--accent); }
.subheading { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); margin-bottom: 1px; }

.sidebar-section { display: flex; flex-direction: column; gap: 12px; }

.divider { border: 0; border-top: 1px solid var(--border); width: 100%; margin: 5px 0; }

/* Form Elements */
select, button, input {
    background: #2a2a2a;
    color: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    font-size: 0.9rem;
    transition: 0.2s;
}

button:hover { background: #3a3a3a; cursor: pointer; border-color: var(--accent); }

.bulk-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.bulk-actions button { flex: 1; padding: 4px; font-size: 0.75rem; }

/* Legend UI */
#legend-container { display: flex; flex-direction: column; gap: 6px; margin-bottom: 1px; }
.legend-item { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; }
.legend-color { width: 10px; height: 10px; border-radius: 50%; }

/* Advanced Builder Rows */
.filter-row { display: flex; gap: 5px; margin-bottom: 10px; }
.filter-row select, .filter-row input { flex: 1; font-size: 0.7rem; padding: 5px; }

.filter-row {
    display: grid;
    grid-template-columns: 1fr 0.8fr 1fr auto;
    gap: 5px;
    margin-bottom: 10px;
    align-items: center;
}

.filter-row select, .filter-row input {
    background: #444;
    color: white;
    border: 1px solid #555;
    padding: 4px;
    border-radius: 4px;
    font-size: 12px;
}

.maplibregl-popup {
    max-width: 300px !important; /* Forces the width */
}

.maplibregl-popup-content {
    background: #252525 !important;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.85rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.maplibregl-popup-tip {
    border-top-color: #252525 !important;
}

.hover-popup b {
    color: #999;
    font-weight: 400;
}

/* Layout for the header section of the popup */
.popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

/* Constrain the logo size */
.popup-logo {
    width: 50px;
    height: 50px;
    object-fit: contain; /* Keeps the logo's proportions */
    border-radius: 4px;
    background: #333; /* Slight background in case the logo is transparent */
}

.popup-divider {
    border: 0;
    border-top: 1px solid #444;
    margin: 5px 0;
}


#content-area {
    flex-grow: 1;
    display: grid;
    height: 100vh;
    transition: grid-template-columns 0.3s ease;
}

/* View Modes */
.view-map { grid-template-columns: 1fr 0fr; }
.view-calendar { grid-template-columns: 0fr 1fr; }
.view-both { grid-template-columns: 1fr 1fr; }

#calendar-container {
    background: #121212;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

#calendar-header {
    display: flex;             /* Align children side-by-side */
    justify-content: center;   /* Center the whole group horizontally */
    align-items: center;       /* Center them vertically */
    gap: 20px;                 /* Space between buttons and the month text */
    padding: 15px;
    background: var(--panel-dark);
}

#calendar-header h2 {
    margin: 0;                 /* Remove default browser margins that cause jumping */
    font-size: 1.2rem;
    min-width: 150px;          /* Prevents buttons from moving when month length changes */
    text-align: center;
}

#calendar-header button {
    background: none;
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 5px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: 0.2s;
}

#calendar-header button:hover {
    background: var(--border);
    color: white;
}

#calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    padding: 10px;
}

.calendar-day {
    background: #1e1e1e;
    min-height: 120px;
    padding: 5px;
    color: var(--text-dim);
}

.crew-event {
    background: var(--accent);
    color: black;
    font-size: 0.7rem;
    padding: 2px 5px;
    margin-bottom: 2px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 5;
}

.crew-event.highlight {
    outline: 2px solid white;
    box-shadow: 0 0 10px var(--accent);
}