﻿/* Ensure the Blazor root and MudLayout allow full height */
#app, .mud-layout {
    height: 100%;
}

/* Force the main content to be a flex container */
.mud-main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Ensure the Leaflet container actually expands */
.leaflet-container {
    height: 100%;
    width: 100%;
}

/* Make the drawer slightly transparent to see the map underneath */
/*.mud-drawer {
    background-color: rgba(30, 30, 39, 0.9) !important;*/ /* Adjust based on your theme colors */
    /*backdrop-filter: blur(4px);*/ /* Adds a nice glass effect */
/*}*/

/* Custom Leaflet Tooltip Styling */
.leaflet-tooltip {
    background-color: #27272f !important; /* Match MudBlazor Surface color */
    color: white !important;
    border: 1px solid #3e3e42 !important;
    border-radius: 4px;
    padding: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* Remove the little white "beak" or arrow of the tooltip */
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
    display: none;
}

/* Replace Leaflet Layer Control icon with a Globe */
.leaflet-control-layers-toggle {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='2' y1='12' x2='22' y2='12'%3E%3C/line%3E%3Cpath d='M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z'%3E%3C/path%3E%3C/svg%3E") !important;
    background-size: 20px 20px;
}

/* Splash Screen Styles */
.white-text {
    color: white !important;
}
.secondary-text-opacity {
    opacity: 0.7;
}
.font-weight-bold {
    font-weight: 700;
}

.map-fab-print {
    position: absolute !important;
    top: 80px; /* Shifted down from 10px */
    right: 10px; /* Positioned to the left of the Leaflet zoom controls */
    z-index: 1000; /* Above Leaflet layers but below complex UI if needed */
}

.map-fab-export {
    position: absolute;
    top: 130px; /* Shifted down from 60px */
    right: 10px;
    z-index: 1000;
}

/* Increase Snackbar z-index to stay above maps and dialogs */
#mud-snackbar-container {
    z-index: 3000 !important;
}

/* Hide the print metadata container during normal browsing */
.print-only-text {
    display: none;
}

/* New class for the container holding the map and the inset panels */
.map-fullscreen-container {
    height: 100%;
    width: 100%;
    position: relative; /* Essential for absolute positioning of inset panels */
}

