@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;700&display=swap');

:root {
    --primary-color: #2563eb;
    --bg-app: #020617;
    --text-main: #f8fafc;
    --sidebar-width: 320px;
    --sidebar-bg: rgba(15, 23, 42, 0.8);
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-text: #ffffff;
    --sidebar-text-dim: rgba(255, 255, 255, 0.6);
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --app-glow: rgba(37, 99, 235, 0.15);
    --marker-bg: #2563eb;
    --marker-dot: #ffffff;
    --header-bg: #ffffff;
}

.theme-light-cream {
    --primary-color: #facc15;
    --bg-app: #fdf8f4;
    --text-main: #1e293b;
    --sidebar-bg: #1e293b;
    --sidebar-border: #2d3748;
    --sidebar-text: #ffffff;
    --sidebar-text-dim: #cbd5e1;
    --sidebar-hover: #2d3748;
    --app-glow: rgba(250, 204, 21, 0.05);
    --marker-bg: #1e293b;
    --marker-dot: #facc15;
    --header-bg: #ffffff;
}

.theme-modern-white {
    --primary-color: #3b82f6;
    --bg-app: #ffffff;
    --text-main: #0f172a;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;
    --sidebar-text: #0f172a;
    --sidebar-text-dim: #64748b;
    --sidebar-hover: #f1f5f9;
    --app-glow: rgba(59, 130, 246, 0.03);
    --marker-bg: #3b82f6;
    --marker-dot: #ffffff;
    --header-bg: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

/* Custom scrollbar for sidebar */
#points-list::-webkit-scrollbar {
    width: 6px;
}

#points-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

#points-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

#points-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
    opacity: 0.8;
}

/* Header */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    z-index: 100;
    background: var(--header-bg);
    border-bottom: 3px solid var(--primary-color);
    padding: 0.75rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.header-container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.header-right {
    display: flex;
    gap: 1rem;
    width: 200px;
    justify-content: flex-end;
}

.header-right a {
    color: #1e293b;
    font-size: 1.25rem;
    text-decoration: none;
    transition: color 0.2s;
}

.header-right a:hover {
    color: var(--primary-color);
}

.site-logo {
    margin-bottom: 0.25rem;
}

.site-logo a {
    color: #1e293b;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.025em;
}

.main-navigation ul {
    display: flex;
    list-style: none;
    gap: 2.5rem;
}

.main-navigation a {
    color: #1e293b;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s;
}

.main-navigation a:hover {
    color: var(--primary-color);
}

/* Map App Container */
#map-app {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    background-color: var(--bg-app);
    box-shadow: inset 0 0 150px var(--app-glow);
}

/* Viewport & Layers */
.map-viewport {
    width: 100%;
    height: 100%;
    cursor: grab;
    overflow: hidden;
    position: relative;
}

.map-viewport:active {
    cursor: grabbing;
}

#map-layers {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    will-change: transform;
}

#map-image-wrapper {
    position: relative;
}

#map-image {
    display: block;
    user-select: none;
    pointer-events: none;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    background-color: #222;
    /* Fallback */
}

/* Markers */
.marker {
    position: absolute;
    width: 66px;
    height: 66px;
    background: var(--marker-bg);
    border: 4px solid white;
    border-radius: 50% 50% 50% 0;
    transform: translate(-50%, -100%) rotate(-45deg);
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.marker:hover {
    background-color: var(--primary-color);
    transform: translate(-50%, -100%) rotate(-45deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.marker::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--marker-dot);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Sidebar */
#sidebar-navigation {
    position: absolute;
    left: 20px;
    top: 100px;
    /* Adjusted for refined header */
    bottom: auto;
    max-height: calc(100vh - 140px);
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 12px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: 0;
    transition: transform 0.3s ease, left 0.3s ease, right 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

/* Right-aligned sidebar */
#sidebar-navigation.sidebar-right {
    left: auto;
    right: 20px;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 3px solid var(--primary-color);
    position: relative;
    border-radius: 12px 12px 0 0;
}

.sidebar-header::after {
    content: '↴';
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.sidebar-header h2 {
    font-size: 0.9rem;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

#points-list {
    list-style: none;
    overflow-y: auto;
    flex: 0 1 auto;
    max-height: 300px;
}

.point-item {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--sidebar-border);
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.point-item:last-child {
    border-bottom: none;
}

.point-item:hover {
    background: var(--sidebar-hover);
    padding-left: 1.75rem;
}

.point-item:focus {
    background: var(--sidebar-hover);
    padding-left: 1.75rem;
    box-shadow: inset 3px 0 0 var(--primary-color);
}

.point-item h4 {
    margin-bottom: 0.25rem;
    color: var(--sidebar-text);
    font-size: 0.9rem;
    font-weight: 500;
}

.point-item p {
    font-size: 0.75rem;
    color: var(--sidebar-text-dim);
    line-height: 1.4;
}

/* Controls */
#map-controls {
    position: absolute;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 50;
}

#map-controls button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    font-size: 1.25rem;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#map-controls button:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Popup */
#map-popup {
    position: absolute;
    width: 400px;
    max-width: 90vw;
    background: white;
    color: #1e293b;
    border-radius: 16px;
    overflow: hidden;
    z-index: 200;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: auto;
}

#map-popup.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.close-popup {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.popup-image {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-color: #e2e8f0;
}

.popup-content {
    padding: 1.5rem;
}

.popup-title {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.popup-description {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #64748b;
    margin-bottom: 1.25rem;
    max-height: 150px;
    overflow-y: auto;
}

.btn-more {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-more:hover {
    background: #1d4ed8;
}