/* 基本布局 */
html, body { height: 100%; margin: 0; font-family: Arial, Helvetica, sans-serif; }
body { display: flex; flex-direction: column; }

/* 顶部工具栏 */
.topbar { 
  position: fixed; 
  left: 0; 
  right: 0; 
  top: 0; 
  height: 48px; 
  background: #0b67a3; 
  color: #fff; 
  display: flex; 
  align-items: center; 
  z-index: 10001; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.topbar .top-inner { 
  width: 100%; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding: 0 16px; 
}
.topbar .brand { 
  font-weight: 700; 
  font-size: 18px;
}
.controls { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
}
.controls button { 
  padding: 6px 12px; 
  border: none; 
  border-radius: 4px; 
  background: #fff; 
  color: #0b67a3; 
  cursor: pointer; 
  font-size: 14px;
}
.controls button:hover { 
  background: #f0f0f0; 
}
.controls .status {
  color: #fff;
  font-size: 14px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}

/* 主区域 */
main { 
  position: relative; 
  flex: 1 1 auto; 
  margin-top: 48px;
}

/* 左侧导航面板 */
.sidebar {
  position: fixed;
  top: 48px;
  left: 0;
  width: 280px;
  height: calc(100vh - 48px);
  background: #fff;
  border-right: 1px solid #e0e0e0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0,0,0,0.08);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #0b67a3 0%, #1a8ccc 100%);
  color: #fff;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
}

.sidebar-search {
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  display: flex;
  gap: 8px;
}

.sidebar-search input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
}

.sidebar-search .search-btn {
  padding: 8px 12px;
  border: none;
  background: #0b67a3;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-search .search-btn img {
  width: 16px;
  height: 16px;
  display: block;
}

/* 树形导航 */
.tree-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-item {
  user-select: none;
}

.tree-item > span {
  display: inline-block;
  vertical-align: middle;
}

.tree-item > .tree-label {
  padding: 8px 12px 8px 4px;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  border-radius: 4px;
  transition: background 0.2s;
}

.tree-item:hover > .tree-label {
  color: #0b67a3;
}

.tree-item.active > .tree-label {
  color: #0b67a3;
  font-weight: 600;
}

.tree-toggle {
  width: 16px;
  font-size: 10px;
  color: #999;
  cursor: pointer;
  margin-left: 8px;
}

.tree-icon {
  margin-left: 4px;
  font-size: 14px;
  display: inline-block;
}

.tree-icon.file img {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  display: inline-block;
}

.tree-children {
  list-style: none;
  margin: 0;
  padding-left: 20px;
}

/* 底部时间选择 */
.sidebar-footer {
  border-top: 1px solid #eee;
  padding: 16px;
  background: #fafafa;
}

.time-slider {
  position: relative;
}

.time-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin-bottom: 8px;
  background: linear-gradient(to right, #0b67a3 0%, #0b67a3 var(--slider-progress, 50%), #e0e0e0 var(--slider-progress, 50%), #e0e0e0 100%);
  border-radius: 3px;
  outline: none;
  pointer-events: none;
}

.time-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 3px solid #0b67a3;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.time-slider input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #fff;
  border: 3px solid #0b67a3;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #666;
}

.time-display span:nth-child(2) {
  color: #0b67a3;
  font-weight: 600;
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
}

.date-nav button {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.date-nav button:hover {
  background: #f0f0f0;
}

.current-date {
  font-size: 14px;
  font-weight: 600;
  color: #0b67a3;
}

/* 日历 */
.calendar {
  margin-top: 16px;
  background: #fff;
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.week-day {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  padding: 4px 0;
}

.calendar-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-date {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  color: #333;
}

.calendar-date:hover {
  background: #e8f4fd;
}

.calendar-date.other-month {
  color: #ccc;
}

.calendar-date.today {
  background: #0b67a3;
  color: #fff;
  font-weight: 600;
}

.calendar-date.selected {
  background: #1a8ccc;
  color: #fff;
}

/* 地图区域 - 调整位置为左侧留出空间 */
#map { 
  position: absolute; 
  top: 0; 
  left: 280px; 
  right: 0; 
  bottom: 0; 
}

/* 信息面板 - 温度显示 */
.infoBox {
  position: fixed;
  top: 60px;
  left: 300px;
  background: rgba(255,255,255,0.95);
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  min-width: 180px;
  font-size: 14px;
  z-index: 10002;
  cursor: move;
  user-select: none;
}

.infoBox h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #0b67a3;
  font-weight: 700;
  cursor: move;
}

