/* Base Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f2f5;
    color: #333;
}

/* Main Container */
.container {
    width: 95vw;
    margin: 20px auto;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

h1 {
    color: #2c3e50;
    margin-top: 0;
    font-size: 24px;
    width: 100%;
}

/* Map Container */
#map {
    height: 100%;
    width: 100%;
    border-radius: 6px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    position: relative;
    overflow: hidden;
}

/* Controls Section */
.controls {
    display: flex;
    align-items: center;
    gap: 150px;
    margin: 20px 0;
    padding: 3px;
    background-color: rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    margin-bottom: 10px;
}

#date-picker {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    min-width: 180px;
}

/* Complete tooltip control - no lingering, no fading */
.leaflet-popup-pane,
.leaflet-tooltip-pane {
    display: none !important; /* Hide Leaflet's default containers */
}

.political-tooltip-container {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    opacity: 1 !important;
    transition: none !important;
    animation: none !important;
    background: white;
    border-radius: 6px;
    box-shadow: 0 3px 14px rgba(0,0,0,0.2);
    border: 1px solid #ddd;
    padding: 12px;
    min-width: 200px;
    max-width: 220px;
    transform: translate3d(0,0,0); /* Hardware acceleration */
}

.political-tooltip-container h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #2c3e50;
}

.political-tooltip-container p {
    margin: 6px 0;
}

.political-tooltip-container strong {
    display: inline-block;
    width: 70px;
}

/* Leaflet Overrides */
.leaflet-control-zoom {
    margin-right: 10px !important;
    margin-top: 10px !important;
    border: 1px solid #ddd !important;
}

.leaflet-bar a {
    background-color: white !important;
    color: #555 !important;
    border-bottom: 1px solid #eee !important;
}

.leaflet-bar a:hover {
    background-color: #f8f9fa !important;
}

/* Disable all animations at root level */
.leaflet-container {
    --leaflet-tooltip-transition: none !important;
}

.leaflet-popup {
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .container {
        width: 95vw;
        padding: 15px;
    }
    
    #map {
        height: 100%;
    }
    
    .controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    #date-picker {
        width: 100%;
    }
}

/* Table Styles */
.table-container {
    margin: 20px auto;
    max-width: 1000px;
    overflow-x: auto;
}

/* Reference Link */
.reference-link {
    display: inline-block;
    margin: 10px 0;
    padding: 8px 15px;
    background: #4285f4;
    color: white;
    text-decoration: none;
    border-radius: 4px;
}

.reference-link:hover {
    background: #3367d6;
}

.political-tooltip-container {
    /* Keep all your existing styles */
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    /* Add these to ensure proper positioning */
    transform: none !important;
    will-change: transform;
    /* Remove any bottom positioning */
    bottom: auto !important;
}

/* Keep all your existing .tooltip-title, .tooltip-row, etc. styles */

.tooltip-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    line-height: 1.4;
}

.tooltip-label {
    font-weight: bold;
    margin-right: 10px;
    flex: 0 0 100px; /* Fixed width for labels */
    text-align: left;
}

.tooltip-value {
    flex: 1;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tooltip-title {
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 8px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.tooltip-dates {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    font-style: italic;
}

/* Prevent white tiles during loading */
.leaflet-container .leaflet-layer,
.leaflet-container .leaflet-tile-container {
    will-change: auto !important;
    transform: translate3d(0,0,0) !important;
}

/* Remove fade effects on tiles */
.leaflet-tile {
    opacity: 1 !important;
    transition: none !important;
    background-color: transparent !important;
}

/* Hide loading placeholder */
.leaflet-container .leaflet-loading {
    display: none !important;
}

/* Disable all tile loading animations */
.leaflet-tile-container img {
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
}

/* Ensure no blank spaces during movement */
.leaflet-container {
    backface-visibility: hidden;
    perspective: 1000;
    transform-style: preserve-3d;
}

/* Disable all tile loading animations */
.leaflet-tile-container img {
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
}

/* Ensure no blank spaces during movement */
.leaflet-container {
    backface-visibility: hidden;
    perspective: 1000;
    transform-style: preserve-3d;
}

#prev-date-btn, #next-date-btn {
    padding: 8px 12px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 500px;
    margin-bottom: 10px;
}

#prev-decade-btn:hover, #prev-year-btn:hover, #prev-date-btn:hover, 
#next-date-btn:hover, #next-year-btn:hover, #next-decade-btn:hover {
    background-color: #3367d6;
}

