body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #121212;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden; /* Prevent body scroll */
}

.navbar {
    background-color: #1e1e1e;
    padding: 10px 20px;
    text-align: center;
    border-bottom: 2px solid #444;
}

.nav-button {
    color: #e0e0e0;
    text-decoration: none;
    margin: 0 15px;
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid #555;
    background-color: #333;
    transition: background-color 0.3s, color 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.nav-button:hover {
    background-color: #444;
}

.nav-button.active {
    background-color: #bb86fc;
    color: #121212;
    font-weight: bold;
    border-color: #bb86fc;
}

h1 {
    text-align: center;
    margin: 10px 0;
    font-weight: 300;
    font-size: 1.5rem;
    color: #e0e0e0;
}

#main-container, #main-container-vertical {
    display: flex;
    flex: 1;
    overflow: hidden;
    flex-direction: column; /* Stack vertically on small screens */
}

#map-container {
    flex: 1; 
    display: flex;
    flex-direction: column;
    min-height: 300px; /* Ensure map container has a minimum height */
}

#map {
    width: 100%;
    height: 70%;
    background-color: #333;
}

#timeline {
    width: 100%;
    height: 30%;
    background-color: #1e1e1e;
    border-top: 2px solid #444;
}

#info-panel {
    background-color: #1e1e1e;
    border-top: 2px solid #444;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 50vh; /* Adjust height for small screens */
}

#event-details {
    padding: 20px;
    flex-shrink: 0;
}

#event-details h2 {
    margin-top: 0;
    color: #bb86fc;
}

#event-details p {
    line-height: 1.6;
}

#event-list-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 20px 20px 20px;
    border-top: 1px solid #444;
}

#event-list-container h3 {
    margin: 15px 0 10px 0;
    font-weight: 500;
    color: #e0e0e0;
}

/* Accordion Styles */
.accordion-button {
    background-color: #333;
    color: #e0e0e0;
    cursor: pointer;
    padding: 12px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 1em;
    transition: background-color 0.4s ease;
    border-bottom: 1px solid #444;
}

.accordion-button:hover, .accordion-button.active {
    background-color: #444;
}

.accordion-button:after {
    content: '\25B6'; /* Right-pointing triangle */
    font-size: 0.8em;
    color: #aaa;
    float: right;
    transition: transform 0.2s ease;
}

.accordion-button.active:after {
    transform: rotate(90deg);
}

.accordion-panel {
    padding: 0;
    background-color: #1e1e1e;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
}

#accordion-container .event-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.event-list-item {
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
    transition: background-color 0.2s;
}

.event-list-item:hover {
    background-color: #3a3a3a;
}

.event-list-item.selected {
    background-color: #bb86fc;
    color: #121212;
}

.event-list-date {
    font-weight: bold;
    color: #aaa;
    flex-shrink: 0;
}

.event-list-title {
    margin-left: 15px; /* Added space between year and title */
    text-align: left;
}

.event-list-item.selected .event-list-date {
    color: #121212;
}


.category-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.8em;
    font-weight: bold;
    color: #121212;
    margin-bottom: 10px;
}

.Military { background-color: #cf6679; }
.Political { background-color: #03dac6; }
.Clandestine { background-color: #bb86fc; }
.Military-Conflict { background-color: #cf6679; }
.Political-Debacle { background-color: #f2a365; }
.Military-Service { background-color: #03dac6; }
.Global-Conflict { background-color: #cf6679; }
.Clandestine-Operations { background-color: #bb86fc; }
.Technological-Development { background-color: #f2a365; }
.Political-Policy { background-color: #87CEEB; }


/* VIS-TIMELINE STYLING OVERRIDE */
.vis-timeline {
    border: none;
}
.vis-item {
    background-color: #424242;
    border-color: #bb86fc;
    color: #e0e0e0;
    border-radius: 4px;
}
.vis-item.vis-selected {
    background-color: #bb86fc;
    border-color: #fff;
    color: #121212;
}
.vis-time-axis .vis-grid.vis-major {
    border-color: #555;
}
.vis-time-axis .vis-text {
    color: #999;
}

/* Vertical Timeline Styles */
#vertical-timeline-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    position: relative;
}

#vertical-timeline {
    position: relative;
    border-left: 3px solid #444;
    padding: 10px 0;
}

.timeline-event {
    display: flex;
    align-items: center;
    margin-left: 20px;
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
    padding: 10px;
    border-radius: 6px;
    transition: background-color 0.3s;
}
.timeline-event:hover {
    background-color: #2a2a2a;
}
.timeline-event.selected {
    background-color: #3a3a3a;
    border: 1px solid #bb86fc;
}

.timeline-dot {
    width: 20px;
    height: 20px;
    background-color: #121212;
    border: 4px solid #fff;
    border-radius: 50%;
    position: absolute;
    left: -31px; /* Adjust to center on the line */
    top: 50%;
    transform: translateY(-50%);
}

.timeline-content {
    display: flex;
    align-items: center;
}

.timeline-date {
    font-size: 1.2em;
    font-weight: bold;
    color: #bb86fc;
    margin-right: 20px;
}

.timeline-title {
    font-size: 1em;
}

#info-panel-vertical {
    background-color: #1e1e1e;
    padding: 20px;
    overflow-y: auto;
    height: 50vh; /* Default height for mobile */
}
#info-panel-vertical h2 {
    margin-top: 0;
    color: #bb86fc;
}
#info-panel-vertical p {
    line-height: 1.6;
}

.connection-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #444;
}
.connection-section h3 {
    color: #03dac6;
    margin-bottom: 10px;
}


/* Responsive Design for larger screens */
@media (min-width: 768px) {
    #main-container, #main-container-vertical {
        flex-direction: row; /* Side-by-side layout on larger screens */
    }

    #map-container, #vertical-timeline-container {
        flex: 3; /* Map/Timeline takes 3/4 of the space */
    }

    #info-panel, #info-panel-vertical {
        flex: 1; /* Info panel takes 1/4 of the space */
        border-left: 2px solid #444;
        border-top: none; /* Remove top border on large screens */
        height: auto; /* Reset height */
    }
}
