/* =============================
   component.css
   按钮、卡片、标题等组件样式
   ============================= */

/* 标题和更多按钮的容器 */
.header-with-more {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.more-btn {
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid #dadce0;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  color: #5f6368;
}

.more-btn:hover {
  background: #f8f9fa;
  border-color: #c4c7c5;
}

/* 弹窗样式 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow-y: auto;  /* 允许弹窗内容滚动 */
}

/* 拖动时的样式 */
.modal-header:active {
  cursor: grabbing;
}

.modal-content {
  position: relative;
  background: #fff;
  margin: 5vh auto;
  padding: 24px;
  width: 90%;
  max-width: 1400px;  /* 增加最大宽度，让4列布局更舒适 */
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  max-height: 90vh;      /* 限制最大高度 */
  overflow-y: auto;      /* 内容过多时允许滚动 */
  transition: transform 0.1s ease-out; /* 拖动时的平滑过渡 */
}

/* 响应式：小窗口时调整弹窗尺寸 */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    padding: 16px;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .modal-content {
    width: 100%;
    margin: 0;
    padding: 12px;
    border-radius: 0;
    max-height: 100vh;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  user-select: none; /* 标题栏不允许选中，用于拖动 */
}

/* 弹窗内容区域允许文本选择 */
.modal-body {
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.close-btn {
  border: none;
  background: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 8px;
  color: #5f6368;
}

.close-btn:hover {
  color: #202124;
}

/* 暗色主题适配 */
body.dark .more-btn {
  background: #2a2b31;
  border-color: #444;
  color: #ddd;
}

body.dark .more-btn:hover {
  background: #3a3b41;
}

body.dark .modal-content {
  background: #1e1f24;
}

body.dark .close-btn {
  color: #ddd;
}

body.dark .close-btn:hover {
  color: #fff;
}

/* 图表弹窗样式 */
.chart-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  overflow: hidden;
}

.chart-modal-content {
  position: relative;
  background: #fff;
  margin: 5vh auto;
  padding: 24px;
  width: 90%;
  max-width: 900px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.chart-modal-title {
  margin: 0;
  font-size: 1.2rem;
  color: #202124;
}

.chart-modal-close {
  border: none;
  background: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 8px;
  color: #5f6368;
}

.chart-modal-close:hover {
  color: #202124;
}

.chart-time-range {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.chart-time-btn {
  padding: 6px 16px;
  border-radius: 4px;
  border: 1px solid #dadce0;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  color: #5f6368;
  transition: all 0.2s ease;
}

.chart-time-btn:hover {
  background: #f8f9fa;
  border-color: #c4c7c5;
}

.chart-time-btn.active {
  background: #0078d7;
  border-color: #0078d7;
  color: #fff;
}

.chart-container {
  position: relative;
  flex: 1;
  min-height: 400px;
  height: 400px;
  background: #f8f9fa;
  border-radius: 4px;
  padding: 12px;
  box-sizing: border-box;
}

.chart-canvas {
  display: block;
}

.chart-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #5f6368;
  border-radius: 4px;
}

/* 暗色主题适配 - 图表弹窗 */
body.dark .chart-modal-content {
  background: #1e1f24;
}

body.dark .chart-modal-title {
  color: #e8eaed;
}

body.dark .chart-modal-close {
  color: #ddd;
}

body.dark .chart-modal-close:hover {
  color: #fff;
}

body.dark .chart-time-btn {
  background: #2a2b31;
  border-color: #444;
  color: #ddd;
}

body.dark .chart-time-btn:hover {
  background: #3a3b41;
}

body.dark .chart-time-btn.active {
  background: #0078d7;
  border-color: #0078d7;
  color: #fff;
}

body.dark .chart-container {
  background: #2a2b31;
}

body.dark .chart-loading {
  background: rgba(30, 31, 36, 0.9);
  color: #ddd;
}

/* 响应式 - 图表弹窗 */
@media (max-width: 768px) {
  .chart-modal-content {
    width: 95%;
    padding: 16px;
  }

  .chart-container {
    min-height: 250px;
  }
}

@media (max-width: 480px) {
  .chart-modal-content {
    width: 100%;
    margin: 0;
    padding: 12px;
    border-radius: 0;
    max-height: 100vh;
  }

  .chart-time-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  .chart-container {
    min-height: 200px;
  }
}

/* 为弹窗和按钮添加平滑过渡 */
.more-btn {
  transition: background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.6s cubic-bezier(0.4, 0, 0.2, 1), color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: background-color, border-color, color;
}

.modal-content {
  transition: background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: background-color;
}

.close-btn {
  transition: color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: color;
}

/* 页面主标题 */
h1 {
  margin-top: 70px;
  font-size: 1.4rem;
  transition: color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: color;
}
/* 容器固定在右上角 */
#topRightBtns {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px; /* 按钮间距 */
  z-index: 1001; /* 确保在弹窗之上，以便在弹窗打开时也能切换主题 */
}

/* 按钮通用样式 */
#topRightBtns button {
  background: #0078d7;
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

#topRightBtns button:hover {
  background: #005fa3;
}
#refreshBar {
  margin: 10px auto;
  display: flex;
  justify-content: center;
  gap: 10px;
  align-items: center;
}
#refreshBtn {
  background: #0078d7;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease;
}
#refreshBtn:hover {
  background: #0064b0;
}
#lastUpdate, #countdown {
  font-size: 0.9rem;
  color: #5f6368;
  margin: 5px 0;
  transition: color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: color;
}
.card {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 14px 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 90px;
  will-change: background-color;
  user-select: text; /* 允许卡片内的文本选择 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}
.card:not(.placeholder):hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1);
}
.card .name {
  font-size: 0.9rem;
  color: #3c4043;
  font-weight: 500;
  margin-bottom: 6px;
  user-select: text; /* 允许名称文本选择 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  cursor: text; /* 显示文本光标 */
}
.card .price {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.card .change {
  font-size: 0.85rem;
  font-weight: 500;
}
.price.up, .change.up { color: #d93025; }
.price.down, .change.down { color: #137333; }
.card.placeholder {
  background: transparent;
  border: 2px dashed rgba(0, 0, 0, 0.1);
  box-shadow: none;
  visibility: visible;
  opacity: 0.3;
  pointer-events: none;
}
body.dark .card.placeholder {
  border-color: rgba(255, 255, 255, 0.1);
}