.infoBox .meta { 
  margin-top: 12px; 
  color: #666; 
  font-size: 12px; 
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.infoBox #temp {
  font-size: 24px;
  font-weight: 700;
  color: #ff6600;
}

/* 拖拽功能 */
.infoBox.dragging {
  cursor: grabbing;
  opacity: 0.9;
}

/* 图表面板 */
.chart-panel {
  position: absolute;
  top: 0;
  left: 280px;
  right: 0;
  bottom: 0;
  background: #fff;
  padding: 16px;
  box-sizing: border-box;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 16px;
  color: #333;
}

.chart-header small {
  color: #666;
  font-weight: 400;
  font-size: 13px;
}

.chart-svg {
  width: 100%;
  height: 350px;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fafafa;
  margin-bottom: 16px;
}

.chart-empty {
  text-align: center;
  color: #888;
  margin-top: 16px;
  padding: 40px;
}

/* 统计表格 */
.chart-stats {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.stats-left,
.stats-right {
  flex: 1;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.stats-table thead {
  background: linear-gradient(135deg, #0b67a3 0%, #1a8ccc 100%);
  color: #fff;
}

.stats-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
}

.stats-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
}

.stats-table tbody tr:last-child {
  border-bottom: none;
}

.stats-table tbody td {
  padding: 10px 16px;
  font-size: 13px;
}

.stats-table tbody td:first-child {
  color: #666;
  width: 40%;
}

.stats-table tbody td:last-child {
  color: #333;
  font-weight: 600;
  text-align: right;
  vertical-align: middle;
}

.stat-value {
  color: #0b67a3 !important;
  font-size: 14px !important;
  text-align: right;
  display: inline-block;
  white-space: nowrap;
}

.stat-value input[type="number"] {
  width: 70px;
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
  font-size: 13px;
  color: #0b67a3;
  font-weight: 600;
  background: #fff;
  transition: all 0.2s;
  margin: 0;
  vertical-align: middle;
  display: inline-block;
}

.stat-value input[type="number"]:hover {
  border-color: #0b67a3;
}

.stat-value input[type="number"]:focus {
  outline: none;
  border-color: #0b67a3;
  box-shadow: 0 0 0 2px rgba(11, 103, 163, 0.1);
}

.stat-value span {
  margin-left: 4px;
  color: #666;
  font-weight: normal;
  vertical-align: middle;
  display: inline-block;
}

/* 历史数据表格面板 */
.history-panel {
  position: absolute;
  top: 0;
  left: 280px;
  right: 0;
  bottom: 0;
  background: #fff;
  padding: 16px;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #0b67a3;
}

.history-header > span {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.history-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.time-range-selector {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-right: 12px;
}

.time-range-selector label {
  font-size: 13px;
  color: #666;
  white-space: nowrap;
}

.time-input {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  transition: border-color 0.2s;
}

.time-input:hover {
  border-color: #0b67a3;
}

.time-input:focus {
  outline: none;
  border-color: #0b67a3;
  box-shadow: 0 0 0 2px rgba(11, 103, 163, 0.1);
}

.custom-datetime-wrapper {
  position: relative;
  display: inline-block;
}

.custom-datetime-input {
  cursor: pointer;
  background: #fff;
}

.custom-datetime-picker {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10000;
  min-width: 320px;
  padding: 16px;
}

.custom-datetime-picker .dtp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.custom-datetime-picker .dtp-month-year {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-datetime-picker .dtp-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: #666;
  font-size: 16px;
}

.custom-datetime-picker .dtp-nav-btn:hover {
  color: #0b67a3;
}

.custom-datetime-picker .dtp-calendar {
  margin-bottom: 12px;
}

.custom-datetime-picker .dtp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.custom-datetime-picker .dtp-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  padding: 4px 0;
}

.custom-datetime-picker .dtp-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.custom-datetime-picker .dtp-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  color: #333;
}

.custom-datetime-picker .dtp-day:hover {
  background: #e8f4fd;
}

.custom-datetime-picker .dtp-day.other-month {
  color: #ccc;
}

.custom-datetime-picker .dtp-day.today {
  background: #e8f4fd;
  color: #0b67a3;
  font-weight: 600;
}

