/* ============================================================
   PODSTAWY I ZMIENNE
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    margin: 10px;
    background: #fff;
    color: #000000;
    --map-blue: #BCD0ED;
    --map-yellow: #FFE166;
    --map-red: #EB5D48;
    --map-orange: #F5A04C;
    --map-green: #91C681;
    --map-black: #000000;
    --map-disabled: #ccc;
    --map-background: #e6e5e5;
}

h1 { font-size:1.3em; font-weight: bold;}


#map-app {
    width: 100%;
}

/* ============================================================
   GÓRNE STEROWANIE
   ============================================================ */

#top-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 960px;
    margin: 0 auto 15px;
}

#location-select-wrapper,
#map-search {
    width: 360px;
    max-width: 100%;
}

#location-select {
    width: 100%;
    min-height: 38px;
    font-weight: 500;
    cursor: pointer;
}

#location-select optgroup {
    font-weight: 700;
}

#location-select option {
    font-weight: 400;
}

.location-or {
    flex: 0 0 auto;
    color: var(--map-black);
    font-weight: 600;
    white-space: nowrap;
}

#map-search {
    position: relative;
}

#map-search-select {
    width: 100%;
    min-height: 38px;
    text-align: left;
}

/* ============================================================
   GŁÓWNY OBSZAR MAPY
   ============================================================ */

#map-stage {
    display: flex;
    align-items: center;
    width: 100%;
}

#svg-stack {
    position: relative;
    width: 100%;
    height: calc(100vh - 100px);
    max-height: 800px;
    min-height: 300px;
    margin: 0;
    overflow: hidden;
}

/* ============================================================
   POSZCZEGÓLNE PIĘTRA
   ============================================================ */

.floor {
    position: absolute;
    inset: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(40px);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.45s ease;
    pointer-events: none;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.floor.active {
    z-index: 2;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.floor.exit-down {
    transform: translateY(40px);
    opacity: 0;
}

.floor.exit-up {
    transform: translateY(-40px);
    opacity: 0;
}

/* ============================================================
   SVG - MAPA
   ============================================================ */

.floor svg {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 100%;
    flex-shrink: 1;
    background-color: var(--map-background);
}

/* ============================================================
   POPOVER INFORMACYJNY
   ============================================================ */

.map-room-popover {
    --bs-popover-max-width: 400px;
    --bs-popover-border-color: var(--map-black);
    --bs-popover-bg: #fff;
    --bs-popover-body-color: var(--map-black);
    pointer-events: auto;
}

.map-room-popover .popover-body {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.45;
}

.map-room-popover .popover-body ul {
    padding-left: 20px;
    margin-bottom: 10px;
}

.map-room-popover .popover-body p:last-child {
    margin-bottom: 0;
}

/* ============================================================
   KOLORY W PLIKACH SVG
   ============================================================ */

#pomieszczenia g {
    fill: var(--map-blue) !important;
}

#pomieszczenia g:hover,
#pomieszczenia g:focus,
#pomieszczenia g.room-hover-state {
    fill: var(--map-orange) !important;
    cursor: pointer !important;
    outline: none;
}   

#pomieszczenia g.niedostepne,
#pomieszczenia g.niedostepne:hover {
    fill: var(--map-disabled) !important;
    cursor: default !important;
}

#pomieszczenia .wc,
#pomieszczenia .wc:hover {
    fill: var(--map-yellow) !important;
    cursor: default !important;
}

#pomieszczenia .winda,
#pomieszczenia .winda:hover {
    fill: var(--map-green) !important;
    cursor: default !important;
    font-size: 14px !important;
}

text {
    font-size: 1.5em !important;
    font-family: Arial, sans-serif !important;
    text-anchor: middle !important;
    fill: var(--map-black) !important;
}

#ulice { opacity: 0.5; }

#ulice text {
    font-size: 3em !important;
    fill: #fff !important;
}

#ulice .pasy { fill: #FFFFFF; }

#korytarze path { fill: #fff !important; }

/* ============================================================
   EFEKT ZAZNACZONEGO POKOJU
   ============================================================ */

.room-url-highlight path,
.room-url-highlight rect,
.room-url-highlight polygon {
    stroke: var(--map-orange) !important;
    stroke-width: 12px !important;
    animation: room-highlight-pulse 1.8s ease-in-out infinite;
}

@keyframes room-highlight-pulse {
    0%, 100% {
        fill: var(--map-orange);
        stroke: var(--map-orange);
        stroke-width: 10px;
    }
    50% {
        fill: color-mix(in srgb, var(--map-orange) 35%, transparent);
        stroke: var(--map-orange);
        stroke-width: 6px;
    }
}

/* ============================================================
   WYSZUKIWANIE WYDZIAŁU / PRACOWNIKA
   ============================================================ */

.map-search-dropdown {
    width: 100%;
    min-width: 320px;
    max-width: 100%;
    padding: 0;
}

.map-search-input {
    padding: 10px;
}

.map-search-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
}

.map-search-list li a {
    display: block;
    padding: 8px 12px;
    color: var(--bs-body-color);
    text-decoration: none;
}

.map-search-list li a:hover,
.map-search-list li a:focus {
    background: var(--bs-tertiary-bg);
}

.map-search-list .map-search-heading {
    padding: 10px;
    border-top: 1px solid var(--bs-border-color);
    border-bottom: 1px solid var(--bs-border-color);
    color: var(--map-black);
    font-weight: 700;
    text-transform: uppercase;
}

.map-search-list .map-search-heading:first-child {
    border-top: 0;
}

.map-search-list .map-search-result small {
    display: block;
    margin-top: 2px;
    color: var(--map-black);
}

.map-search-list .map-search-empty {
    padding: 12px;
    color: var(--map-black);
}

/* ============================================================
   PALETA APLIKACJI
   ============================================================ */

:root {
    --bs-primary: #BCD0ED;
    --bs-primary-rgb: 188, 208, 237;
    --bs-warning: #FFE166;
    --bs-warning-rgb: 255, 225, 102;
    --bs-danger: #EB5D48;
    --bs-danger-rgb: 235, 93, 72;
    --bs-success: #91C681;
    --bs-success-rgb: 145, 198, 129;
    --bs-body-color: #000000;
    --bs-link-color: #000000;
    --bs-link-hover-color: #000000;
}

#location-select:focus,
#map-search-select:focus,
.map-search-input:focus {
    border-color: var(--map-blue);
}

#map-search-select:hover {
    background-color: var(--map-blue);
    border-color: var(--map-blue);
    color: var(--map-black);
}

/* ============================================================
   RESPONSYWNOŚĆ
   ============================================================ */

@media (max-width: 700px) {
    body {
        margin: 5px;
    }

    #top-controls {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
        padding: 0 5px;
    }

    #location-select-wrapper,
    #map-search {
        width: 100%;
    }

    .location-or {
        text-align: center;
    }

    #svg-stack {
        height: calc(100vh - 145px);
        min-height: 250px;
    }

    .floor {
        inset: 5px;
    }
}

@media (max-width: 500px) {
    #svg-stack {
        height: calc(100vh - 155px);
        min-height: 200px;
    }

    .floor {
        inset: 3px;
    }

    .map-search-dropdown {
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .floor,
    .room-url-highlight path,
    .room-url-highlight rect,
    .room-url-highlight polygon {
        transition: none !important;
        animation: none !important;
    }
}