/* Import LOTR-inspired fonts */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Lato:wght@300;400;700&display=swap');

/* Base styles and colors */
:root {
    --primary-color: #704214; /* Earthy brown */
    --secondary-color: #2c4c28; /* Forest green */
    --accent-color: #c19a5b; /* Gold */
    --dark-color: #1a1a1a;
    --light-color: #f3efe0; /* Parchment */
    --online-color: #2e7d32; /* Rich green */
    --offline-color: #c62828; /* Rich red */
    --map-background: #02598d; /* Original map background */
    --panel-bg: rgba(255, 255, 255, 0.95);
    --panel-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --panel-border-radius: 8px;
    --control-spacing: 10px;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Lato', sans-serif;
    color: var(--dark-color);
    overflow: hidden;
}

/* Map area */
#map-container {
    position: relative;
    height: 100%;
    width: 100%;
    margin: 0;
}

#map {
    height: 100%;
    width: 100%;
    margin: 0;
    background: var(--map-background);
    z-index: 1;
}

/* Floating header styling */
#floating-header {
    position: absolute;
    top: 20px;
    left: 20px;
    background-color: var(--panel-bg);
    border-radius: var(--panel-border-radius);
    box-shadow: var(--panel-shadow);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    z-index: 900;
}

#floating-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('assets/parchment-bg.jpg');
    background-size: cover;
    opacity: 0.2;
    z-index: -1;
    border-radius: var(--panel-border-radius);
}

.header-icon img {
    height: 32px;
    width: 32px;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
    transition: transform 0.3s ease;
}

.header-icon img:hover {
    transform: rotate(10deg);
}

/* Animate the icon with a subtle glow effect */
@keyframes glow {
    0% { box-shadow: 0 0 3px rgba(193, 154, 91, 0.5); }
    50% { box-shadow: 0 0 8px rgba(193, 154, 91, 0.8); }
    100% { box-shadow: 0 0 3px rgba(193, 154, 91, 0.5); }
}

.header-icon img {
    animation: glow 3s infinite;
}

#site-title {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    color: var(--primary-color);
    margin: 0 10px;
    white-space: nowrap;
}

.header-divider {
    width: 1px;
    height: 20px;
    background-color: var(--accent-color);
    margin: 0 10px;
    opacity: 0.6;
}

.header-link {
    font-family: 'Cinzel', serif;
    font-size: 14px;
    text-decoration: none;
    color: var(--primary-color);
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
}

.header-link i {
    margin-right: 5px;
}

.header-link:hover {
    color: var(--accent-color);
}

/* Control Panel */
#control-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: var(--control-spacing);
    z-index: 900;
}

.control-button {
    background-color: var(--panel-bg);
    border-radius: var(--panel-border-radius);
    box-shadow: var(--panel-shadow);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cinzel', serif;
    color: var(--primary-color);
    width: 44px;
    height: 44px;
    box-sizing: border-box;
    position: relative;
}

.control-button i {
    font-size: 18px;
}

.control-button span {
    display: none; /* Hidden by default, shown on hover */
    position: absolute;
    white-space: nowrap;
    right: 60px;
    background-color: var(--panel-bg);
    padding: 5px 10px;
    border-radius: 4px;
    box-shadow: var(--panel-shadow);
    font-size: 14px;
}

.control-button:hover {
    background-color: var(--light-color);
    transform: translateX(-3px);
}

.control-button:hover span {
    display: block;
}

.control-button.active {
    background-color: var(--accent-color);
    color: white;
}

/* Zoom controls */
.zoom-controls {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.zoom-controls .control-button {
    border-radius: 0;
    margin: 0;
}

.zoom-controls #zoom-in {
    border-radius: var(--panel-border-radius) var(--panel-border-radius) 0 0;
}

.zoom-controls #zoom-out {
    border-radius: 0 0 var(--panel-border-radius) var(--panel-border-radius);
}

/* Side panels */
.side-panel {
    position: absolute;
    top: 20px;
    right: 80px;
    width: 280px;
    background-color: var(--panel-bg);
    border-radius: var(--panel-border-radius);
    box-shadow: var(--panel-shadow);
    z-index: 950;
    transform: translateX(500px); /* Increased to ensure it's fully off-screen */
    transition: transform 0.3s ease;
    overflow: hidden;
    max-height: calc(100% - 40px);
    display: flex;
    flex-direction: column;
    opacity: 0; /* Start with opacity 0 */
    visibility: hidden; /* Hide completely by default */
}

.side-panel.visible {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

/* REMOVED duplicate search panel styles to fix the issue */

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background-color: rgba(112, 66, 20, 0.1);
}

.panel-header h3 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: 18px;
    color: var(--primary-color);
}

.close-button {
    cursor: pointer;
    padding: 5px;
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.close-button:hover {
    color: var(--accent-color);
}

.panel-content {
    padding: 15px;
    overflow-y: auto;
    flex-grow: 1;
}

/* Search panel */
#search-box {
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    font-family: 'Lato', sans-serif;
    margin-bottom: 10px;
    background-color: white;
    color: var(--dark-color);
}

#search-results {
    max-height: 300px;
    overflow-y: auto;
}

.search-result {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease;
}

.search-result:hover {
    background-color: rgba(112, 66, 20, 0.1);
}

/* Layer panel */
.layer-option {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.layer-option input {
    margin-right: 10px;
}

.layer-option label {
    font-family: 'Cinzel', serif;
    color: var(--primary-color);
    font-size: 16px;
    cursor: pointer;
}

.layer-option.checkbox {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Legend panel */
.legend-section {
    margin-bottom: 20px;
}

.legend-section h4 {
    font-family: 'Cinzel', serif;
    color: var(--primary-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 5px;
    margin-top: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.color-box {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* Hide Leaflet default zoom control since we have our own */
.leaflet-control-zoom {
    display: none !important;
}

/* Style the Leaflet layer control to match our design */
.leaflet-control-layers {
    display: none !important; /* Hide the default control */
}

/* Popup styling */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    font-family: 'Lato', sans-serif;
}

.leaflet-popup-content {
    margin: 10px;
}

.leaflet-popup-content b {
    color: var(--primary-color);
    font-family: 'Cinzel', serif;
}

.leaflet-popup-tip {
    background-color: white;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #floating-header {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
    }

    .header-icon img {
        height: 24px;
        width: 24px;
    }

    #site-title {
        font-size: 12px;
    }

    #control-panel {
        top: 10px;
        right: 10px;
    }

    .control-button {
        width: 40px;
        height: 40px;
        padding: 10px;
    }

    .side-panel {
        right: 60px;
        width: 240px;
        max-height: calc(100% - 20px);
    }
}
