:root {
    --primary-color: #c4a77d;
    --secondary-color: #2c3e50;
    --bg-color: #f4f4f4;
    --sidebar-width: 300px;
    --text-color: #333;
    --border-color: #ddd;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100%;
    height: 100svh; /* For mobile viewport height, auto fallback*/
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    position: relative;
}

.sidebar-header {
    padding: 7px;
    background: var(--secondary-color);
    color: white;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

@media screen and (max-width: 768px) {
    .sidebar-header {
        display: none;
    }
    .floating-showhide-btn {
        display: block !important;
    }
    .floating-showhide-btn-pc {
        display: none !important;
    }
    .sidebar.hidden {
        transform: translateY(100vh);
        transform: translateY(100svh); /* Fallback for browsers not supporting svh */
    }
}
@media screen and (min-width: 769px) {
    .sidebar {
        transition: transform 0.3s ease;
    }
    
}

.sidebar-header h1 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.sidebar-header nav a {
    color: #ccc;
    text-decoration: none;
    margin-right: 15px;
    font-weight: bold;
    padding-bottom: 5px;
}

.sidebar-header nav a.active {
    color: white;
    border-bottom: 2px solid var(--primary-color);
}

.sidebar-header nav a:hover {
    color: white;
}

.sidebar-header nav a.uid-link {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.search-container {
    padding: 5px;
    border-bottom: 1px solid var(--border-color);
}

.selectors {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 5px;
}

.map-selector-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

.map-selector-btn {
    padding: 5px 5px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.2s;
    color: #555;
}

.map-selector-btn:hover {
    background: #f0f0f0;
    border-color: #bbb;
}

.map-selector-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: bold;
}

.region-select {
    width: 100%;
    padding: 5px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    font-size: 0.9rem;
}

/* Search */
.search-wrapper {
    position: relative;
    width: 100%;
}

#search-input {
    width: 100%;
    padding: 6px 30px 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: none;
}

.search-clear:hover {
    color: #333;
}

.search-clear.visible {
    display: block;
}

/* Filter Controls */
.filter-controls {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 5px;
    margin-bottom: 5px;
}

.control-group {
    display: flex;
    gap: 5px;
}

.filter-btn {
    padding: 6px 10px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.sidebar-footer {
    padding: 5px;
    border-top: 1px solid var(--border-color);
    background: #f8f9fa;
}

/* Toggle Control */
.toggle-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
    padding: 6px 10px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    white-space: nowrap;
    transition: all 0.2s;
}

.toggle-control:hover {
    background: #f0f0f0;
    border-color: #999;
}

.toggle-control input {
    cursor: pointer;
}

.toggle-control .sword-check {
    width: 16px;
    height: 16px;
    min-width: 16px;
}

.language-selector-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

.language-selector {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    font-size: 0.85rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.language-selector:hover {
    border-color: #999;
}

.language-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(196, 167, 125, 0.15);
}

.language-selector option {
    background: #fff;
    color: #333;
    padding: 6px 8px;
}

#btn-viethoa {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
        position: relative;
        order: 2;
    }

    .map-container, .content-container {
        height: 60vh;
        order: 1;
    }
    
    .content-container {
        overflow-y: auto;
    }
    .copyright {
        display: none;
    }
    #btn-viethoa {
        display: inline-block;
        text-decoration: none;
        color: inherit;
    }
}

.copyright {
    font-size: 0.8rem;
    color: #888;
    margin-top: 5px;
}

.maplibregl-popup-close-button {
    font-size: 16px;
    color: #333;
    padding: 2px 6px;
}

li {
    margin-left: 20px;
}
.marker-popup-category {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.marker-popup-icon {
    width: 20px;
    height: 20px;
}
.marker-popup-category strong {
    color: #1a00a3;
}
.marker-popup-image img {
    width: 100%;
    height: auto;
}

/* Image Overlay */
.image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    cursor: pointer;
}

.image-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border-radius: 4px;
}

.image-overlay .close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 30px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
}

.floating-showhide-btn {
    position: absolute;
    top: -50px;
    left: 10px;
    z-index: 1500;
    background: white;
    color: black;
    border: 2px solid #80808036;
    width: 40px;
    height: 40px;
    text-align: center;
    font-size: 30px;
    border-radius: 4px;
    display: none;
    line-height: 40px;
    font-family: monospace;
    display: none;
}

.floating-showhide-btn-pc {
    position: absolute;
    top: 50svh;
    right: -26px;
    z-index: 1500;
    background: white;
    color: black;
    width: 25px;
    height: 60px;
    transform: translateY(-50%);
    text-align: center;
    font-size: 30px;
    line-height: 40px;
    font-family: monospace;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

@keyframes flashing-green {
    0% { background-color: #b6fcb6; }
    50% { background-color: #34c634; }
    100% { background-color: #b6fcb6; }
}
#btn-load-game-data.active {
    background-color: white !important;
    color: black !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
}
#btn-load-game-data.active::after {
    content: ' ';
    height: 15px;
    display: inline-block;
    width: 15px;
    border-radius: 8px;
    animation: flashing-green 2s infinite;
    z-index: -1;
    margin-left: 10px;
}

.toast-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 0.9rem;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.5s;
}

.toast-message.visible {
    opacity: 1;
}

.status-circle {
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid gray;
        text-align: center;
    line-height: 18px;
}