/* ==========================================================================
   Building Viewer - Unified Tabbed Interface
   ========================================================================== */

:root {
    /* Building Viewer Variables */
    --building-viewer-height: 700px;
    --building-viewer-tab-bottom: 20px;
    --building-viewer-tab-padding: 12px 16px;
    --building-viewer-tab-gap: 12px;
    --building-viewer-tab-bg: rgba(255, 255, 255, 0.95);
    --building-viewer-tab-radius: 12px;
    --building-viewer-floorplan-padding: 120px;
    --building-viewer-primary-color: #353535;
    
    /* Floor Map Overlay Colors */
    --floor-map-office-fill: #BA0018;
    --floor-map-office-opacity: 0.8;
    --floor-map-vaikuseboks-fill: #684E72;
    --floor-map-vaikuseboks-opacity: 0.8;
    --floor-map-meeting-room-fill: #684E72;
    --floor-map-meeting-room-opacity: 0.8;
}

.building-viewer {
    width: 100%;
    background: #fff;
    /* border-radius: 8px; */
    overflow: hidden;
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
    position: relative;
}

/* ==========================================================================
   Tab Navigation (Bottom Overlay)
   ========================================================================== */

.building-viewer__tabs {
    position: absolute;
    bottom: var(--building-viewer-tab-bottom);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--building-viewer-tab-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--building-viewer-tab-radius);
    padding: var(--building-viewer-tab-padding);
    margin: 0;
    gap: var(--building-viewer-tab-gap);
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.building-viewer__tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: #fff;
    border: 2px solid #d0d0d0;
    border-radius: 8px;
    color: #666;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-width: auto;
}

.building-viewer__tab svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.building-viewer__tab:hover,
.building-viewer__tab:focus {
    background: rgba(101, 80, 112, 0.08);
    border-color: var(--building-viewer-primary-color);
    color: var(--building-viewer-primary-color);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(101, 80, 112, 0.15);
    outline: none;
}

.building-viewer__tab--active,
.building-viewer__tab--active:focus {
    background: var(--building-viewer-primary-color);
    color: #fff;
    border-color: var(--building-viewer-primary-color);
    box-shadow: 0 2px 8px rgba(101, 80, 112, 0.2);
    outline: none;
}

.building-viewer__tab--active:hover,
.building-viewer__tab--active:focus:hover {
    background: var(--building-viewer-primary-color);
    color: #fff;
    transform: translateY(-2px);
}

.building-viewer__tab--active svg {
    stroke: #fff;
}

/* ==========================================================================
   Tab Content
   ========================================================================== */

.building-viewer__content {
    position: relative;
    width: 100%;
    height: var(--building-viewer-height);
    overflow: hidden;
}

.building-viewer__panel {
    display: none;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.building-viewer__panel--active {
    display: block;
    opacity: 1;
}

/* ==========================================================================
   Nested Components Adjustments
   ========================================================================== */

/* Remove extra margins from nested shortcodes */
.building-viewer__panel .building-map,
.building-viewer__panel .panorama-viewer-wrapper {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Add bottom padding to floor map and facade to prevent tab overlap */
.building-viewer__panel[data-panel="floorplan"] .building-map,
.building-viewer__panel[data-panel="fassad"] .building-map {
    padding-bottom: var(--building-viewer-floorplan-padding);
}

/* Ensure floor map controls are visible */
.building-viewer__panel .building-map__controls {
    background: #fff;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    :root {
        --building-viewer-floorplan-padding: 100px;
    }
    
    .building-viewer__tab {
        padding: 12px 16px;
        font-size: 14px;
        flex-direction: column;
        gap: 4px;
    }
    
    .building-viewer__tab svg {
        width: 18px;
        height: 18px;
    }
    
    .building-viewer__tab span {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    :root {
        --building-viewer-floorplan-padding: 80px;
    }
    
    .building-viewer__tab {
        padding: 10px 8px;
    }
    
    .building-viewer__tab span {
        display: none;
    }
    
    .building-viewer__tab svg {
        width: 24px;
        height: 24px;
    }
}

/* ==========================================================================
   Animation
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.building-viewer__panel--active {
    animation: fadeIn 0.3s ease;
}


/**
 * Interactive Building Map Styles
 * Using BEM naming convention
 */

/* ==========================================================================
   Building Map Container
   ========================================================================== */

.building-map {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    display: flex;
    gap: 0;
    background: #fff;
}

/* ==========================================================================
   Controls
   ========================================================================== */

.building-map__controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;        
    flex-shrink: 0;    
}

/* Floor Label */
.building-map__floor-label {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 12px;
    color: #999;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Floor Selector */
.building-map__floor-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.building-map__floor-btn {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #999;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    outline: none;
}

.building-map__floor-btn:hover {
    background: rgba(101, 80, 112, 0.1);
    color: #666;
}

.building-map__floor-btn:focus {
    outline: none;
}

.building-map__floor-btn--active, .building-map__floor-btn--active:hover {    
    background: var(--building-viewer-primary-color);
    color: #fff;
} 

.building-map__floor-btn--disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    background: #f5f5f5;
    color: #999;
}

.building-map__floor-btn--disabled:hover {
    cursor: not-allowed !important;
    background: #f5f5f5;
    color: #999;
}

/* ==========================================================================
   Map Container
   ========================================================================== */

.building-map__container {
    position: relative;
    background: #fff;
    height: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Floor */
.building-map__floor {
    display: none;
    width: 100%;
    height: 100%;
    padding: 20px;
    position: absolute;
    top: 0;
    left: 0;
}

.building-map__floor--active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

/* Floor Wrapper - Contains base layer and overlay layer */
.building-map__floor-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Base Layer - The actual floor plan SVG */
.building-map__base-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.building-map__base-layer .building-map__svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
}

/* Overlay Layer - Office overlays on top of floor plan */
.building-map__overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}

