/* --- General Body and Global Styling --- */
html {
    box-sizing: border-box;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}
*, *:before, *:after {
    box-sizing: inherit;
}

body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: "Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 14px;
    line-height: 1.5;
    color: #3c4043;
    background-color: #f0f2f5;
    overflow: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 28px;
    background-color: #FFFFFF;
    z-index: 10001;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

body::after {
    content: "";
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 28px;
    background-color: #FFFFFF;
    z-index: 10001;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
}

.page-container {
    display: flex;
    position: absolute;
    top: 28px;
    bottom: 28px;
    left: 0;
    right: 0;
    padding-top: 16px;
    padding-right: 16px;
    padding-bottom: 16px;
    padding-left: 0;
    gap: 16px;
    overflow: hidden;
}

/* --- Sidebar Styling --- */
.sidebar {
    width: 360px;
    flex-shrink: 0;
    background-color: #ffffff;
    border-top: 1px solid #dadce0;
    border-right: 1px solid #dadce0;
    border-bottom: 1px solid #dadce0;
    border-left: none;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    box-shadow: 3px 0px 15px rgba(0, 0, 0, 0.07), 0px 4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 20;
    box-sizing: border-box;
    position: relative;
    overflow-x: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed { width: 60px; }
.sidebar .sidebar-header { padding: 20px 24px; border-bottom: 1px solid #dadce0; flex-shrink: 0; transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-sizing: border-box; white-space: nowrap; }
.sidebar.collapsed .sidebar-header { padding: 20px 0; display: flex; justify-content: center; align-items: center; }
.sidebar .sidebar-header h2 { margin: 0; font-size: 1.375em; color: #3c4043; font-weight: 500; line-height: 1.2; opacity: 1; visibility: visible; transition: opacity 0.2s ease-in-out, visibility 0s linear 0s; }
.sidebar.collapsed .sidebar-header h2 { opacity: 0; visibility: hidden; transition: opacity 0.1s ease-in-out, visibility 0s linear 0.1s; }
.sidebar .sidebar-content { padding: 8px 24px 24px 24px; overflow-y: auto; overflow-x: hidden; flex-grow: 1; opacity: 1; visibility: visible; transition: opacity 0.2s ease-in-out 0.1s, visibility 0s linear 0s; }
.sidebar.collapsed .sidebar-content { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.1s ease-in-out, visibility 0s linear 0.1s; padding-right: 0; padding-left: 0; }
.sidebar-content::-webkit-scrollbar { width: 6px; }
.sidebar-content::-webkit-scrollbar-thumb { background-color: #dadce0; border-radius: 3px; }
.sidebar-content::-webkit-scrollbar-track { background-color: transparent; }

#controls { background: transparent; box-shadow: none; position: static; max-height: none; z-index: auto; }
#controls h3 { margin-top: 28px; margin-bottom: 16px; font-size: 0.875em; color: #5f6368; font-weight: 500; border-bottom: none; padding-bottom: 0; white-space: nowrap; }
#controls h3:first-child { margin-top: 8px; }
#controls div { margin-bottom: 16px; }
#controls label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 0.875em; color: #3c4043; line-height: 1.4; white-space: nowrap; }
#controls input[type="number"], #controls input[type="text"], #controls input[type="file"], #controls select { width: 100%; padding: 10px 12px; margin-bottom: 4px; border: 1px solid #dadce0; border-radius: 4px; box-sizing: border-box; font-size: 0.875em; color: #3c4043; background-color: #fff; transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; }
#controls input[type="number"]:focus, #controls input[type="text"]:focus, #controls input[type="file"]:focus, #controls select:focus { border-color: #1a73e8; box-shadow: 0 0 0 1px #1a73e8; outline: none; }
#controls input[type="file"] { background-color: #fff; padding-top: 8px; padding-bottom: 8px; }
#controls input[type="file"]::file-selector-button { padding: 6px 12px; margin-right: 12px; border: 1px solid #dadce0; border-radius: 4px; background-color: #f8f9fa; color: #1a73e8; font-weight: 500; cursor: pointer; transition: background-color 0.15s ease; }
#controls input[type="file"]::file-selector-button:hover { background-color: #f1f3f4; }

/* --- MODIFIED: Base Button Styles for Immersive Feel & Common Properties --- */
#controls button {
    width: 100%;
    padding: 9px 16px; /* Base padding */
    border-radius: 20px; /* Consistent rounded (pill-like) shape */
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out, transform 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    font-size: 0.875em; /* 14px */
    font-weight: 500; /* Medium weight */
    text-align: center;
    box-sizing: border-box;
    line-height: 1.5;
    white-space: nowrap;
    border: 1px solid transparent; /* Make space for border, but initially transparent for some */
    box-shadow: none; /* Default no shadow, to be added on hover for immersive */
}

/* Primary Action Buttons (Filled Style) */
#controls #setCenterBtn,
#controls #processFileBtn {
    background-color: #1a73e8; /* Google Blue */
    color: white;
    border-color: #1a73e8; /* Match background for solid feel */
}
#controls #setCenterBtn:hover,
#controls #processFileBtn:hover {
    background-color: #1868cc;
    border-color: #1868cc;
    box-shadow: 0 2px 4px rgba(26,115,232,0.2);
    transform: translateY(-1px);
}
#controls #setCenterBtn:active,
#controls #processFileBtn:active {
    background-color: #175cb5;
    border-color: #175cb5;
    box-shadow: none;
    transform: translateY(0px);
}