#prev-decade-btn:disabled, #prev-year-btn:disabled, #prev-date-btn:disabled, 
#next-date-btn:disabled, #next-year-btn:disabled, #next-decade-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Prevent Leaflet controls from overlapping */
.leaflet-top.leaflet-right {
    margin-top: 50px;
}

/* Improve visibility on different map backgrounds */
.leaflet-container .political-legend,
.leaflet-container .legend-toggle-button {
    transition: all 0.2s ease;
}

/* Ensure good contrast on dark map areas */
.leaflet-container.dark-mode .political-legend,
.leaflet-container.dark-mode .legend-toggle-button {
    background: rgba(45, 45, 45, 0.9);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.leaflet-container.dark-mode .political-legend h3,
.leaflet-container.dark-mode .political-legend .legend-label {
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

/* Country Info Popup Styles */
.country-info-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.popup-content {
    padding: 20px;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.popup-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 20px;
}

.popup-close {
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    color: #666;
    user-select: none;
}

.popup-close:hover {
    color: #dc3912;
    background: rgba(220, 57, 18, 0.1);
    border-radius: 50%;
}

.policy-section {
    margin-bottom: 20px;
}

.policy-section h4 {
    margin: 0 0 10px 0;
    color: #4285f4;
    font-size: 16px;
    font-weight: 600;
}

.policy-text {
    margin: 0;
    line-height: 1.6;
    color: #333;
    text-align: justify;
}

/* Overlay background */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .country-info-popup {
        width: 95%;
        max-width: none;
        margin: 10px;
    }
    
    .popup-content {
        padding: 15px;
    }
    
    .popup-header h3 {
        font-size: 18px;
    }
}

/* Enhanced Popup Styles */
.popup-title-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.popup-flag {
    height: 20px;
    width: 30px;
    object-fit: cover;
    border: 1px solid #ddd;
    border-radius: 2px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    color: #333;
    font-size: 14px;
	display: flex;
    align-items: center;
    gap: 5px;
}

.policy-label {
    font-size: 12px;
    font-weight: normal;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .info-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .info-label {
        font-size: 11px;
    }
    
    .info-value {
        font-size: 13px;
        text-align: right;
    }
}

.policy-label.policy-left {
    background-color: #dc3912; /* -3 color */
    color: white;
}

.policy-label.policy-center-left {
    background-color: #f19009; /* -1 color */
    color: white;
}

.policy-label.policy-center-right {
    background-color: #8097a4; /* 2 color */
    color: white;
}

.policy-label.policy-right {
    background-color: #4285f4; /* 3 color */
    color: white;
}

/* Alignment label colors - same as map tiles */
.alignment-label.alignment-far-left {
    background-color: #dc3912;
    color: white;
}

.alignment-label.alignment-left {
    background-color: #e6650d;
    color: white;
}

.alignment-label.alignment-center-left {
    background-color: #f19009;
    color: white;
}

.alignment-label.alignment-centrist {
    background-color: #fbbc04;
    color: #333;
}

.alignment-label.alignment-center-right {
    background-color: #bdaa54;
    color: #333;
}

.alignment-label.alignment-right {
    background-color: #8097a4;
    color: white;
}

.alignment-label.alignment-far-right {
    background-color: #4285f4;
    color: white;
}

.alignment-label {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    margin-left: 5px;
}

.policy-label.policy-centrist {
    background-color: #fbbc04; /* 0 color */
    color: #333;
}

.alignment-label {
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
}

.alignment-far-left { background-color: #dc3912; color: white; }
.alignment-left { background-color: #e6650d; color: white; }
.alignment-center-left { background-color: #f19009; color: black; }
.alignment-centrist { background-color: #fbbc04; color: black; }
.alignment-center-right { background-color: #bdaa54; color: black; }
.alignment-right { background-color: #8097a4; color: white; }
.alignment-far-right { background-color: #4285f4; color: white; }

/* Leader portrait styles */
.leader-portrait-container {
    text-align: center;
    margin: 10px 0;
}

.leader-portrait {
    width: 120px;
    height: 150px;
    border: 2px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    margin: 0 auto;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leader-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.leader-portrait source + img {
    /* Hide the fallback image if a source is found */
    display: none;
}

.leader-portrait source:not([srcset]) + img {
    /* Show the fallback image if no source is found */
    display: block;
}

.leader-name {
    margin-top: 8px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

.popup-header-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.popup-header-top h3 {
    margin: 0;
    flex: 1;
}

/* Adjust existing styles for the new layout */
.popup-title-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leader-portrait {
    width: 120px;
    height: 150px;
    margin: 0 auto;
    position: relative;
}

.leader-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 2px solid #ddd;
    border-radius: 3px;
}

.leader-portrait .no-portrait {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 3px;
    color: #666;
    font-style: italic;
}

.leader-name {
    margin-top: 8px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

/* Adjust popup body layout for portrait */
.popup-body {
    display: flex;
    flex-direction: column;
}

.info-grid {
    order: 2; /* Move info grid below portrait */
}

.policy-section {
    order: 3; /* Keep policy sections at bottom */
}

/* Leader portrait styles - for body placement */
.leader-portrait-container {
    text-align: center;
    margin: 0 0 20px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.leader-portrait {
    width: 120px;
    height: 150px;
    margin: 0 auto;
    display: none; /* Hidden until loaded */
    object-fit: cover;
    border: 2px solid #ddd;
    border-radius: 4px;
}

.no-portrait {
    width: 120px;
    height: 150px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 4px;
    color: #666;
    font-style: italic;
    font-size: 12px;
}

.leader-name {
    margin-top: 10px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

/* Ensure popup body layout is correct */
.popup-body {
    display: flex;
    flex-direction: column;
}

.popup-body > .leader-portrait-container {
    order: 1;
}

.popup-body > .info-grid {
    order: 2;
}

.popup-body > .policy-section {
    order: 3;
}

/* Header layout - flag and country name on same line */
.popup-header-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.popup-header-top .popup-flag {
    width: 40px;
    height: 25px;
    object-fit: cover;
    border: 1px solid #ddd;
}

.popup-header-top h3 {
    margin: 0;
    font-size: 1.5em;
    color: #333;
}

/* Side-by-side layout for portrait and info */
.info-portrait-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.leader-portrait-container {
    flex: 0 0 auto;
    text-align: center;
}

.leader-portrait {
    width: 120px;
    height: 150px;
    display: none; /* Hidden until loaded */
    object-fit: cover;
    border: 2px solid #ddd;
    border-radius: 4px;
}

.no-portrait {
    width: 120px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 4px;
    color: #666;
    font-style: italic;
    font-size: 12px;
}

.leader-name {
    margin-top: 8px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
    max-width: 120px;
}

.info-grid {
    flex: 1;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 15px;
    align-content: start;
}

.info-item {
    display: contents;
}

.info-label {
    font-weight: bold;
    color: #555;
    text-align: right;
    white-space: nowrap;
}

.info-value {
    color: #333;
}

/* Policy sections */
.policy-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.policy-section h4 {
    margin: 0 0 8px 0;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.policy-label {
    font-size: 0.8em;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: bold;
}

.policy-text {
    margin: 0;
    line-height: 1.5;
    color: #555;
}

/* Alignment labels */
.alignment-label {
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.alignment-far-left { background-color: #dc3912; color: white; }
.alignment-left { background-color: #e6650d; color: white; }
.alignment-center-left { background-color: #f19009; color: black; }
.alignment-centrist { background-color: #fbbc04; color: black; }
.alignment-center-right { background-color: #bdaa54; color: black; }
.alignment-right { background-color: #8097a4; color: white; }
.alignment-far-right { background-color: #4285f4; color: white; }

/* Leader portrait styles */
.leader-portrait-container {
    flex: 0 0 auto;
    text-align: center;
}

.leader-portrait {
    width: 120px;
    height: 150px;
    display: none; /* Hidden until loaded */
    object-fit: cover;
    border: 2px solid #ddd;
    border-radius: 4px;
}

.no-portrait {
    width: 120px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 4px;
    color: #666;
    font-style: italic;
    font-size: 12px;
}

/* Info grid layout */
.info-grid {
    flex: 1;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 15px;
    align-content: start;
}

.info-item {
    display: contents;
}

.info-label {
    font-weight: bold;
    color: #555;
    text-align: right;
    white-space: nowrap;
}

.info-value {
    color: #333;
}

/* Make sure alignment is at the bottom visually */
.info-item:last-child {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-item:last-child .info-label {
    text-align: left;
}

.info-item:last-child .info-value {
    margin-left: 10px;
}

.date-input-row input[type="date"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    min-width: 140px;
    flex: 0 0 auto;
}

.map-controls-panel .controls > * {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.map-controls-panel input[type="date"] {
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    min-width: 120px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .map-controls-panel {
        max-width: 380px;
        left: 5px;
        top: 5px;
        padding: 8px;
    }
    
    .date-input-row input[type="date"] {
        min-width: 120px;
        font-size: 13px;
        padding: 6px;
    }
    
    .nav-buttons-row button {
        padding: 6px 8px;
        font-size: 13px;
        min-width: 35px;
    }
}

@media (max-width: 480px) {
    .map-controls-panel {
        max-width: 320px;
    }
    
    .nav-buttons-row {
        gap: 2px;
    }
    
    .nav-buttons-row button {
        padding: 5px 6px;
        font-size: 12px;
        min-width: 30px;
    }
    
    .date-input-row input[type="date"] {
        min-width: 110px;
        font-size: 12px;
    }
}

.nav-buttons-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.nav-buttons-row button:hover {
    background: #f0f0f0;
}

.nav-buttons-row button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.autoplay-row {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.autoplay-row #play-pause-btn {
    min-width: 45px;
    font-size: 16px;
    padding: 8px 12px;
    border-radius: 6px;
}

.speed-control label {
    white-space: nowrap;
    color: #666;
    font-weight: 500;
}

.speed-control input[type="range"] {
    width: 90px;
}

.speed-control #speed-value {
    min-width: 70px;
    text-align: left;
    font-size: 12px;
    color: #444;
    font-weight: 500;
}

.play-btn:hover, .pause-btn:hover {
    background-color: #3367d6 !important;
	transform: scale(1.05);
}

.play-btn:active, .pause-btn:active {
    background-color: #3367d6 !important;
	transform: scale(0.95);
}

.nav-buttons-row button:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-buttons-row button:active {
    transform: scale(0.95);
}

/* Navigation buttons - fix disabled state */
.nav-buttons-row button {
    padding: 4px 6px;
    border: 1px solid #ddd;
    background: rgba(0, 0, 0, 0.0);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    min-width: 0;
    flex: 1;
    display: flex;
    text-align: center;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: 500;
    height: 28px;
}

.nav-buttons-row button:not(:disabled) {
    /* Only apply hover effects to enabled buttons */
}

.nav-buttons-row button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #f9f9f9 !important;
    border-color: #eee !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Ensure enabled buttons have proper colors */
.nav-buttons-row button:not(:disabled) {
    opacity: 1;
}

/* Color coding for different time jumps - only for enabled buttons */
#prev-decade-btn:not(:disabled), #next-decade-btn:not(:disabled) {
    background-color: #f8f8f8;
    border-color: #bbb;
}

#prev-year-btn:not(:disabled), #next-year-btn:not(:disabled) {
    background-color: #f5f5f5;
}

#prev-date-btn:not(:disabled), #next-date-btn:not(:disabled) {
    background-color: #f0f0f0;
}

/* Hover effects only for enabled buttons */
#prev-decade-btn:not(:disabled):hover, #next-decade-btn:not(:disabled):hover {
    background-color: #3367d6;
}

#prev-year-btn:not(:disabled):hover, #next-year-btn:not(:disabled):hover {
    background-color: #3367d6;
}

#prev-date-btn:not(:disabled):hover, #next-date-btn:not(:disabled):hover {
    background-color: #3367d6;
}




#prev-date-btn, #next-date-btn {
    padding: 8px 12px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

#prev-date-btn:hover, #next-date-btn:hover {
    background-color: #3367d6;
}

#prev-date-btn:disabled, #next-date-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

#prev-decade-btn, #prev-year-btn, #prev-date-btn, 
#next-date-btn, #next-year-btn, #next-decade-btn {
    padding: 8px 12px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 8px;
}

#prev-decade-btn:hover, #prev-year-btn:hover, #prev-date-btn:hover, 
#next-date-btn:hover, #next-year-btn:hover, #next-decade-btn:hover {
    background-color: #3367d6;
}

#prev-decade-btn:disabled, #prev-year-btn:disabled, #prev-date-btn:disabled, 
#next-date-btn:disabled, #next-year-btn:disabled, #next-decade-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.leaflet-container.dark-mode .legend-close {
    color: #ccc;
}

.leaflet-container.dark-mode .legend-close:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.2);
}

/* Navigation buttons - enabled state (blue) */
.nav-buttons-row button:not(:disabled) {
    background-color: #4285f4;
    border-color: #3367d6;
    color: white;
}

/* Disabled state (gray) */
.nav-buttons-row button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #cccccc !important;
    border-color: #bbbbbb !important;
    color: #666666 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Navigation button row styling */
.nav-buttons-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* Color coding for different time jumps */
#prev-decade-btn:not(:disabled), #next-decade-btn:not(:disabled) {
    background-color: #4285f4;
}

#prev-year-btn:not(:disabled), #next-year-btn:not(:disabled) {
    background-color: #4285f4;
}

#prev-date-btn:not(:disabled), #next-date-btn:not(:disabled) {
    background-color: #4285f4;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Full-page map */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.map-controls-panel .controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.date-input-row {
    display: flex;
    justify-content: center;
    gap: 5px;
}


/* Map controls panel */
.map-controls-panel {
    position: absolute;
    top: 0px;
    left: 80px;
    z-index: 1000;
    background: rgba(255, 255, 255, .0);
    border: 0px solid #ccc;
    border-radius: 0px;
    max-width: 500px;
    transition: all 0.3s ease;
}

/* Speed controls panel */
.speed-controls-panel {
    position: absolute;
    top: 90px;
    left: 80px;
    z-index: 1000;
    background: rgba(255, 255, 255, .0);
    border: 0px solid #ccc;
    border-radius: 0px;
    max-width: 500px;
    transition: all 0.3s ease;
}

/* Loading indicator */
#loading-indicator {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #ccc;
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

/* Tooltip */
.political-tooltip-container {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #ccc !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(5px) !important;
}

/* Country info popup */
.country-info-popup {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid #ccc !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2) !important;
}

.popup-overlay {
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(3px) !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .map-controls-panel {
        top: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .nav-buttons-row {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-buttons-row button {
        flex: 0 0 calc(33.333% - 4px);
        margin-bottom: 4px;
    }
}

@media (max-width: 480px) {
    .map-controls-panel {
        padding: 10px;
    }
    
    .date-input-row input[type="date"] {
        min-width: 120px;
        font-size: 14px;
    }
    
    .nav-buttons-row button {
        padding: 6px 8px;
        font-size: 12px;
        min-width: 30px;
    }
}

.nav-buttons-row {
    display: flex;
    justify-content: center;
    gap: 3px;
    flex-wrap: nowrap;
    width: 140px; /* Match the date input width */
}

/* Navigation buttons - enabled state (blue) */
.nav-buttons-row button:not(:disabled) {
    background-color: #4285f4;
    border-color: #3367d6;
    color: white;
}

/* Hover effects for enabled buttons */
.nav-buttons-row button:not(:disabled):hover {
    background-color: #3367d6;
    transform: scale(1.05);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.nav-buttons-row button:not(:disabled):active {
    transform: scale(0.95);
}

/* Disabled state (gray) */
.nav-buttons-row button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #cccccc !important;
    border-color: #bbbbbb !important;
    color: #666666 !important;
    transform: none !important;
    box-shadow: none !important;
}

.date-input-row input[type="date"] {
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    width: 140px;
    height: 28px;
}

.autoplay-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 15px;
    padding-left: 15px;
    border-left: 1px solid #ddd;
}

#play-pause-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #4285f4;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

#play-pause-btn.pause-btn::before {
    content: "❚❚";
}

#play-pause-btn.play-btn::before {
    content: "▶";
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

#playback-speed {
    width: 80px;
}

/* Responsive adjustments for autoplay */
@media (max-width: 768px) {
    .autoplay-controls {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        width: 100%;
        justify-content: center;
    }
    
    .speed-control {
        flex-direction: column;
        gap: 4px;
    }
}

.autoplay-controls {
    display: flex;
    align-items: center;
    justify-content: center;
}

#play-pause-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #4285f4;
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

#play-pause-btn:hover {
    background: #3367d6;
}

.speed-control {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    width: 100%;
}

.speed-control label {
    white-space: nowrap;
    color: #666;
    text-align: center;
}

.speed-control input[type="range"] {
    width: 100%;
    height: 6px;
}

#speed-value {
    text-align: center;
    font-size: 12px;
    color: #444;
    font-weight: 500;
}

/* Top-centered portrait layout */
.leader-portrait-top-container {
    text-align: center;
    margin: 0 0 20px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    width: 100%;
    box-sizing: border-box;
}

.leader-portrait-top-container .leader-portrait-container {
    margin: 0 auto;
}

/* Adjust info grid for the new layout */
.popup-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.info-grid {
    order: 2; /* Ensure info grid comes after portrait */
    margin-top: 0;
}

.policy-section {
    order: 3; /* Policy sections come last */
}

/* Remove the old side-by-side styles */
.info-portrait-container {
    display: none !important;
}

/* Increased portrait size (1.5x) */
.leader-portrait-top-container .leader-portrait {
    width: 180px; /* 120px * 1.5 */
    height: 225px; /* 150px * 1.5 */
    display: none; /* Hidden until loaded */
    object-fit: cover;
    border: 2px solid #ddd;
    border-radius: 6px; /* Slightly larger border radius */
    margin: 0 auto;
}

.leader-portrait-top-container .no-portrait {
    width: 180px;
    height: 225px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 6px;
    color: #666;
    font-style: italic;
    font-size: 14px;
    margin: 0 auto;
}

.leader-portrait-top-container .leader-name {
    margin-top: 12px;
    font-weight: bold;
    font-size: 16px;
    color: #333;
    text-align: center;
}

/* Adjust the container to accommodate larger portrait */
.leader-portrait-top-container {
    text-align: center;
    margin: 0 0 25px 0; /* Slightly more margin */
    padding: 20px; /* More padding */
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    width: 100%;
    box-sizing: border-box;
}

/* Adjust popup sizing for larger portrait */
.country-info-popup {
    max-width: 550px; /* Slightly wider to accommodate larger portrait */
}

.popup-content {
    padding: 25px; /* More padding for larger content */
}

/* Ensure info grid has proper spacing */
.info-grid {
    margin-top: 10px;
    padding: 0;
}

/* Adjust policy sections for new layout */
.policy-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #eee;
}

.policy-section h4 {
    font-size: 17px;
    margin-bottom: 12px;
}

.policy-text {
    font-size: 15px;
    line-height: 1.6;
}

/* Adjust popup sizing for larger portrait */
.country-info-popup {
    max-width: 550px; /* Slightly wider to accommodate larger portrait */
}

.popup-content {
    padding: 25px; /* More padding for larger content */
}

/* Ensure info grid has proper spacing */
.info-grid {
    margin-top: 10px;
    padding: 0;
}

/* Adjust policy sections for new layout */
.policy-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #eee;
}

.policy-section h4 {
    font-size: 17px;
    margin-bottom: 12px;
}

.policy-text {
    font-size: 15px;
    line-height: 1.6;
}

/* Party logo styles */
.party-logo-container {
    margin-top: 15px;
    padding: 10px;
    background-color: #f8f8f8;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
    text-align: center;
}

.party-logo {
    max-width: 120px;
    max-height: 80px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* Adjust leader name margin when logo is present */
.leader-portrait-container:has(.party-logo-container) .leader-name {
    margin-bottom: 10px;
}

/* Adjust portrait container for logo */
.leader-portrait-container {
    position: relative;
}

/* Responsive adjustments for party logo */
@media (max-width: 768px) {
    .party-logo-container {
        margin-top: 12px;
        padding: 8px;
    }
    
    .party-logo {
        max-width: 100px;
        max-height: 60px;
    }
}

@media (max-width: 480px) {
    .party-logo-container {
        margin-top: 10px;
        padding: 6px;
    }
    
    .party-logo {
        max-width: 80px;
        max-height: 50px;
    }
}

/* Outer container for portrait and logo */
.leader-portrait-top-container {
    text-align: center;
    margin: 0 0 25px 0;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    width: 100%;
    box-sizing: border-box;
}

/* Inner portrait container (existing styles) */
.leader-portrait-top-container .leader-portrait-container {
    margin: 0 auto 20px auto; /* Add bottom margin for separation */
    padding: 15px;
    background-color: white;
    border-radius: 6px;
    border: 1px solid #ddd;
    width: fit-content;
}

/* Outer logo container (below portrait in the same outer box) */
.party-logo-outer-container {
    margin-top: 15px;
    padding: 12px;
    background-color: #f8f8f8;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
    text-align: center;
}

.party-logo-outer-container .party-logo {
    max-width: 120px;
    max-height: 80px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* Adjust responsive styles */
@media (max-width: 768px) {
    .party-logo-outer-container {
        margin-top: 12px;
        padding: 10px;
    }
    
    .party-logo-outer-container .party-logo {
        max-width: 100px;
        max-height: 60px;
    }
}

@media (max-width: 480px) {
    .party-logo-outer-container {
        margin-top: 10px;
        padding: 8px;
    }
    
    .party-logo-outer-container .party-logo {
        max-width: 80px;
        max-height: 50px;
    }
}

/* Party name styling with English translation */
#popup-party {
    line-height: 1.4;
}

#popup-party em {
    font-style: italic;
    color: #666;
    font-size: 0.95em;
    display: block;
    margin-top: 3px;
}

/* Ensure proper spacing in info grid */
.info-item {
    margin-bottom: 10px;
}

.info-item:last-child {
    margin-bottom: 0;
}

/* Party name styling with English translation */
#popup-party {
    line-height: 1.4;
    display: block;
}

#popup-party em {
    font-style: italic;
    color: #666;
    font-size: 0.95em;
    display: block;
    margin-top: 3px;
}

