body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #1a1a1a;
    color: #f0f0f0;
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll */
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background-color: #2d2d2d;
    padding: 0.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    height: 50px;
    border-bottom: 1px solid #3c3a3a7a;
}

header h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #f8f8f8;
}

.controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    min-width: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

select {
    padding: 4px;
    background-color: #3d3d3d;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
}

input[type=range] {
    width: 150px;
}

/* TOP ROW LAYOUT */
.top-row {
    display: flex;
    flex: 1;
    /* Takes remaining height */
    overflow: hidden;
    min-height: 0;
    /* Important for flex scrolling */
}

#map-container {
    flex: 3;
    /* 75% width */
    position: relative;
    height: 100%;
}

#map {
    height: 100%;
    width: 100%;
    background-color: #242424;
}

#sidebar {
    flex: 1;
    /* 25% width */
    min-width: 300px;
    background-color: #2d2d2d;
    padding: 1rem;
    overflow-y: auto;
    border-left: 1px solid #3d3d3d;
}

#state-name {
    margin-top: 5px;
}

#state-events {
    margin-bottom: 5px;
}

/* BOTTOM ROW LAYOUT */
.bottom-row {
    display: flex;
    height: 35vh;
    /* Fixed height for charts */
    min-height: 250px;
    background-color: #222;
    border-top: 1px solid #3d3d3d;
    padding: 10px;
    gap: 10px;
}

.chart-col {
    flex: 1;
    min-width: 0;
    /* Prevents flex item from overflowing */
}

.panel {
    background-color: #363636;
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.panel:hover {
    transform: translateY(-2px);
    transition: 0.4s ease;
    box-shadow: 0 6px 14px rgba(29, 29, 29, 0.35);
}

.panel.h-100 {
    height: 100%;
    margin-bottom: 0;
    box-sizing: border-box;
}

.panel h2 {
    margin-top: 0;
    font-size: 1rem;
    border-bottom: 1px solid #4d4d4d;
    padding-bottom: 0.3rem;
    margin-bottom: 0.5rem;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
}

.instruction {
    color: #888;
    font-size: 0.9rem;
}

.legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(45, 45, 45, 0.9);
    padding: 10px;
    border-radius: 5px;
    z-index: 1000;
    color: white;
    font-size: 0.8rem;
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.legend i {
    width: 15px;
    height: 15px;
    float: left;
    margin-right: 8px;
    opacity: 0.7;
}

.note {
    color: #888;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* Multi-Select Dropdown Styles */
.multiselect-dropdown {
    position: relative;
    width: 100%;
}

.multiselect-btn {
    width: 100%;
    padding: 8px;
    background-color: #3d3d3d;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.multiselect-btn:after {
    content: '\25BC';
    font-size: 0.8em;
    margin-left: 10px;
}

.multiselect-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #3d3d3d;
    border: 1px solid #555;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.multiselect-content.show {
    display: block;
}

.multiselect-item {
    display: block;
    padding: 8px 10px;
    cursor: pointer;
    color: #ddd;
    font-size: 0.9em;
    border-bottom: 1px solid #444;
}

.multiselect-item:last-child {
    border-bottom: none;
}

.multiselect-item:hover {
    background-color: #4d4d4d;
    color: #fff;
}

.multiselect-item input {
    margin-right: 10px;
}

.leaflet-interactive {
    transition: fill 0.35s ease, fill-opacity 0.45s ease;
}

#details-content {
    opacity: 1;
    transition: opacity 0.25s ease-in-out;
}

#details-content.fade-out {
    opacity: 0;
}

/* Chatbot Styles */
.chatbot-btn {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
    height: 30px;
}

.chatbot-btn:hover {
    background-color: #0056b3;
}

.chatbot-panel {
    position: fixed;
    top: 0;
    right: -400px;
    /* Hidden by default */
    width: 350px;
    height: 100vh;
    background-color: #2d2d2d;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
    z-index: 2001;
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #444;
}

.chatbot-panel.open {
    right: 0;
}

.chatbot-header {
    padding: 15px;
    background-color: #363636;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #fff;
}

.chatbot-header p {
    margin: 5px 0 0;
    font-size: 0.8rem;
    color: #aaa;
    width: 100%;
}

.chatbot-close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
}

.chatbot-close-btn:hover {
    color: #fff;
}

.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    word-wrap: break-word;
}

.bot-message {
    background-color: #3d3d3d;
    color: #eee;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    margin-right: auto;
}

.user-message {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.chatbot-input-area {
    padding: 15px;
    background-color: #363636;
    border-top: 1px solid #444;
    display: flex;
    gap: 10px;
}

.chatbot-input-area input {
    flex: 1;
    padding: 10px;
    border-radius: 20px;
    border: 1px solid #555;
    background-color: #2d2d2d;
    color: white;
    outline: none;
}

.chatbot-input-area input:focus {
    border-color: #007bff;
}

.chatbot-input-area button {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.chatbot-input-area button:hover {
    background-color: #0056b3;
}

.chatbot-btn:hover {
    background-color: #0056b3;
}

.chatbot-btn svg {
    width: 20px;
    height: 20px;
}

header .chatbot-btn {
    display: flex !important;
    flex-shrink: 0;
    white-space: nowrap;
}