/* MODIFIED: Immersive Style for Secondary/Toggle Buttons */
#controls #toggleGridBtn,
#controls #toggleHullsBtn,
#controls #drawRulersBtn,
#controls #toggleHybridOverlayBtn {
    background-color: transparent;
    color: #5f6368;
    border: 1px solid #dadce0;
}

#controls #toggleGridBtn:hover,
#controls #toggleHullsBtn:hover,
#controls #drawRulersBtn:hover,
#controls #toggleHybridOverlayBtn:hover {
    background-color: #f1f3f4;
    color: #1a73e8;
    border-color: #dadce0;
}

#controls #toggleGridBtn:active,
#controls #toggleHullsBtn:active,
#controls #drawRulersBtn:active,
#controls #toggleHybridOverlayBtn:active {
    background-color: #e8eaed;
    color: #174ea6;
    border-color: #dadce0;
    box-shadow: none;
    transform: translateY(0px);
}

#controls button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.4);
}
#controls #toggleGridBtn:focus-visible,
#controls #toggleHullsBtn:focus-visible,
#controls #drawRulersBtn:focus-visible,
#controls #toggleHybridOverlayBtn:focus-visible {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.4);
}

#controls button:disabled {
    background-color: #f1f3f4 !important;
    color: #bdc1c6 !important;
    border-color: #f1f3f4 !important;
    cursor: not-allowed;
    box-shadow: none !important;
    transform: none !important;
}

#localTilesConfig { padding:16px; border: 1px solid #dadce0; margin-top:16px; border-radius: 8px; background-color: #f8f9fa; }
#localTilesConfig label { font-weight: 400; color: #5f6368; }
#controls p { font-size: 0.75em; color: #5f6368; margin-top: 6px; margin-bottom: 16px; line-height: 1.4; }

/* --- Map Area Styling --- */
.map-main-area {
    flex-grow: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
    background-color: transparent;
}

#map-container {
    flex-grow: 1;
    border: 1px solid #dadce0;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: visible;
    position: relative;
    display: flex;
    background-color: #fff;
}

#map {
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

#map-container .maplibregl-ctrl-group { border-radius: 4px !important; box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15) !important; }
#map-container .maplibregl-ctrl-group button { border-radius: 4px !important; background-color: #fff !important; color: #5f6368 !important; transition: background-color 0.15s ease; }
#map-container .maplibregl-ctrl-group button:hover { background-color: #f1f3f4 !important; }

/* --- Legend Styling --- */
#legend { position: absolute; top: 16px; right: 16px; background: #ffffff; padding: 16px; border-radius: 8px; z-index: 10; box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 2px 6px 2px rgba(60,64,67,0.15); max-height: calc(100% - 32px); overflow-y: auto; font-size: 0.875em; border: 1px solid #dadce0; }
#legend::-webkit-scrollbar { width: 5px; }
#legend::-webkit-scrollbar-thumb { background-color: #dadce0; border-radius: 3px; }
#legend::-webkit-scrollbar-track { background-color: transparent; }
#legend h3 { margin-top: 0; margin-bottom: 12px; font-size: 1em; text-align: left; color: #3c4043; border-bottom: 1px solid #e8eaed; padding-bottom: 8px; font-weight: 500; }
.legend-item { display: flex; align-items: center; margin-bottom: 8px; font-size: 0.875em; color: #3c4043; }
.legend-color-box { width: 14px; height: 14px; margin-right: 10px; border: 1px solid #dadce0; display: inline-block; flex-shrink: 0; border-radius: 3px; }

/* --- Tooltip Styling --- */
.custom-map-popup .maplibregl-popup-content { font-family: inherit; font-size: 0.8125em; padding: 12px 16px; background-color: #ffffff; box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 2px 6px 2px rgba(60,64,67,0.15); border-radius: 8px; color: #3c4043; line-height: 1.5; max-width: 280px; }
.custom-map-popup .maplibregl-popup-content b { display: block; margin-bottom: 6px; color: #1a73e8; font-weight: 500; font-size: 0.9375em; }
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: #ffffff; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: #ffffff; }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: #ffffff; }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: #ffffff; }

/* --- Button Confetti Effect Styling --- */
.confetti-particle { position: absolute; width: 6px; height: 6px; opacity: 0; pointer-events: none; border-radius: 1px; z-index: 10000; }


/* --- 时间轴浮动卡片样式 --- */
#timeline-controls-wrapper {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    width: auto;
    max-width: calc(100% - 30px);
    z-index: 1000;
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    /* NEW: Add default opacity and transition */
    opacity: 0.6; /* 默认较低的透明度，例如 60% */
    transition: opacity 0.3s ease-in-out; /* 平滑过渡效果 */
}

/* NEW: Add hover effect for the wrapper */
#timeline-controls-wrapper:hover {
    opacity: 1; /* 鼠标悬浮时完全不透明 (或您期望的较高透明度，例如 0.95) */
}

/* 卡片1: 显示模式和年月选择 */
#timeline-mode-selector-card {
    background-color: rgba(255, 255, 255, 0.92);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    width: 170px;
}

/* 卡片2: 日期滑块和当前日期显示 */
#timeline-slider-card {
    background-color: rgba(255, 255, 255, 0.92);
    padding-top: 6px;
    padding-bottom: 6px;
    padding-left: 15px;
    padding-right: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    flex-grow: 1;
    min-width: 200px;
}

