#map-container {
    touch-action: none;
    overflow: hidden;
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: auto;
}

#floorplan {
    width: 100%;
    display: block;
}

.room {
    position: absolute;
    background: rgba(0, 0, 0, 0);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: background 0.2s ease;
}

.teacher-mode .maintenance-only {
    display: none;
}

.maintenance-mode .teacher-only {
    display: none;
}

.room[data-room="Library"] {
    border: none;
}

.room:hover {
    background: rgba(0, 0, 0, 0.3);
}

.room.hovered {
    background: rgba(0, 0, 0, 0.3);
}

.room-badge { 
    position: absolute; 
    top: 1px; 
    right: 1px; 
    background: red; 
    color: white; 
    font-size: 11px; 
    font-weight: bold; 
    width: 18px; 
    height: 18px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    pointer-events: none; 
    opacity: 0; /* hidden when empty */ 
    transition: opacity 0.2s; 
}

#mobile-warning {
    display: none;
    background: #ffcc00;
    color: #333;
    padding: 8px;
    font-size: 13px;
    text-align: center;
    border-bottom: 1px solid #aaa;
}

#room-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 350px;
    height: 550px;
    background: white;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 0 20px rgba(0,0,0,0.4);
    display: none;
    z-index: 1001;
    overflow: hidden;
    min-width: 250px;
    min-height: 150px;
    resize: both;
    touch-action: none;
}

#popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    backdrop-filter: blur(6px);
    background: rgba(0, 0, 0, 0.25); /* subtle dimming */
    display: none;
    z-index: 1000; /* behind popup, above map */
}

#room-popup-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    height: 100%;
    box-sizing: border-box;
    overflow: visible;
    touch-action: pan-y;
}

#room-popup-body label {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    gap: 4px;
}

#room-popup-body input,
#room-popup-body select,
#room-popup-body textarea {
    font-family: Arial, Helvetica, sans-serif;
    padding: 6px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

#room-popup-notes {
    flex: 1;
    min-height: 80px;
    resize: none;
}

#sort-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 5px;
}

#sort-buttons button {
    flex: 1;
    padding: 6px;
    font-size: 12px;
    cursor: pointer;
}

#workorder-list {
    flex: 1;
    overflow-y: auto;
    max-height: 40vh;
    min-height: 100px;
    padding: 10px;
    padding-bottom: 50px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.workorder-box {
    font-family: Arial, Helvetica, sans-serif;
    padding: 10px;
    border-radius: 6px;
    color: #222;
    cursor: default;
    user-select: none;
    position: relative;
}

.workorder-box .main-click-area { 
    cursor: pointer;
}

.workorder-details {
    margin-top: 6px;
    padding-left: 10px;
    display: none;
    font-size: 14px;
    color: #333;
    border-left: 2px solid #aaa;
}

.delete-order {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 14px;
    font-weight: bold;
    color: #900;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.delete-order:hover {
    opacity: 1;
}

.add-note-btn {
    position: absolute;
    top: 4px;
    right: 28px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.7;
}

.add-note-btn:hover {
    opacity: 1;
}

#popup-resizer { 
    width: 15px; 
    height: 15px; 
    position: absolute; 
    right: 0; 
    bottom: 0; 
    cursor: se-resize; 
    background: transparent;
}

#room-popup-header {
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #444;
    color: white;
    padding: 10px;
    border-radius: 8px 8px 0 0;
    touch-action: none;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
}

#room-popup-header:active { 
    cursor: grabbing; 
}

#room-popup-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
}

#room-popup-form {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
}

#room-popup-form label:nth-of-type(2),
#room-popup-form label:nth-of-type(3),
#room-popup-form label:nth-of-type(4) {
    margin-top: 5px;
}

#room-popup-notes {
    width: calc(100% - 20px);
    margin: 0 10px 10px 10px;
    height: 150px;
    border: none;
    padding: 10px;
    resize: none;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

#popup {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 20px;
    border: 2px solid black;
    display: none;
}

#draw-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#selection-box {
    position: absolute;
    border: 2px dashed red;
    background: rgba(255, 0, 0, 0.2);
    pointer-events: none;
}

@media (max-width: 600px) {
    #room-popup {
        width: 90vw;
        height: auto;
        max-height: 80vh;
        max-width: none;
        resize: none; /* optional: resizing on mobile is awkward */
    }

    #mobile-warning {
        display: block;
    }

    #room-popup-header {
        touch-action: auto; /* allow normal scrolling */
        cursor: default;    /* no drag cursor */
    }

    #workorder-list {
        padding-bottom: 60px;
        overscroll-behavior: contain;
        max-height: calc(80vh - 200px);
    }
}