.building-map__overlay-layer svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
}

.building-map__overlay-layer .building-map__office {
    pointer-events: auto;
}

/* SVG */
.building-map__svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.building-map__background {
    transition: fill 0.3s ease;
}

/* ==========================================================================
   Offices
   ========================================================================== */

.building-map__office {
    cursor: pointer;
    transition: all 0.3s ease;
}

.building-map__office-rect {
    transition: all 0.3s ease;
}

/* Office Type Colors */
.building-map__office-rect--office {
    fill: var(--floor-map-office-fill);
    fill-opacity: var(--floor-map-office-opacity);
}

.building-map__office-rect--vaikuseboks {
    fill: var(--floor-map-vaikuseboks-fill);
    fill-opacity: var(--floor-map-vaikuseboks-opacity);
}

.building-map__office-rect--meeting-room {
    fill: var(--floor-map-meeting-room-fill);
    fill-opacity: var(--floor-map-meeting-room-opacity);
}

/* Legacy status classes */
.building-map__office-rect--available {
    fill: #4caf50;
}

.building-map__office-rect--occupied {
    fill: #f44336;
}

.building-map__office-rect--conference {
    fill: #2196f3;
}

/* Office Overlay */
.building-map__office-overlay {
    transition: all 0.3s ease;
}

.building-map__office:hover .building-map__office-overlay {
    /* fill: rgba(255, 255, 255, 0.3); */
    /* stroke: #ffd700; */
    /* stroke-width: 4; */
}

.building-map__office--hover .building-map__office-rect {
    filter: brightness(1.2);    
    /* stroke-width: 3; */
}

.building-map__office--active .building-map__office-overlay {
    /* fill: rgba(255, 215, 0, 0.2); */
    /* stroke: #ffd700; */
    /* stroke-width: 4; */
}

.building-map__office--active .building-map__office-rect {
    filter: brightness(1.1);
}

/* Office Label */
.building-map__office-label {
    font-family: inherit;
    font-weight: 500;
    pointer-events: none;
    user-select: none;
}

/* ==========================================================================
   Tooltip
   ========================================================================== */

.building-map__tooltip {
    position: absolute;
    z-index: 1000;
    pointer-events: none;
    transform: translateX(-50%);
}

.building-map__tooltip-content {
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    max-width: 300px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.building-map__tooltip-content::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0, 0, 0, 0.9);
}

.building-map__tooltip-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.building-map__tooltip-info {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #ddd;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: normal;
}

.building-map__tooltip-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.building-map__tooltip-status--available {
    background: #4caf50;
    color: #fff;
}

.building-map__tooltip-status--occupied {
    background: #f44336;
    color: #fff;
}

.building-map__tooltip-status--conference {
    background: #2196f3;
    color: #fff;
}

/* ==========================================================================
   Demo Office Links
   ========================================================================== */

.building-map__demo-links {
    margin-top: 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.building-map__demo-title {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #555;
}

.building-map__demo-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: #ddd #f5f5f5;
}

.building-map__demo-list::-webkit-scrollbar {
    height: 8px;
}

.building-map__demo-list::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.building-map__demo-list::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

.building-map__demo-list::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

.building-map__demo-link {
    display: inline-block;
    padding: 6px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    font-size: 13px;
    transition: all 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}

