/* ==================== BUILDING VIEWER 3D ==================== */

#viewer-container {
    display: flex;
    height: calc(100vh - 180px);
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Left sidebar removed - zones moved to right sidebar */

#viewer-sidebar-right {
    width: 33.333%;
    min-width: 400px;
    background: #f8f9fa;
    padding: 15px 10px;
    overflow-y: auto;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.05);
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

#viewer-canvas {
    flex: 1;
    position: relative;
    background: #f5f5f5;
    transition: margin-right 0.3s ease;
}

#viewer-canvas.with-detail-panel {
    margin-right: 400px;
}

.viewer-title {
    color: #5994B8;
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

.file-upload {
    margin-bottom: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #5994B8 0%, #4a7ea0 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(89, 148, 184, 0.3);
}

.file-upload label {
    display: block;
    color: white;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
}

#viewer-file-input {
    width: 100%;
    padding: 10px;
    border: 2px dashed rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
}

#viewer-file-input:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
}

.format-info {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 12px;
    color: white;
}

.viewer-tabs {
    display: flex;
    gap: 0;
    background: #e0e0e0;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.viewer-tab {
    flex: 1;
    padding: 12px 8px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    color: #666;
    background: #f5f5f5;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.viewer-tab img {
    width: 20px;
    height: 20px;
    filter: brightness(0) saturate(100%) invert(45%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(90%);
    transition: filter 0.2s;
    pointer-events: none;
}

.viewer-tab:hover {
    background: #eeeeee;
    color: #5994B8;
}

.viewer-tab:hover img {
    filter: brightness(0) saturate(100%) invert(52%) sepia(78%) saturate(405%) hue-rotate(161deg) brightness(92%) contrast(86%);
}

.viewer-tab.active {
    background: white;
    color: #5994B8;
    border-bottom: 3px solid #5994B8;
}

.viewer-tab.active img {
    filter: brightness(0) saturate(100%) invert(52%) sepia(78%) saturate(405%) hue-rotate(161deg) brightness(92%) contrast(86%);
}

.viewer-filter-section {
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    overflow-x: visible;
    flex: 1;
}

.viewer-tab-content {
    display: none;
}

.viewer-tab-content.active {
    display: block;
}

.viewer-filter-title {
    font-size: 14px;
    font-weight: bold;
    color: #5994B8;
    padding: 12px 15px;
    background: #f5f5f5;
    border-bottom: 2px solid #5994B8;
}

.viewer-filter-collapsible {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.viewer-filter-collapsible:hover {
    background: #eeeeee;
}

.collapse-icon {
    font-size: 12px;
    transition: transform 0.2s;
}

.collapse-icon.collapsed {
    transform: rotate(-90deg);
}

.control-group {
    margin-bottom: 12px;
}

.control-group label {
    display: flex;
    align-items: center;
    color: #555;
    font-size: 13px;
    margin-bottom: 5px;
    font-weight: 500;
    cursor: pointer;
}

.control-group input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.control-group input[type="radio"] {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.control-group input[type="range"] {
    width: 100%;
    margin: 5px 0;
}

.slider-value {
    text-align: center;
    color: #5994B8;
    font-weight: 600;
    font-size: 12px;
    margin-top: 5px;
}

.surface-filters {
    background: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}

.surface-filters h3::before {
    content: '🏢';
}

.filter-checkbox {
    display: flex;
    align-items: center;
    padding: 6px 0;
}

.filter-checkbox label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex: 1;
}

.filter-checkbox input[type="checkbox"] {
    margin-right: 10px;
}

.filter-indicator {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-left: auto;
    margin-right: 5px;
}

#viewer-zone-legend-content,
#viewer-construction-legend-content,
#viewer-opening-legend-content {
    padding: 8px;
}

.zone-legend-title {
    font-size: 14px;
    font-weight: bold;
    color: #5994B8;
    padding: 12px 15px;
    background: #f5f5f5;
    border-bottom: 2px solid #5994B8;
}

.zone-legend-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #565654;
    transition: all 0.2s;
    border-radius: 5px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.zone-name-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.zone-name {
    flex: 1;
}

.zone-legend-item:hover {
    background: #e9ecef;
}

.zone-legend-item.selected {
    background: white;
    border-left: 3px solid #5994B8;
    padding-left: 9px;
    color: #5994B8;
    font-weight: bold;
}

.viewer-filter-item {
    padding: 12px;
    cursor: pointer;
    font-size: 14px;
    color: #565654;
    transition: all 0.2s;
    border-radius: 5px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-left: 3px solid transparent;
    position: relative;
}

.viewer-filter-item.has-icon {
    padding-left: 45px;
}

.viewer-filter-item:hover {
    background: #e9ecef;
}

.viewer-filter-item.selected {
    background: white;
    border-left: 3px solid #5994B8;
    color: #5994B8;
    font-weight: bold;
}

.viewer-filter-item.selected .filter-item-name,
.viewer-filter-item.selected .filter-item-info {
    font-weight: bold;
}

.viewer-filter-item.selected .filter-item-name {
    color: #5994B8;
    font-weight: bold;
}

.filter-item-name {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.construction-name-container {
    flex: 1;
}

.surface-type-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.filter-item-info {
    margin-left: 8px;
    font-size: 11px;
    color: #888;
    white-space: nowrap;
}

.filter-item-info::after {
    content: none;
}

.filter-item-info::before {
    content: none;
}

.zone-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.zone-name {
    color: #333;
    font-weight: 500;
    margin-bottom: 2px;
}

.zone-id {
    color: #666;
    font-size: 11px;
    font-style: italic;
}

.viewer-button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #5994B8 0%, #4a7ea0 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.viewer-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(89, 148, 184, 0.4);
}

.viewer-button:active {
    transform: translateY(0);
}

#viewer-stats {
    background: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}