@media print {
    /* Hide everything except the necessary map and print container */
    header, .mud-drawer, .mud-appbar, .leaflet-control-zoom, .leaflet-control-layers, .map-fab-print, .map-fab-export, .leaflet-control-geocoder {
        display: none !important;
    }

    body {
        visibility: hidden;
        margin: 0;
        padding: 0;
        background-color: white !important;
    }

    /* Make the entire map area visible and fill the page */
    .map-fullscreen-container {
        visibility: visible !important;
        width: 100vw !important;
        height: 100vh !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 5000 !important;
        background-color: white !important;
    }

    .leaflet-container {
        visibility: visible !important;
        height: 100% !important; /* Map fills the fullscreen container */
        width: 100% !important;
    }

    #qgis-map, #qgis-map * {
        visibility: visible !important;
    }

    /* Print Details Panel (Bottom Right Inset) */
    .print-only-text.inset-print-panel { /* Target with new class to avoid conflicts */
        visibility: visible !important;
        display: flex !important; /* Use flex to stack its children */
        flex-direction: column !important;
        justify-content: flex-start !important; /* Align content from top */
        
        /* Positioning on the map */
        position: absolute !important;
        bottom: 10px !important;
        right: 10px !important;
        width: 300px !important; /* Fixed width */
        height: auto !important; /* Content-driven height */
        max-height: calc(100vh - 20px); /* Max height to prevent overflow, adjust as needed */
        
        background: #fff !important;
        border: 2px solid #112e51 !important; /* Add border as per design */
        box-sizing: border-box !important;
        overflow: hidden; /* Or auto if content might exceed max-height */
        padding: 4px; /* Internal padding */
        z-index: 5001 !important; /* Above the map */
    }

    .print-only-text.inset-print-panel * {
        visibility: visible !important;
    }

    /* Print Index Map Panel (Upper Right Inset) */
    .print-only-text.inset-index-map-panel {
        visibility: visible !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;

        /* Positioning on the map */
        position: absolute !important;
        top: 10px !important;
        right: 10px !important;
        width: 300px !important; /* Consistent fixed width for the panel */
        height: auto !important; /* Content-driven height */
        max-height: 230px !important; /* Max height to prevent overflow */

        background-color: white !important;
        border: 1.5px solid #112e51 !important;
        box-sizing: border-box !important;
        overflow: hidden;
        margin: 0;
        padding: 0;
        z-index: 5001 !important; /* Above the map */
    }

    /* Move GIS scale bar to the upper right during print */
    .leaflet-control-scale {
        position: fixed !important;
        top: 330px !important;
        right: 10px !important; /* Positioned just left of the 300px wide Upper Right Inset Panel */
        bottom: auto !important;
        left: auto !important;
        z-index: 5002 !important;
    }

    .leaflet-control-north-arrow {
        position: fixed !important;
        top: 250px !important;
        right: 100px !important; /* Positioned just left of the 300px wide Upper Right Inset Panel */
        bottom: auto !important;
        left: auto !important;
        z-index: 5002 !important;
    }

    .print-only-text.inset-index-map-panel * {
        visibility: visible !important;
    }

    /* Reset MudBlazor layout artifacts */
    .mud-layout, .mud-main-content, .mud-main-content > div {
        padding: 0 !important;
        margin: 0 !important;
        height: 100% !important;
        min-height: 100% !important;
        overflow: visible !important;
    }

    /* Ensure scale and map controls stay at bottom of printed page */
    .leaflet-bottom {
        bottom: 5px !important;
    }
}

/* Elevate bottom controls on mobile to avoid overlapping with browser navigation bars */
@media (max-width: 768px) {
    .leaflet-bottom {
        bottom: 70px !important; /* Adjust this value based on your specific needs */
    }
}

/* ... existing styles ... */

/* Splash Screen Styles */
.splash-logo {
    height: 240px;
    border-radius: 24px; /* Keeps the rounded corners */
    overflow: hidden; /* Ensures the image content is clipped to the corners */
    object-fit: cover; /* Ensures the image fills the area correctly */
    transition: height 0.3s ease;
}

.splash-progress {
    width: 300px;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    #nav-drawer {
        height: 104px !important;
    }

    .splash-logo {
        height: 150px; /* Reduced size for mobile */
        border-radius: 16px; /* Slightly smaller radius for smaller image */
    }

    .splash-progress {
        width: 200px; /* Reduced width for mobile */
    }
}

/* Screen state */
.print-only-text {
    display: none;
}

@media print {
    /* Print state */
    /* This rule is now overridden by .print-only-text.inset-print-panel, can be removed if desired. */
    .print-only-text {
        display: flex !important; /* Forces flex here so children stay top/bottom */
        flex-direction: column !important;
        justify-content: space-between !important;
        visibility: visible !important;
    }

    /* This rule is now superseded by .map-fullscreen-container, can be removed if desired. */
    .map-print-layout {
        display: flex !important;
        flex-direction: row !important;
        visibility: visible !important;
    }
}

.line-label-style {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #000;
    font-weight: bold;
    font-size: 10px;
    text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
    pointer-events: none;
}

/* Ensure labels are visible and bypass default Leaflet tooltip styling */
.leaflet-tooltip.line-label-style {
    background-color: rgba(255, 255, 255, 0.7) !important;
    border: 1px solid #666 !important;
    color: #000 !important;
    font-weight: bold !important;
    font-size: 11px !important;
    padding: 1px 3px !important;
    box-shadow: none !important;
    white-space: nowrap;
    pointer-events: none;
}

.leaflet-tooltip-left.line-label-style::before,
.leaflet-tooltip-right.line-label-style::before {
    display: none !important; /* Hide the tooltip arrow */
}