html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 20px;
    background-color: #f0f0f0;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.navbar {
    flex-shrink: 0;
    margin-bottom: 0;
}

.instructions-container {
    background-color: #f8f9fa;
    border-bottom: 1px solid #ddd;
    overflow: hidden;
    width: 100%;
}

.instructions-toggle {
    padding: 8px 20px;
    background-color: #e9ecef;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.instructions-toggle:hover {
    background-color: #dee2e6;
}

.instructions {
    padding: 15px 20px;
    margin: 0;
}

.instructions p {
    margin-bottom: 8px;
    max-width: 800px;
}

.instructions ol {
    margin: 0 0 8px 0;
    padding-left: 25px;
    max-width: 800px;
}

.attribution {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
    margin: 0;
}

.instructions-content {
    max-height: 1000px;
    transition: max-height 0.3s ease-out;
    background-color: white;
}

.instructions-content.collapsed {
    max-height: 0;
}

.content-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

#map {
    width: 50%;
    height: calc(100vh - 120px);
}

.control-panel {
    width: 50%;
    background: white;
    border-left: 1px solid #ddd;
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

.control-panel-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.frozen-header {
    padding: 20px;
    background: white;
    border-bottom: 1px solid #eee;
    transition: max-height 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}

.control-panel.collapsed .frozen-header {
    max-height: 60px;
    padding: 10px 20px;
}

.control-panel.collapsed .frozen-header > *:not(.controls-header) {
    display: none;
}

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

.control-panel.collapsed .controls-header {
    margin-bottom: 0;
}

.controls-header h5 {
    margin: 0;
}

.control-panel-toggle {
    cursor: pointer;
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-panel-toggle:hover {
    background: #f8f9fa;
}

.control-panel-toggle .toggle-icon {
    transition: transform 0.3s ease;
}

.control-panel.collapsed .toggle-icon {
    transform: rotate(180deg);
}

.species-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.taxonomy-group-header {
    padding: 6px 8px;
    margin: 4px 0;
    background: #f8f9fa;
    font-weight: 500;
    font-size: 0.9em;
    color: #495057;
    border-left: 3px solid #0d6efd;
}

.species-item {
    padding: 6px 8px;
    margin-bottom: 2px;
    background: white;
    max-width: 100%;
    border-bottom: 1px solid #eee;
}

.species-item:hover {
    background: #f8f9fa;
}

.species-item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.species-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 0 auto;
    min-width: 120px;
    max-width: 200px;
    font-weight: 500;
    font-size: 0.9em;
    color: #212529;
}

.species-taxonomy {
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
    flex: 1 1 auto;
    font-size: 0.75em;
    min-width: 0;
}

/* Make the species list header sticky */
.species-list-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 8px;
    margin: 0 -8px 8px;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.95em;
    font-weight: 500;
    z-index: 10;
}

.species-list-header .btn {
    font-size: 0.8em;
    padding: 4px 8px;
}

.toast-container {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 9999;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

.leaflet-control-container .leaflet-top {
    top: 10px;
}

.leaflet-control-container .leaflet-left {
    left: 10px;
}

.btn-group-vertical {
    width: 100%;
}

.btn-group-vertical .btn {
    margin-bottom: 5px;
    text-align: left;
}

.saved-geofences-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
}

.saved-geofence-item {
    padding: 8px 12px;
    border-bottom: 1px solid #dee2e6;
    background: white;
}

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

.saved-geofence-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
    flex: 1;
}

.saved-geofence-item:hover {
    background-color: #f8f9fa;
}

.taxonomy-group-header.kingdom-level {
    background: #e9ecef;
    font-size: 1.1em;
    padding: 10px 12px;
}

.taxonomy-group-header.phylum-level {
    background: #f1f3f5;
    padding-left: 24px;
}

.taxonomy-group-header.class-level {
    background: #f8f9fa;
    padding-left: 36px;
}

.taxonomy-group-header.order-level {
    background: #ffffff;
    padding-left: 48px;
    border-left: 3px solid #dee2e6;
}

/* SQL Download Modal styles */
#sqlQuery {
    font-family: monospace;
    font-size: 14px;
    white-space: pre;
    resize: vertical;
}

.modal-lg {
    max-width: 800px;
}

.alert-info a {
    color: #055160;
    text-decoration: underline;
}

.alert-info a:hover {
    color: #055160;
    text-decoration: none;
}