/* css/mapa.css */

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Prevent scrolling of the whole page, handled by Panzoom */
    font-family: verdana, sans-serif;
    background-color: #f0f0f0;
}

#map-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: grab;
    background-color: #e8e8e8; /* Default background for missing map areas */
}

#map-wrapper:active {
    cursor: grabbing;
}

#map-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

#map-container svg {
    max-width: none;
    /* Maintain A4 aspect ratio, wait, SVG viewbox handles this. Let's ensure it scales well */
}

#map-loading, #map-error {
    font-size: 24px;
    font-weight: bold;
    color: #555;
    background: rgba(255, 255, 255, 0.8);
    padding: 20px 40px;
    border-radius: 8px;
    border: 2px solid #ccc;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to map */
    z-index: 10;
}

.panel {
    pointer-events: auto; /* Re-enable clicks on panels */
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #ccc;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
    border-radius: 6px;
    padding: 15px;
    position: absolute;
}

.panel h2, .panel h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.panel-top-left {
    top: 20px;
    left: 20px;
}

.panel-top-right {
    top: 20px;
    right: 20px;
    width: 250px;
    max-height: 50vh;
    display: flex;
    flex-direction: column;
}

.panel-bottom-center {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    text-align: center;
}

/* Floor selector buttons */
.floor-selector {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.floor-btn {
    padding: 8px 12px;
    border: 1px solid #aaa;
    background: #f9f9f9;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    text-align: left;
}

.floor-btn:hover {
    background: #e0e0e0;
}

.floor-btn.active {
    background: #bddfd0; /* Classic theme color */
    border-color: #8bb7a2;
}

#current-floor-indicator {
    margin-top: 10px;
    font-weight: bold;
    font-size: 12px;
    color: #666;
}

/* Room search list */
#search-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#room-search {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
}

#room-list {
    overflow-y: auto;
    flex: 1;
    border: 1px solid #eee;
    min-height: 0;
}

.room-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}

.room-item:hover {
    background: #e9e9e9;
}

/* Info Panel */
.close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #888;
}
.close-btn:hover {
    color: #f00;
}

#info-timetable {
    margin-top: 10px;
    font-size: 14px;
    text-align: left;
}
#info-actions {
    margin-top: 15px;
}
.btn-link {
    display: inline-block;
    padding: 5px 10px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    text-decoration: none;
    color: #000;
    font-weight: bold;
}
.btn-link:hover {
    background: #e0e0e0;
}

/* Ensure all interactive polygons are transparent even if hidden from mapData */
.interactive-layer path, .interactive-layer polygon, .interactive-layer rect, .interactive-layer circle {
    fill: transparent !important;
    stroke: none !important;
}

/* Interactive SVG Styling */
.svg-room {
    fill: transparent !important;
    stroke: none !important;
    cursor: pointer;
}

.interactive-layer.ready .svg-room {
    transition: fill 0.2s;
}

.svg-room:hover {
    fill: rgba(0, 150, 255, 0.4) !important;
}

.svg-room.active {
    fill: rgba(255, 165, 0, 0.6) !important;
    stroke: #ff8c00 !important;
    stroke-width: 2px !important;
}

/* Room text overlay inside SVG */
.svg-room-text {
    pointer-events: none;
    font-family: 'Verdana', sans-serif;
    font-weight: bold;
    fill: #333;
    text-anchor: middle;
    dominant-baseline: central;
    stroke: white;
    stroke-width: 1px;
    paint-order: stroke;
}

.svg-room-text.short {
    font-size: 11px;
}

.svg-room-text.detail {
    font-size: 8px;
    fill: #0044aa; /* Dark blue for timetable details */
}

/* Responsive */
@media (max-width: 768px) {
    #search-toggle {
        display: block !important;
        padding: 12px;
        font-size: 16px;
    }
    #search-content {
        display: none;
    }
    #search-content.open {
        display: flex;
        flex-direction: column;
        height: 25vh;
        margin-top: 10px;
    }
    .panel-top-right {
        top: auto;
        bottom: 20px;
        right: 20px;
        left: 20px;
        width: auto;
        max-height: 40vh;
    }
    .panel-bottom-center {
        bottom: 20px;
        top: auto;
        left: 20px;
        right: 20px;
        width: auto;
        z-index: 20;
        transform: none;
    }
    .panel-top-left {
        display: flex;
        flex-direction: row;
        gap: 10px;
        align-items: center;
    }
    .panel-top-left h2 { margin: 0; font-size: 18px; }
    .floor-selector { flex-direction: row; flex-wrap: wrap; }
    .floor-btn { padding: 10px 14px; font-size: 16px; }
    .room-item { font-size: 15px; padding: 10px; }
    #info-timetable { font-size: 15px; }
    .btn-link { font-size: 15px; padding: 8px 12px; }
}