/* ... (其余的 #timeline-slider-card 内部元素和滑块美化样式保持不变) ... */


/* 调整卡片内部控件的样式 */
#timeline-mode-selector-card > div,
#timeline-slider-card > div {
    margin-bottom: 0;
}

#timeline-mode-selector-card label,
#timeline-slider-card label#timelineSliderLabel {
    margin-bottom: 3px;
    font-size: 0.8em;
    font-weight: 500;
    color: #333;
    display: block;
    line-height: 1.2;
}

#timeline-slider-card #currentDateLabel {
    text-align: center;
    margin-top: 2px;
    font-size: 0.75em;
    color: #333;
    line-height: 1.2;
    padding: 2px 0;
}

#timeline-mode-selector-card select {
    width: 100%;
    padding: 5px 8px;
    font-size: 0.8em;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #fff;
    height: auto;
    line-height: 1.3;
}

/* --- 美化时间轴滑块 (#timelineSlider) --- */
#timelineSlider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px; /* Thinner track */
    background: #d1d1d1;
    border-radius: 3px;
    outline: none;
    opacity: 0.9;
    transition: opacity .15s ease-in-out;
    cursor: pointer;
    margin-top: 4px;
    margin-bottom: 4px;
}

#timelineSlider:hover {
    opacity: 1;
}

/* WebKit (Chrome, Safari, newer Edge, Opera) - Thumb */
#timelineSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px; /* Adjust width for airplane icon */
    height: 22px; /* Adjust height for airplane icon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.01 21L23 12 2.01 3 2 10l15 2-15 2z' fill='%231a73e8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 90%; /* Adjust size of icon within thumb area */
    background-color: transparent;
    border: none;
    border-radius: 0; /* No border radius for airplane icon */
    cursor: pointer;
    margin-top: -8px; /* Recalculate: (track_height - thumb_height) / 2 = (6px - 22px) / 2 = -8px */
    transition: transform 0.15s ease-in-out;
}

#timelineSlider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

#timelineSlider::-webkit-slider-thumb:active {
    transform: scale(1.25);
}


/* Mozilla Firefox - Thumb */
#timelineSlider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.01 21L23 12 2.01 3 2 10l15 2-15 2z' fill='%231a73e8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 90%;
    background-color: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: transform 0.15s ease-in-out;
}

#timelineSlider::-moz-range-thumb:hover {
    transform: scale(1.15);
}

#timelineSlider::-moz-range-thumb:active {
    transform: scale(1.25);
}

/* Mozilla Firefox - Track */
#timelineSlider::-moz-range-track {
    width: 100%;
    height: 6px; /* Match WebKit track height */
    background: #d1d1d1;
    border-radius: 3px;
    cursor: pointer;
}

/* Microsoft Edge (older, non-Chromium) and IE - Thumb */
#timelineSlider::-ms-thumb {
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.01 21L23 12 2.01 3 2 10l15 2-15 2z' fill='%231a73e8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 90%;
    background-color: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    margin-top: 0px;
    transition: transform 0.15s ease-in-out;
}
#timelineSlider::-ms-thumb:hover {
    transform: scale(1.15);
}
#timelineSlider::-ms-thumb:active {
    transform: scale(1.25);
}

/* Microsoft Edge (older, non-Chromium) and IE - Track */
#timelineSlider::-ms-track {
    width: 100%;
    height: 6px; /* Match WebKit track height */
    background: transparent;
    border-color: transparent;
    border-width: 6px 0; /* Should match height */
    color: transparent;
    cursor: pointer;
}

#timelineSlider::-ms-fill-lower {
    background: #1a73e8; /* Blue color for the filled part */
    border-radius: 3px 0 0 3px; /* Rounded start of filled track */
}

#timelineSlider::-ms-fill-upper {
    background: #d1d1d1; /* Light grey for the unfilled part */
    border-radius: 0 3px 3px 0; /* Rounded end of unfilled track */
}
/* --- End of美化时间轴滑块 --- */


/* Hide year/month containers initially, JS will control visibility */
#timeline-mode-selector-card #yearSelectContainer,
#timeline-mode-selector-card #monthSelectContainer {
    /* JS will set display: block; when needed */
}

#timeline-mode-selector-card #yearSelectContainer div,
#timeline-mode-selector-card #monthSelectContainer div {
    margin-bottom: 0;
}