#viewer-stats h3 {
    color: #333;
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#viewer-stats h3::before {
    content: '📊';
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

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

.stat-label {
    color: #666;
}

.stat-value {
    color: #5994B8;
    font-weight: 600;
}

#viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #5994B8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#viewer-loading p {
    color: #333;
    text-align: center;
    margin: 0;
}

#viewer-file-type {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    border-radius: 8px;
    color: #5994B8;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: none;
}

#viewer-axis-indicator {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    color: #333;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.axis-label {
    margin: 2px 0;
}

.axis-x { color: #ff0000; font-weight: bold; }
.axis-y { color: #00ff00; font-weight: bold; }
.axis-z { color: #0000ff; font-weight: bold; }

/* ==================== ZONE DETAIL PANEL ==================== */

#zone-detail-panel {
    position: absolute;
    top: 0;
    right: 33.333%;
    width: 0;
    height: 100%;
    background: white;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    transition: width 0.3s ease;
    z-index: 50;
    overflow: hidden;
    border-left: 1px solid #e0e0e0;
}

#zone-detail-panel.visible {
    width: 400px;
    overflow-y: auto;
}

.zone-detail-header {
    background: linear-gradient(135deg, #5994B8 0%, #4a7ea0 100%);
    color: white;
    padding: 20px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.zone-detail-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.zone-detail-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.zone-detail-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.zone-detail-subtitle {
    font-size: 14px;
    opacity: 0.9;
    display: flex;
    gap: 15px;
}

.zone-detail-id {
    font-weight: 500;
}

.zone-detail-usage {
    font-style: italic;
}

.zone-detail-content {
    padding: 20px;
}

.zone-detail-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #5994B8;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #5994B8;
}

.zone-spaces-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.zone-spaces-table thead {
    background: #f5f5f5;
}

.zone-spaces-table th {
    padding: 12px 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #5994B8;
}

.zone-spaces-table th:first-child {
    text-align: left;
}

.zone-spaces-table td {
    padding: 10px 8px;
    font-size: 13px;
    color: #555;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
}

.zone-spaces-table td:first-child {
    text-align: left;
}

.zone-spaces-table tbody tr:hover {
    background: #f9f9f9;
}

.zone-spaces-table tbody tr:last-child td {
    border-bottom: none;
}

/* Le panneau glisse depuis la droite et pousse la vue 3D vers la gauche */

/* ==================== SÉPARATEURS, ICÔNES ET SPARKLINES ==================== */

.construction-type-title {
    font-size: 12px;
    font-weight: 600;
    color: #5994B8;
    margin: 16px 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.construction-type-separator {
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0 8px 0;
    border: none;
}

.construction-type-icon-container {
    position: absolute;
    left: 12px;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    z-index: 10;
}

.construction-type-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

.construction-info-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.construction-sparkline-container {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.construction-sparkline {
    height: 4px;
    background: #4CAF50;
    border-radius: 2px;
    transition: width 0.3s ease;
    min-width: 1px;
    max-width: 60px;
}

.construction-deperditions {
    font-size: 11px;
    color: #4CAF50;
    font-weight: 600;
    white-space: nowrap;
}

/* ==================== POPUPS ==================== */

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.popup-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.popup-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.popup-close:hover {
    background: #e0e0e0;
}

.popup-body {
    padding: 20px;
    overflow-y: auto;
}

.popup-body .data-table {
    width: 100%;
    border-collapse: collapse;
}

.popup-body .data-table th {
    background: #f5f5f5;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #5994B8;
    font-size: 13px;
}

.popup-body .data-table th:first-child {
    text-align: left;
}

.popup-body .data-table td:first-child {
    text-align: left;
}

.popup-body .data-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
}

.popup-body .data-table tbody tr:hover {
    background: #f9f9f9;
}
