:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-color: #F8FAFC;
    --panel-bg: rgba(255, 255, 255, 0.85);
    --panel-border: rgba(0, 0, 0, 0.08);
    --text-main: #0F172A;
    --text-muted: #64748B;
    --accent: #10B981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--panel-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #0F172A, #475569);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Search */
.search-container {
    position: relative;
    display: flex;
    flex-direction: column;
}

#searchInput {
    width: 100%;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: rgba(241, 245, 249, 0.8);
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

#searchInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.search-results.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid var(--panel-border);
    cursor: pointer;
    transition: background 0.2s;
}

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

.search-result-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.search-result-title {
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.search-result-floor {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Floor Selector */
.floor-selector h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.floor-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.floor-btn {
    padding: 0.8rem 0;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: rgba(241, 245, 249, 0.8);
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.floor-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.floor-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.instructions {
    margin-top: auto;
    padding: 1.5rem;
    background: rgba(241, 245, 249, 0.8);
    border-radius: 12px;
    border: 1px solid var(--panel-border);
}

.instructions p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}

/* Map Area */
.map-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.controls {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--panel-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.map-container {
    width: 100%;
    height: 100%;
    cursor: grab;
    overflow: hidden;
}

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

.map-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
}

.floor-map {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.floor-map.active {
    opacity: 1;
    visibility: visible;
}

/* Marker */
.map-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -100%);
    z-index: 30;
    pointer-events: none;
}

.map-marker.hidden {
    display: none;
}

.map-marker .pin {
    width: 20px;
    height: 20px;
    border-radius: 50% 50% 50% 0;
    background: var(--accent);
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -10px 0 0 -10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.map-marker .pin::after {
    content: '';
    width: 8px;
    height: 8px;
    margin: 6px 0 0 6px;
    background: var(--bg-color);
    position: absolute;
    border-radius: 50%;
}

.map-marker .pulse {
    background: rgba(16, 185, 129, 0.4);
    border-radius: 50%;
    height: 14px;
    width: 14px;
    position: absolute;
    left: 50%;
    top: 100%;
    margin: -7px 0px 0px -7px;
    transform: rotateX(55deg);
    z-index: -2;
}

.map-marker .pulse::after {
    content: "";
    border-radius: 50%;
    height: 40px;
    width: 40px;
    position: absolute;
    margin: -13px 0 0 -13px;
    animation: pulsate 1.5s ease-out;
    animation-iteration-count: infinite;
    opacity: 0;
    box-shadow: 0 0 1px 2px var(--accent);
    animation-delay: 1.1s;
}

@keyframes pulsate {
    0% {
        transform: scale(0.1, 0.1);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(1.2, 1.2);
        opacity: 0;
    }
}

/* ===== Sidebar Close Button ===== */
.sidebar-close {
    display: none; /* hidden on desktop */
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
    background: rgba(241, 245, 249, 0.8);
    color: var(--text-main);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 51;
}

.sidebar-close:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 0.08);
}

/* ===== Sidebar Toggle Button ===== */
.sidebar-toggle {
    display: none; /* hidden on desktop */
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: 1px solid var(--panel-border);
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sidebar-toggle:active {
    transform: scale(0.92);
}

.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: var(--text-main);
    transition: all 0.35s ease;
}

.hamburger-icon {
    position: relative;
}

.hamburger-icon::before,
.hamburger-icon::after {
    content: '';
    position: absolute;
    left: 0;
}

.hamburger-icon::before {
    top: -7px;
}

.hamburger-icon::after {
    top: 7px;
}

/* X state when sidebar is open */
.sidebar-toggle.active .hamburger-icon {
    background: transparent;
}

.sidebar-toggle.active .hamburger-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.sidebar-toggle.active .hamburger-icon::after {
    top: 0;
    transform: rotate(-45deg);
}

/* ===== Sidebar Overlay (backdrop) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    z-index: 49;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar-close {
        display: flex;
    }

    .app-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 85%;
        max-width: 340px;
        height: 100vh;
        height: 100dvh;
        padding: 1.5rem;
        padding-top: 4.5rem; /* space for toggle button */
        gap: 1.5rem;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        overflow-y: auto;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.15);
    }

    .sidebar-overlay {
        display: block;
    }

    .header h1 {
        font-size: 1.4rem;
    }

    .header p {
        font-size: 0.8rem;
    }

    #searchInput {
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
        border-radius: 10px;
    }

    .search-results {
        max-height: 200px;
    }

    .floor-selector h3 {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
    }

    .floor-buttons {
        gap: 0.4rem;
    }

    .floor-btn {
        padding: 0.7rem 0;
        font-size: 1rem;
        border-radius: 8px;
    }

    .instructions {
        padding: 1rem;
    }

    .instructions p {
        font-size: 0.8rem;
    }

    /* Map area takes full screen on mobile */
    .map-area {
        width: 100%;
        height: 100vh;
        height: 100dvh;
    }

    .controls {
        bottom: 1.5rem;
        right: 1rem;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
}

@media (max-width: 400px) {
    .sidebar {
        width: 92%;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .floor-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}
