/* Constrain the main app container within the flex body */
#app-container {
    flex: 1; 
    display: flex;
    flex-direction: column;
    margin-top: 30px;
    margin-bottom: 40px;
    width: 100%;
    box-sizing: border-box;
}

/* Top Dashboard Bar Styling */
#top-bar {
    background: #fff;
    padding: 20px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    margin-bottom: 20px;
    border: 1px solid #f3f4f6;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
}

.stats-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-weight: 600;
    color: #3b82f6;
    font-size: 1.1rem;
}

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

.control-group label { 
    font-size: 0.85rem; 
    color: #4b5563; 
    font-weight: 600; 
}
.control-group select { 
    padding: 8px 12px; 
    border-radius: 8px; 
    border: 1px solid #d1d5db;
    font-family: 'Inter', sans-serif;
    outline: none;
}

.action-row {
    display: flex;
    gap: 10px;
}

.action-row .btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.action-row .btn svg { 
    width: 18px; 
    height: 18px; 
    fill: currentColor; 
}

/* Button color variations matching global theme */
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-warning { background: #f59e0b; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: #ef4444; }
.btn-danger:hover { background: #dc2626; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Map and Sidebar Layout */
#main-area {
    display: flex;
    gap: 25px;
    width: 100%;
    height: 65vh;
    min-height: 500px;
}

#map {
    flex: 1;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    z-index: 1; /* Keeps map rendering below the sticky header */
    border: 1px solid #f3f4f6;
}

/* Leaflet Map Controls Customization */
.leaflet-bar {
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.leaflet-bar a, 
.leaflet-bar a:hover {
    min-width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    padding: 0 10px !important;
    background-color: #111827 !important; /* Navy blue matching site page-header banner */
    color: #ffffff !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 1.4rem !important; /* Larger text for clearly visible + and - */
    font-weight: 600 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

/* Text adjustments for word-based buttons like Reset */
.leaflet-bar a:not(:empty) {
    font-size: 0.85rem !important; /* Slightly smaller font size so full words fit nicely */
    font-weight: 600 !important;
    width: auto !important;
}

.leaflet-bar a:last-child {
    border-bottom: none !important;
}

.leaflet-bar a:hover {
    background-color: #1f2937 !important; /* Slightly lighter shade on hover */
    color: #3b82f6 !important; /* Accent blue glow on text/icon */
}

/* Midpoint Distance Text Label on Map Path */
.path-distance-label {
    color: #000000;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    pointer-events: none;
    transform-origin: center bottom;
    text-shadow: 0px 0px 4px #ffffff, 0px 0px 2px #ffffff;
}

/* Widen the sidebar box to fit two columns side-by-side */
#sidebar {
    width: 420px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #f3f4f6;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

/* Two-column layout inside the sidebar container */
#results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    font-size: 0.8rem;
}

/* Ensure any headings span across both columns */
#results h3, #results h4, #results .full-width {
    grid-column: 1 / -1;
    font-size: 0.95rem;
    margin: 2px 0;
}

#results p, #results div {
    margin: 2px 0;
    line-height: 1.3;
}

/* Mobile Responsiveness matching global 768px breakpoint */
@media (max-width: 768px) {
    #top-bar { 
        flex-direction: column; 
        align-items: stretch; 
        text-align: center;
    }
    .action-row { 
        flex-wrap: wrap; 
        justify-content: center;
    }
    .stats-section {
        align-items: center;
    }
    
    #main-area {
        flex-direction: column;
        height: auto;
    }
    
    #map {
        height: 450px;
        width: 100%;
    }
    
    #sidebar {
        width: 100%;
        height: auto;
        max-height: 350px;
    }
}