:root {
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --text-muted: #999999;
  --background-primary: rgba(38, 38, 38, 0.95);
  --background-secondary: rgba(42, 42, 42, 0.8);
  --background-overlay: rgba(255, 255, 255, 0.95);
  --border-color: #444444;
  --accent-color: #00bfff;
  --hover-color: rgba(255, 255, 255, 0.1);
  --shadow-color: rgba(0, 0, 0, 0.3);
}

html, body, #cesiumContainer {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.cesium-viewer-bottom {
    display: none;
}

/* --- Modern UI Customization --- */

/* --- Top Right Toolbar and Buttons --- */
.cesium-viewer-toolbar {
    background: rgba(42, 42, 42, 0.8);
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    border: 1px solid #444;
}

.cesium-button {
    background-color: transparent;
    color: #ffffff;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

.cesium-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    box-shadow: none;
}

/* --- InfoBox (Wikipedia Article Window) --- */
/* InfoBox Container Positioning */
.cesium-viewer-infoBoxContainer {
    position: absolute !important;
    top: 80px !important;
    right: 10px !important;
    z-index: 1000 !important;
    pointer-events: none !important;
}

.cesium-infoBox-visible {
    pointer-events: auto !important;
}

.cesium-infoBox {
    background: rgba(26, 26, 26, 0.98);
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.6);
    color: #ffffff;
    width: 380px;
    min-width: 300px;
    max-width: 80vw;
    height: 70vh;
    min-height: 300px;
    max-height: 85vh;
    backdrop-filter: blur(10px);
    overflow: hidden;
    resize: both;
    position: relative;
    /* Move resize handle to bottom-left */
    transform: scaleX(-1);
}

/* Fix content orientation after flipping the container */
.cesium-infoBox > * {
    transform: scaleX(-1);
}

.cesium-infoBox-title {
    background: linear-gradient(135deg, #2a2a2a, #1a1a2a);
    color: #00bfff;
    font-size: 1.3em;
    font-weight: 600;
    padding: 15px 20px;
    border-bottom: 2px solid #444;
    border-radius: 12px 12px 0 0;
    cursor: move;
    user-select: none;
}

.cesium-infoBox-close {
    background-color: transparent;
    color: #ffffff;
    font-size: 24px;
    top: 12px;
    right: 18px;
    transition: color 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.cesium-infoBox-close:hover {
    color: #ff4d4d;
    transform: scale(1.1);
}

/* InfoBox iframe styling */
.cesium-infoBox-iframe {
    border-radius: 0 0 12px 12px;
    background: #1a1a1a;
    width: 100%;
    height: calc(100% - 60px);
    border: none;
    overflow: auto;
}

/* InfoBox body content */
.cesium-infoBox-description {
    padding: 0 !important;
    margin: 0 !important;
    background: #1a1a1a;
    border-radius: 0 0 12px 12px;
    overflow: auto;
    max-width: 100%;
    height: calc(100% - 60px);
    resize: none;
}

/* Scrollbar styling for InfoBox */
.cesium-infoBox-description::-webkit-scrollbar {
    width: 8px;
}

.cesium-infoBox-description::-webkit-scrollbar-track {
    background: #2a2a2a;
    border-radius: 0 0 12px 0;
}

.cesium-infoBox-description::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.cesium-infoBox-description::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Resize handle indicator */
.cesium-infoBox::after {
    content: '';
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, transparent 40%, #555 40%, #555 60%, transparent 60%);
    cursor: nwse-resize;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.cesium-infoBox:hover::after {
    opacity: 0.8;
}

/* --- UI Toolbar (Top Left) --- */
#toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    background: var(--background-secondary);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    max-width: 320px;
    box-sizing: border-box;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px var(--shadow-color);
}

#toolbar label {
  margin-left: 5px;
  margin-right: 10px;
  vertical-align: middle;
}

.filter-controls {
  display: inline-flex;
  align-items: center;
  margin-left: 20px;
  padding-left: 20px;
  border-left: 1px solid #666;
  flex-wrap: nowrap;
}

.filter-controls label {
  display: inline-flex;
  align-items: center;
  margin: 0 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-controls input[type="checkbox"] {
  margin-right: 5px;
  cursor: pointer;
}

.filter-status {
    margin-top: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    color: var(--text-secondary);
}

.filter-controls strong {
  color: var(--text-primary);
  margin-right: 10px;
}

#toolbar input {
    vertical-align: middle;
    margin-right: 5px;
}

/* --- Geocoder (Search Bar) --- */
.cesium-geocoder-input {
    background: rgba(62, 62, 62, 0.9);
    border: 1px solid #555;
    border-radius: 5px;
}

/* Search Styling */
.search-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.modern-search {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-primary);
  font-size: 14px;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.modern-search:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.modern-search::placeholder {
  color: var(--text-secondary);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: var(--background-primary);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 32px var(--shadow-color);
  z-index: 1000;
  margin-top: 4px;
  display: none;
}

.search-result-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s ease;
  color: var(--text-primary);
  background: var(--background-primary);
}