.building-map__demo-link:hover {
    background: #ffd700;
    border-color: #ffd700;
    color: #000;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.building-map__demo-link--active {
    background: #ffd700;
    border-color: #ffd700;
    color: #000;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

/* ==========================================================================
   External Office Cards (Production)
   ========================================================================== */

/* Active state when hovering over office card */
.office-card-active {
    box-shadow: 0 4px 16px rgba(34, 113, 177, 0.3) !important;
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

/* Selected state when clicking office card */
.office-card-selected {
    border: 2px solid #2271b1 !important;
    box-shadow: 0 4px 16px rgba(34, 113, 177, 0.4) !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
    .building-map {
        flex-direction: column;
    }
    
    .building-map__main-card {
        flex-direction: column;
    }
    
    .building-map__controls {
        width: 100%;
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding: 15px 20px;
    }
    
    .building-map__floor-label {
        display: none;
    }
    
    .building-map__floor-selector {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .building-map__container {
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .building-map__floor {
        padding: 10px;
    }
    
    .building-map__floor-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .building-map__tooltip-content {
        font-size: 12px;
        padding: 10px 12px;
        min-width: 150px;
    }
    
    .building-map__tooltip-title {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .building-map__controls {
        padding: 10px;
    }
    
    .building-map__floor-btn {
        width: 45px;
        height: 45px;
        font-size: 13px;
    }
    .building-map__demo-links {
        padding: 10px;
        margin-top: 15px;
    }
    
    .building-map__demo-title {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .building-map__demo-list {
        gap: 6px;
    }
    
    .building-map__demo-link {
        font-size: 11px;
        padding: 4px 8px;
    }
}

/**
 * Panorama Viewer Styles
 * 
 * @package Interactive_Building_Map
 * @since 1.0.0
 */

/* ==========================================================================
   Panorama Viewer Wrapper
   ========================================================================== */

.panorama-viewer-wrapper {
    position: relative;
    margin: 2rem 0;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   Header
   ========================================================================== */

.panorama-viewer-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #655070 0%, #4a3a54 100%);
    color: #fff;
}

.panorama-viewer-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
}

.panorama-viewer-description {
    margin: 0;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
}

/* ==========================================================================
   Viewer Container
   ========================================================================== */

.panorama-viewer {
    position: relative;
    background: #000;
    cursor: grab;
}

.panorama-viewer:active {
    cursor: grabbing;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.panorama-viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    z-index: 10;
    pointer-events: none;
}

.panorama-viewer-wrapper.loaded .panorama-viewer-loading {
    display: none;
}

.panorama-viewer-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: panorama-spin 1s linear infinite;
}

@keyframes panorama-spin {
    to {
        transform: rotate(360deg);
    }
}

.panorama-viewer-loading p {
    margin: 0;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

/* ==========================================================================
   Error State
   ========================================================================== */

.panorama-viewer-error {
    padding: 2rem;
    background: #fee;
    border: 2px solid #fcc;
    border-radius: 8px;
    color: #c33;
    text-align: center;
    font-weight: 500;
}

/* ==========================================================================
   Photo Sphere Viewer Customization
   ========================================================================== */

/* Hide navbar by default (controlled via JS config) */
.psv-navbar {
    background: rgba(0, 0, 0, 0.8) !important;
}

/* Customize buttons */
.psv-button {
    color: #fff !important;
}

.psv-button:hover {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* Customize loader */
.psv-loader-container {
    background: rgba(0, 0, 0, 0.9) !important;
}

.psv-loader {
    border-color: rgba(255, 255, 255, 0.2) !important;
    border-top-color: #fff !important;
}

/* ==========================================================================
   Panorama Markers
   ========================================================================== */

.panorama-marker {
    padding: 8px 16px;
    background: rgba(255, 0, 0, 0.8);
    color: #fff;
    border-radius: 20px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.panorama-marker:hover {
    background: rgba(255, 0, 0, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.panorama-marker--meeting {
    background: rgba(101, 80, 112, 0.8);
}

.panorama-marker--meeting:hover {
    background: rgba(101, 80, 112, 1);
}

/* Polygon markers */
.psv-marker--polygon {
    cursor: pointer;
    transition: all 0.3s ease;
}

.psv-marker--polygon:hover polygon,
.psv-marker--polygon:hover path {
    fill-opacity: 0.6 !important;
    stroke-width: 3px !important;
}

/* Marker tooltips */
.psv-marker-tooltip {
    background: rgba(0, 0, 0, 0.9) !important;
    color: #fff !important;
    padding: 10px 15px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5) !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .panorama-viewer-wrapper {
        margin: 1rem 0;
        border-radius: 0;
    }
    
    .panorama-viewer-header {
        padding: 1rem;
    }
    
    .panorama-viewer-title {
        font-size: 1.25rem;
    }
    
    .panorama-viewer-description {
        font-size: 0.875rem;
    }
}