.custom-datetime-picker .dtp-day.selected {
  background: #0b67a3;
  color: #fff;
  font-weight: 600;
}

.custom-datetime-picker .dtp-time-selector {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.custom-datetime-picker .dtp-time-col {
  flex: 1;
}

.custom-datetime-picker .dtp-time-col-title {
  text-align: center;
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

.custom-datetime-picker .dtp-time-list {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
}

.custom-datetime-picker .dtp-time-item {
  padding: 6px 12px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.custom-datetime-picker .dtp-time-item:hover {
  background: #f0f0f0;
}

.custom-datetime-picker .dtp-time-item.selected {
  background: #0b67a3;
  color: #fff;
  font-weight: 600;
}

.custom-datetime-picker .dtp-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.custom-datetime-picker .dtp-btn {
  flex: 1;
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.custom-datetime-picker .dtp-btn:hover {
  background: #f0f0f0;
}

.custom-datetime-picker .dtp-btn.dtp-btn-primary {
  background: #0b67a3;
  color: #fff;
  border-color: #0b67a3;
}

.custom-datetime-picker .dtp-btn.dtp-btn-primary:hover {
  background: #1a8ccc;
  border-color: #1a8ccc;
}

.btn-query {
  padding: 6px 16px;
  background: #0b67a3;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.3s;
  white-space: nowrap;
}

.btn-query:hover {
  background: #1a8ccc;
}

.btn-refresh {
  padding: 6px 16px;
  background: #0b67a3;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.3s;
}

.btn-refresh:hover {
  background: #1a8ccc;
}

.select-limit {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
}

.select-limit:hover {
  border-color: #0b67a3;
}

.history-chart-container {
  margin-bottom: 16px;
  position: relative;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 16px;
}

.history-chart-container .chart-header {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-controls {
  display: flex;
  gap: 8px;
}

.btn-zoom {
  padding: 4px 12px;
  background: #0b67a3;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.btn-zoom:hover {
  background: #1a8ccc;
}

.btn-zoom:active {
  background: #0a5a8a;
}

.chart-wrapper {
  position: relative;
  overflow: hidden;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fafafa;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.chart-wrapper svg {
  display: block;
  width: 100%;
  height: 350px;
}

.chart-line {
  pointer-events: none; /* 让线条不阻挡拖动 */
}

.chart-point {
  pointer-events: none; /* 让点不阻挡拖动 */
}

.history-chart-container .chart-svg {
  width: 100%;
  height: 350px;
  display: block;
}

.chart-wrapper .chart-svg {
  border: none;
  background: transparent;
}

.chart-stats-overlay {
  position: absolute;
  top: 50px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 16px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e0e0e0;
  z-index: 10;
}

.stats-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #333;
}

.stats-text span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stats-text strong {
  color: #0b67a3;
  font-weight: 600;
  font-size: 14px;
}

.history-table-container {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fafafa;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.history-table thead {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, #0b67a3 0%, #1a8ccc 100%);
  color: #fff;
  z-index: 10;
}

.history-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
}

.history-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s;
}

.history-table tbody tr:hover {
  background: #f5f9fc;
}

.history-table tbody td {
  padding: 10px 16px;
  color: #333;
}

.history-table tbody td.temp-value {
  color: #ff6600;
  font-weight: 600;
  font-size: 15px;
}

.history-table tbody td.loading,
.history-table tbody td.error {
  text-align: center;
  color: #999;
  padding: 40px;
}

.history-table tbody td.error {
  color: #dc3545;
}

.history-empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 16px;
}

.history-empty p {
  margin: 0;
}

/* 响应式 */
@media (max-width: 900px) {
  .sidebar {
    width: 240px;
  }
  #map {
    left: 240px;
  }
  .infoBox {
    left: 260px;
  }
}

@media (max-width: 600px) {
  .topbar .top-inner { 
    flex-direction: column; 
    align-items: stretch; 
    gap: 8px; 
    padding: 8px;
    height: auto;
  }
  .controls { 
    justify-content: flex-start; 
    flex-wrap: wrap; 
  }
  main {
    margin-top: 80px;
  }
  .sidebar {
    display: none;
  }
  #map {
    left: 0;
  }
  .infoBox { 
    left: 8px; 
    right: 8px; 
    min-width: auto;
  }
}

/* 登录页背景 */
.login-page {
  background-image: url('../images/大楼外观照-摄影师发 (3).jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-page main {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}