/* Policy help button styles */
.policy-help-btn {
    width: 20px;
    height: 20px;
    border: 1px solid #ccc;
    background: #f8f9fa;
    color: #666;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    transition: all 0.2s ease;
}

.policy-help-btn:hover {
    background: #4285f4;
    color: white;
    border-color: #4285f4;
    transform: scale(1.1);
}

/* Help modal styles */
.help-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2001;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.help-modal-content {
    padding: 25px;
    position: relative;
}

.help-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #666;
}

.help-close:hover {
    color: #dc3912;
}

.help-modal h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 20px;
    padding-right: 30px;
}

.help-modal p {
    margin: 0 0 20px 0;
    font-style: italic;
    color: #666;
    font-size: 14px;
}

.help-content h4 {
    margin: 20px 0 10px 0;
    color: #4285f4;
    font-size: 16px;
}

.help-content ul {
    margin: 0 0 20px 0;
    padding-left: 20px;
}

.help-content li {
    margin-bottom: 6px;
    line-height: 1.4;
    color: #333;
}

.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .help-modal {
        width: 95%;
        max-width: none;
        margin: 10px;
    }
    
    .help-modal-content {
        padding: 20px;
    }
    
    .help-modal h3 {
        font-size: 18px;
    }
    
    .policy-help-btn {
        width: 18px;
        height: 18px;
        font-size: 11px;
        margin-left: 6px;
    }
}