* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    background: #1a1a1a;
    color: #e0e0e0;
}

/* Toolbar */
#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: 50px;
    background: #2a2a2a;
    border-bottom: 2px solid #3a3a3a;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 12px;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
    overflow-x: auto;
    overflow-y: hidden;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.toolbar-grow {
    flex-grow: 1;
    justify-content: flex-start;
}

.toolbar-btn {
    background: #4a90e2;
    border: none;
    color: white;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    min-width: 44px;
    height: 40px;
    white-space: nowrap;
}

.toolbar-btn span {
    font-size: 18px;
}

.toolbar-btn-secondary {
    background: #3a3a3a;
    padding: 10px 14px;
}

.toolbar-btn-secondary:hover {
    background: #4a4a4a;
}

.toolbar-btn:hover {
    background: #357abd;
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0) scale(0.98);
}

.toolbar-btn.toggle-btn.active {
    background: #357abd;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toolbar-separator {
    width: 1px;
    height: 30px;
    background: #3a3a3a;
    flex-shrink: 0;
}

.toolbar-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1a1a1a;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #3a3a3a;
    transition: border-color 0.2s;
}

.toolbar-input-group:focus-within {
    border-color: #4a90e2;
}

.input-label {
    font-size: 12px;
    color: #b0b0b0;
    font-weight: 500;
    white-space: nowrap;
}

.toolbar-input-group input[type="number"] {
    width: 70px;
    padding: 4px 6px;
    background: transparent;
    border: none;
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 500;
}

.toolbar-input-group input[type="number"]:focus {
    outline: none;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.2s;
    white-space: nowrap;
}

.checkbox-label:hover {
    background: #3a3a3a;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #4a90e2;
    flex-shrink: 0;
}

.checkbox-text {
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 500;
}

.unit {
    color: #808080;
    font-size: 12px;
}

/* Responsive toolbar adjustments */
@media (max-width: 1200px) {
    #toolbar {
        padding: 6px 12px;
        gap: 8px;
    }
    
    .toolbar-btn {
        padding: 8px 12px;
        min-width: 40px;
        height: 36px;
    }
    
    .checkbox-text {
        display: none;
    }
}

@media (max-width: 900px) {
    .toolbar-separator {
        display: none;
    }
    
    .toolbar-input-group {
        padding: 4px 8px;
    }
    
    .toolbar-input-group input[type="number"] {
        width: 60px;
    }
}

/* Main Container */
#mainContainer {
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 200px;
    display: flex;
}

/* Canvas */
#canvas3d {
    flex: 1;
    display: block;
    cursor: grab;
    outline: none;
}

#canvas3d:active {
    cursor: grabbing;
}

/* Sidebar */
#sidebar {
    width: 320px;
    background: #2a2a2a;
    border-left: 2px solid #3a3a3a;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
}

.sidebar-header {
    padding: 20px;
    background: #252525;
    border-bottom: 1px solid #3a3a3a;
}

.selection-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    background: #1a1a1a;
    padding: 4px;
    border-radius: 6px;
}

.toggle-option {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #808080;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.toggle-option:hover {
    color: #b0b0b0;
    background: #2a2a2a;
}

.toggle-option.active {
    background: #4a90e2;
    color: white;
}

.sidebar-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 10px;
}

.sidebar-dropdown {
    width: 100%;
    padding: 10px 12px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.sidebar-dropdown:hover {
    border-color: #4a90e2;
    background: #252525;
}

.sidebar-dropdown:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.sidebar-dropdown option {
    background: #1a1a1a;
    color: #e0e0e0;
}

.properties-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.no-selection {
    color: #808080;
    font-size: 14px;
    text-align: center;
    margin-top: 40px;
}

/* Property Group */
.property-group {
    margin-bottom: 20px;
}

.property-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #b0b0b0;
    margin-bottom: 6px;
}

.property-input, select.property-input {
    width: 100%;
    padding: 10px 12px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 14px;
}

.property-input:focus, select.property-input:focus {
    outline: none;
    border-color: #4a90e2;
}

select.property-input {
    cursor: pointer;
}

.property-row {
    display: flex;
    gap: 10px;
}

.property-row .property-group {
    flex: 1;
}

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

.name-edit-container .property-input {
    flex: 1;
}

