html, body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    color: #333;
}

#appContainer {
    display: flex;
}

#mapid {
    flex: 1;
    position: relative; /* Needed for map controls positioning */
}

#flightsContainer {
    width: 450px;
    background: #fff;
    overflow-y: auto;
    border-left: 1px solid #ddd;
    box-shadow: -3px 0 10px rgba(0,0,0,0.1);
}

.flight-control-container {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.flight-control-container h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
    color: #0056b3;
}

.flight-control-container.active-flight {
    box-shadow: inset 4px 0 0px #333;
}

.flight-summary, .flight-timeline-display {
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 10px;
}

.flight-summary strong {
    color: #0056b3;
}

.chart-container {
    height: 150px; /* Set a fixed height for charts */
    margin-bottom: 15px;
}

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

.timeline-slider {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: #d3d3d3;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
    border-radius: 5px;
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

.timeline-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

.playback-speed-button {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    padding: 3px 8px;
    cursor: pointer;
    border-radius: 3px;
}

.playback-speed-button.selected {
    background-color: #007bff;
    color: white;
}

#mapControls {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 5px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    display: flex;
    gap: 5px;
}

.map-layer-icon {
    font-size: 1.2em;
    padding: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 3px;
}

.selected-layer, .selected-tool {
    border-color: #007bff;
}

.main-header {
    background-color: #ffffff;
    padding: 8px 15px;
    border-bottom: 1px solid #eee;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    z-index: 1001;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-header h1 {
    font-size: 1.5em;
    color: #0056b3;
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

#fileUploadSection {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="file"] {
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 5px;
    background-color: #f9f9f9;
    cursor: pointer;
}

.drive-icon {
    font-size: 1.5em;
    color: #4285F4;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.drive-icon:hover {
    background-color: rgba(66, 133, 244, 0.2);
}

#header-icons {
    display: flex;
    align-items: center;
    gap: 15px;
}

#settingsButton {
    font-size: 1.3em;
    color: #555;
    cursor: pointer;
    transition: color 0.3s ease;
}

#settingsButton:hover {
    color: #007bff;
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 25px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    max-height: 85vh;
        overflow-y: auto;
}
/* Ensure flex display for active modals handled by JS, but we can add helper here if needed */

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 15px;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal h2 {
    margin-top: 0;
    color: #0056b3;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input {
    width: calc(100% - 55px);
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#saveSettingsButton {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    font-size: 1em;
}

#saveSettingsButton:hover {
    background-color: #0056b3;
}

/* Tooltip Styles */
.tooltip-icon {
    position: absolute;
    top: 35px;
    right: 10px;
    transform: translateY(-50%);
    cursor: pointer;
    color: #aaa;
}

.tooltip-icon .tooltip-text {
    visibility: hidden;
    width: 250px;
    background-color: #555;
    color: #fff;
    text-align: left;
    text-transform: none;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1;
    bottom: 125%; 
    left: 50%;
    margin-left: -125px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85em;
    line-height: 1.4;
    font-family: Arial, sans-serif;
}

.tooltip-icon:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.tooltip-text a {
    color: #8ab4f8;
    text-decoration: none;
}

#globalPlaybackControls {
    display: flex;
    align-items: center;
    gap: 10px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.playback-button {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    justify-content: center;
    align-items: center;
}

.playback-button.playing {
    background-color: #007bff;
    color: white;
}

.global-playback-speed-button {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    padding: 5px 12px;
    cursor: pointer;
    border-radius: 3px;
}

.global-playback-speed-button.selected {
    background-color: #007bff;
    color: white;
}

.plane-icon {
    transition: transform 0.1s linear;
}

.plane-icon svg {
    transition: transform 0.1s linear;
}

#loadNewKmlButton {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

@media (max-width: 768px) {
    .main-header {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    #globalPlaybackControls {
        position: static;
        transform: none;
    }

    #appContainer {
        flex-direction: column;
    }

    #mapid {
        height: 60vh; /* Use viewport height for mobile map */
        flex: none;
        position: sticky;
        top: 0;
        z-index: 1000; /* Ensure map stays on top while scrolling */
    }

    #flightsContainer {
        width: 100%;
        min-height: 40vh; /* Ensure it has a substantial height but can grow */
        height: auto;
        overflow-y: visible; /* Allow content to expand the page */
        border-left: none;
        border-top: 1px solid #ddd;
    }
}

@media (min-width: 769px) {
    html, body {
        height: 100vh;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Prevent body scrollbars */
    }

    #appContainer {
        flex: 1;
        overflow: hidden; /* Prevent this container from causing scrollbars */
    }
}

/* Custom Drive Picker Styles */
.drive-picker-content {
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    width: 90%;
    max-width: 600px;
}

.drive-breadcrumbs {
    padding: 10px;
    background-color: #f0f0f0;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 0.9em;
    white-space: nowrap;
    overflow-x: auto;
}

.drive-breadcrumb-item {
    cursor: pointer;
    color: #007bff;
    margin-right: 5px;
}

.drive-breadcrumb-item:hover {
    text-decoration: underline;
}

.drive-breadcrumb-separator {
    color: #666;
    margin-right: 5px;
}

.drive-item-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
}

.drive-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.drive-item:hover {
    background-color: #f9f9f9;
}

.drive-item.selected {
    background-color: #e3f2fd;
    border-left: 4px solid #007bff;
}

.drive-item-icon {
    margin-right: 10px;
    font-size: 1.2em;
    color: #666;
    width: 24px;
    text-align: center;
}

.drive-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drive-picker-footer {
    padding-top: 15px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.action-button {
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

.action-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.action-button.secondary {
    background-color: #6c757d;
}

.action-button.secondary:hover {
    background-color: #5a6268;
}

/* Graph Data Modal Styles */
.graph-data-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
    margin-top: 10px;
}

.graph-data-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.graph-data-option:hover {
    background-color: #f0f0f0;
}

.graph-data-option input[type="checkbox"] {
    cursor: pointer;
}

.flight-header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.graph-control-button {
    background: none;
    border: none;
    cursor: pointer;
    color: #555;
    font-size: 1.1em;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
}

.graph-control-button:hover {
    background-color: #e0e0e0;
    color: #007bff;
}