/* General Body & Layout Styles */
html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 0;
    color: #333;
    overflow: hidden;
    /* Prevent body scrolling */
}

.app-container {
    display: flex !important;
    /* <--- *** FIX 1: OVERRIDES INLINE "display: block;" *** */
    flex-direction: column;
    width: 100%;
    height: 100vh;
    /* This is correct: Force to full viewport height */
    overflow: hidden;
}

/* Top Navigation Bar */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1877f2;
    color: white;
    padding: 10px 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.nav-left h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.logout-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.logout-btn:active {
    background-color: rgba(255, 255, 255, 0.4);
}

/* Main Content Area */
.main-app-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    /* This is correct: allows flex: 1 to work */
}

/* Sidebar Styles */
.sidebar {
    width: 320px;
    background-color: #fff;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar h2 {
    color: #1c1e21;
    margin-top: 0;
    text-align: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}

.sidebar-section {
    margin-bottom: 25px;
}

.sidebar-section h3 {
    margin-top: 0;
    color: #606770;
    font-size: 16px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.file-input-label {
    background-color: #1877f2;
    color: white;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    display: block;
    text-align: center;
    transition: background-color 0.3s ease;
}

.file-input-label:hover {
    background-color: #166fe5;
}

#fileInput {
    display: none;
}

/* Main Content Styles */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.view-switcher {
    padding: 10px;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    text-align: center;
    z-index: 5;
}

.view-switcher button {
    background-color: #e4e6eb;
    color: #1c1e21;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease, color 0.3s ease;
    border-radius: 5px;
    margin: 0 4px;
}

.view-switcher button.active {
    background-color: #1877f2;
    color: white;
}

.viewer-container {
    flex-grow: 1;
    position: relative;
}

#map,
#maptilerContainer,
#cesiumContainer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
}

/*
 * --- FIX 2: OVERRIDES INLINE "height: 343px" on map canvas ---
*/
.maplibregl-canvas {
    height: 100% !important;
}


#map,
#cesiumContainer {
    display: none;
}

/* Waypoint List Styles */
#waypoint-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    /* Correct: Add scroll to list */
    max-height: 35vh;
    /* Correct: Adjust height as needed */
}

#waypoint-list li {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 4px;
}

#waypoint-list li:hover {
    background-color: #f5f5f5;
}

#waypoint-list li.selected {
    background-color: #e7f3ff;
    color: #1877f2;
    font-weight: bold;
}

/* Action Buttons */
.sidebar-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin-top: 10px;
    transition: background-color 0.2s;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: auto;
    /* Correct: Stick buttons to bottom */
}

.action-buttons button {
    flex-grow: 1;
    background-color: #42b72a;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
}

#downloadBtn {
    background-color: #e4e6eb;
    color: #1c1e21;
}

#downloadBtn:hover {
    background-color: #d8dbdf;
}

/* Other UI Components */
#status {
    padding-top: 15px;
    border-top: 1px solid #eee;
    color: #606770;
    font-size: 14px;
    text-align: center;
}

/* Context Menu & Modal Styles */
.context-menu {
    display: none;
    position: absolute;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    padding: 5px 0;
}

.context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.context-menu li {
    padding: 8px 15px;
    cursor: pointer;
}

.context-menu li:hover {
    background-color: #f0f0f0;
}

.context-menu li.disabled {
    color: #999;
    cursor: not-allowed;
    background-color: #f9f9f9;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 20px;
    border-radius: 5px;
    width: 90%;
    max-width: 400px;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

#waypointForm label {
    display: block;
    margin-top: 10px;
    text-align: left;
}

#waypointForm input,
#waypointForm select {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    box-sizing: border-box;
}

#waypointForm button {
    margin-top: 20px;
    width: 100%;
    background-color: #1877f2;
    color: white;
    padding: 10px;
    border: none;
    border-radius: 5px;
}


/* NEW: Loading Overlay and Spinner Styles */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    /* Hidden by default */
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: #1877f2;
    border-bottom: 2px solid #1877f2;
}

.tab-content {
    display: none;
}

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

#rawDescription {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    resize: vertical;
}