.edit-name-btn {
    background: #4a90e2;
    border: none;
    color: white;
    padding: 10px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.edit-name-btn:hover {
    background: #357abd;
}

.edit-name-btn:active {
    transform: scale(0.95);
}

.button-row {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.duplicate-btn {
    background: #4a90e2;
    color: white;
}

.duplicate-btn:hover {
    background: #357abd;
}

.delete-btn {
    background: #e74c3c;
    color: white;
}

.delete-btn:hover {
    background: #c0392b;
}

.action-btn:active {
    transform: scale(0.98);
}

.object-type-badge {
    display: inline-block;
    padding: 6px 12px;
    background: #3a3a3a;
    border-radius: 4px;
    font-size: 12px;
    color: #ff9500;
    font-weight: 600;
    margin-top: 8px;
}

.visibility-info {
    padding: 12px;
    background: #1a1a1a;
    border-left: 3px solid #ff9500;
    border-radius: 4px;
    font-size: 13px;
    color: #e0e0e0;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #4a90e2;
    margin: 20px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #3a3a3a;
}

.section-title:first-child {
    margin-top: 0;
}

/* Camera Name Display */
.camera-name {
    font-size: 16px;
    font-weight: 600;
    color: #4a90e2;
    margin-bottom: 20px;
    padding: 12px;
    background: #1a1a1a;
    border-radius: 4px;
    border-left: 3px solid #4a90e2;
}

/* Scrollbar styling */
.properties-content::-webkit-scrollbar {
    width: 8px;
}

.properties-content::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.properties-content::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

.properties-content::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* Plot Resize Handle */
#plotResizeHandle {
    position: fixed;
    bottom: 200px; /* Same as plot container height */
    left: 0;
    right: 0;
    height: 5px;
    background: #3a3a3a;
    cursor: ns-resize;
    z-index: 51;
    transition: background 0.2s;
}

#plotResizeHandle:hover {
    background: #4a90e2;
}

/* Plot Container */
#plotContainer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: #2a2a2a;
    border-top: 2px solid #3a3a3a;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    z-index: 50;
}

.plot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: #252525;
    border-bottom: 1px solid #3a3a3a;
}

.plot-title-section {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.plot-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.plot-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
    margin: 0;
}

.plot-select {
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    min-width: 200px;
}

.plot-select:focus {
    outline: none;
    border-color: #4a90e2;
}

.plot-select option {
    background: #1a1a1a;
    color: #e0e0e0;
}

.plot-btn {
    background: #3a3a3a;
    border: none;
    color: #e0e0e0;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.plot-btn:hover {
    background: #4a4a4a;
}

.plot-btn:active {
    transform: scale(0.98);
}

#visibilityChart {
    flex: 1;
    padding: 10px 10px 20px 10px; /* Extra bottom padding for x-axis labels */
    min-height: 0; /* Allow flex shrinking */
}

/* Heatmap Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 30px;
    width: 500px;
    max-width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    color: #e0e0e0;
    margin-bottom: 10px;
    font-size: 24px;
}

.modal-description {
    color: #808080;
    font-size: 14px;
    margin-bottom: 25px;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section label {
    display: block;
    color: #b0b0b0;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.modal-section input {
    width: 200px;
    padding: 10px 12px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 14px;
    margin-right: 10px;
}

.modal-section input:focus {
    outline: none;
    border-color: #4a90e2;
}

.mode-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    background: #1a1a1a;
    padding: 4px;
    border-radius: 6px;
    width: fit-content;
}

.mode-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #808080;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.mode-btn:hover {
    color: #b0b0b0;
    background: #2a2a2a;
}

.mode-btn.active {
    background: #4a90e2;
    color: white;
}

.mode-description {
    font-size: 13px;
    color: #808080;
    font-style: italic;
    margin-top: 8px;
}

.modal-progress {
    margin: 25px 0;
    padding: 20px;
    background: #1a1a1a;
    border-radius: 6px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #3a3a3a;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a90e2, #357abd);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    color: #b0b0b0;
    font-size: 13px;
    text-align: center;
    margin: 0;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 25px;
}

.modal-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.modal-btn.primary {
    background: #4a90e2;
    color: white;
}

.modal-btn.primary:hover {
    background: #357abd;
}

.modal-btn.primary:disabled {
    background: #3a3a3a;
    color: #808080;
    cursor: not-allowed;
}

.modal-btn:not(.primary) {
    background: #3a3a3a;
    color: #e0e0e0;
}

.modal-btn:not(.primary):hover {
    background: #4a4a4a;
}

.modal-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.property-value {
    color: #4a90e2;
    font-weight: 600;
    margin-left: 8px;
}

/* Heatmap Legend */
#heatmapLegend {
    position: fixed;
    bottom: 220px; /* Above the 200px plot container + 20px margin */
    left: 20px;
    background: rgba(42, 42, 42, 0.95);
    border: 2px solid #3a3a3a;
    border-radius: 8px;
    padding: 15px;
    z-index: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    min-width: 280px;
    user-select: none; /* Prevent text selection */
    pointer-events: none; /* Make it non-interactive */
}

#heatmapTooltip {
    position: fixed;
    background: rgba(26, 26, 26, 0.95);
    border: 2px solid #4a90e2;
    border-radius: 6px;
    padding: 10px 14px;
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 500;
    z-index: 1000;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.legend-title {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 10px;
    text-align: center;
}

.legend-gradient {
    height: 20px;
    border-radius: 4px;
    background: linear-gradient(to right, 
        rgb(255, 0, 0) 0%,      /* Red at 0% */
        rgb(255, 255, 0) 50%,   /* Yellow at 50% */
        rgb(0, 255, 0) 100%     /* Green at 100% */
    );
    border: 1px solid #555;
    margin-bottom: 5px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #b0b0b0;
}

.legend-labels span {
    flex: 1;
    text-align: center;
}

.legend-labels span:first-child {
    text-align: left;
}

.legend-labels span:last-child {
    text-align: right;
}