.search-result-item:hover {
  background-color: var(--hover-color);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.search-result-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
  margin-top: 4px;
}

.search-result-coordinates {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.search-loading {
  padding: 12px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--background-primary);
}

.search-no-results {
  padding: 12px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--background-primary);
}

.cesium-geocoder-searchButton {
    background: rgba(62, 62, 62, 0.9);
}

/* --- Loading Indicator --- */
#loading-indicator {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 10;
    width: 30px;
    height: 30px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none;
}

#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(18, 18, 18, 0.9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #f0f0f0;
    font-family: sans-serif;
    transition: opacity 0.5s ease-in-out;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#loading-overlay .loading-text {
    margin-top: 20px;
    font-size: 1.2em;
    letter-spacing: 1px;
}

/* --- Toolbar Styles --- */
.modern-toolbar {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(26, 26, 26, 0.95);
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.6);
    color: #ffffff;
    min-width: 320px;
    max-width: 420px;
    backdrop-filter: blur(10px);
    z-index: 1001;
    overflow: hidden;
    transition: all 0.3s ease;
}

.toolbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #2a2a2a, #1a1a2a);
    border-bottom: 1px solid #444;
    cursor: pointer;
    user-select: none;
}

.toolbar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #00bfff;
}

.toolbar-icon {
    fill: #00bfff;
}

.toolbar-toggle {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.2em;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.toolbar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.toolbar-content {
    max-height: 80vh;
    overflow-y: auto;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.modern-toolbar.collapsed .toolbar-content {
    max-height: 0;
    max-width: 20vw;
    opacity: 0;
    overflow: hidden;
}

.modern-toolbar.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.toolbar-section {
    padding: 20px;
    border-bottom: 1px solid #333;
}

/* Locate Me Button */
.locate-me-button {
  position: absolute;
  bottom: 25px;
  left: 25px;
  z-index: 1000;
  background-color: rgba(26, 26, 26, 0.9);
  border: 1px solid #444;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  backdrop-filter: blur(5px);
}

.locate-me-button:active {
    transform: scale(0.95);
}

/* Style for when location tracking is active */
.locate-me-button.tracking-active {
    background-color: #4CAF50; /* Green to indicate 'active' */
    animation: pulse-glow 2s infinite;
    border-color: #81C784;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    70% {
        box-shadow: 0 0 10px 15px rgba(76, 175, 80, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

.locate-me-icon {
  width: 28px;
  height: 28px;
  fill: #ffffff;
}

.toolbar-section:last-child {
    border-bottom: none;
}

/* Cities Grid Styles */
.cities-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.city-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-size: 0.9em;
    color: #e0e0e0;
}

.city-item:hover {
    background: rgba(0, 191, 255, 0.1);
    border-color: #00bfff;
    color: #00bfff;
    transform: translateY(-1px);
}

.city-item:active {
    transform: translateY(0);
}

/* Filter Grid Styles */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 15px;
    max-width: 100%;
    box-sizing: border-box;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #666;
}

.filter-item input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
    accent-color: #00bfff;
    flex-shrink: 0;
}

.filter-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    display: block;
    min-width: 14px;
    min-height: 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.filter-indicator.location {
    background-color: #00bfff;
}

.filter-indicator.event {
    background-color: #ff4444;
}

.filter-item .filter-indicator.battles {
    background-color: #ff8800 !important;
}

.filter-item .filter-indicator.disasters {
    background-color: #aa44ff !important;
}

/* Tablet Responsive (601px - 1024px) */
@media screen and (max-width: 1024px) {
    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Small tablet (601px - 768px) */
@media screen and (max-width: 768px) {
    .filter-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .modern-toolbar {
        max-width: 320px;
    }
}
