/* ==================================
   全域設定與變數 (維持 V1 視覺)
   ================================== */
:root {
  --primary-color: #8c2121; 
  --secondary-color: #d4a373; 
  --bg-color: #f4f1ea; 
  --text-main: #333333;
  --text-muted: #666666;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(140, 33, 33, 0.05);
  --yi-color: #2b7a0b; 
  --ji-color: #c00000; 
  --error-color: #d32f2f;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Helvetica Neue", Helvetica, "PingFang TC", "LiHei Pro", "Hiragino Sans GB", "Microsoft JhengHei", sans-serif;
}

body {
  background-color: var(--bg-color);
  background-image: radial-gradient(circle at top right, #fdfbf7 0%, var(--bg-color) 100%);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  padding: 20px 10px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
}

/* ==================================
   標題與控制列
   ================================== */
header {
  text-align: center;
  margin-bottom: 24px;
}

header h1 {
  font-size: 2.2rem;
  color: var(--primary-color);
  margin-bottom: 8px;
  letter-spacing: 2px;
}

header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.control-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.control-bar button, .control-bar input {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.control-bar button:hover {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

.control-bar input[type="date"] {
  cursor: text;
  min-width: 150px;
}

/* ==================================
   主儀表板網格
   ================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr; 
  gap: 24px;
}

@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1fr; 
  }
}

.col-left, .col-right {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ==================================
   毛玻璃卡片
   ================================== */
.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--glass-shadow);
}

.card-title {
  font-size: 1.2rem;
  color: var(--primary-color);
  margin-bottom: 16px;
  border-bottom: 2px solid rgba(140, 33, 33, 0.1);
  padding-bottom: 8px;
}

/* ==================================
   農曆卡片與宜忌
   ================================== */
.date-header { text-align: center; margin-bottom: 20px; }
.solar-date { font-size: 1.8rem; font-weight: bold; }
.lunar-date { font-size: 1.3rem; color: var(--primary-color); font-weight: bold; margin-top: 5px; }

.weekday-badge {
  display: inline-block;
  background: var(--primary-color);
  color: #fff;
  font-size: 0.9rem;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 8px;
  vertical-align: middle;
}

.meta-details {
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 24px;
}

.meta-item { text-align: center; }
.meta-label { display: block; font-size: 0.85rem; color: var(--text-muted); }
.meta-value { font-weight: bold; font-size: 1.1rem; }

.yiji-container { display: flex; flex-direction: column; gap: 16px; }
.yiji-title { font-size: 1.1rem; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }

.yiji-badge-icon {
  color: #fff;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.9rem;
}

.yiji-title.yi .yiji-badge-icon { background: var(--yi-color); }
.yiji-title.ji .yiji-badge-icon { background: var(--ji-color); }

.badge-list { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}

.badge-yi { background: rgba(43, 122, 11, 0.1); color: var(--yi-color); border: 1px solid rgba(43, 122, 11, 0.2); }
.badge-ji { background: rgba(192, 0, 0, 0.1); color: var(--ji-color); border: 1px solid rgba(192, 0, 0, 0.2); }

/* ==================================
   運勢與方位小工具
   ================================== */
.fortune-selector { display: flex; gap: 10px; margin-bottom: 16px; }
.fortune-selector select { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid #ccc; }

.btn-primary {
  padding: 8px 16px;
  background: var(--secondary-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary:hover { background: #c49066; }

.fortune-section-title { font-weight: bold; margin: 12px 0 6px 0; color: var(--text-main); }
.fortune-positions {
  display: flex; justify-content: space-between;
  background: rgba(255, 255, 255, 0.5); padding: 12px;
  border-radius: 8px; text-align: center;
}
.pos-label { font-size: 0.85rem; color: var(--text-muted); }
.pos-val { font-weight: bold; color: var(--primary-color); }

/* ==================================
   節氣網格與提示
   ================================== */
.jieqi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
@media (max-width: 480px) { .jieqi-grid { grid-template-columns: repeat(3, 1fr); } }

.jieqi-item {
  background: rgba(255, 255, 255, 0.5); border: 1px solid rgba(0,0,0,0.05);
  border-radius: 8px; padding: 8px 4px; text-align: center; cursor: pointer;
  transition: all 0.2s; font-size: 0.9rem;
}
.jieqi-item:hover { background: var(--secondary-color); color: #fff; }
.jieqi-item strong { display: block; margin-bottom: 4px; }
.jieqi-item span { font-size: 0.8rem; opacity: 0.8; }

.jieqi-tip-box {
  display: flex; gap: 12px; background: rgba(212, 163, 115, 0.15);
  padding: 12px; border-radius: 8px; border-left: 4px solid var(--secondary-color);
}
.jieqi-tip-icon { font-size: 1.5rem; }
.jieqi-tip-content h4 { margin-bottom: 4px; color: #8a643b; }
.jieqi-tip-content p { font-size: 0.9rem; color: var(--text-main); margin: 0; }

/* ==================================
   月度篩選器
   ================================== */
.filter-controls { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-controls select, .filter-controls button { padding: 8px; border-radius: 8px; border: 1px solid #ccc; }
.filter-controls button { flex: 1; background: var(--primary-color); color: #fff; cursor: pointer; border: none; }
.filter-results-list {
  list-style: none; max-height: 250px; overflow-y: auto;
  background: rgba(255, 255, 255, 0.5); border-radius: 8px; padding: 8px;
}
.filter-results-list li { padding: 8px 12px; border-bottom: 1px solid rgba(0,0,0,0.05); display: flex; justify-content: space-between; }
.filter-results-list li:last-child { border-bottom: none; }
.no-results { color: var(--text-muted); text-align: center; padding: 16px !important; }

footer { text-align: center; margin-top: 40px; padding: 20px; color: var(--text-muted); font-size: 0.85rem; }

/* ==================================
   第三版新增組件樣式 (錯誤與說明框)
   ================================== */
.hidden { display: none !important; }

.error-toast {
  position: fixed; top: 20px; right: 20px; background: var(--error-color);
  color: white; padding: 16px 24px; border-radius: 8px;
  box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3); display: flex; align-items: center;
  gap: 16px; z-index: 1000; animation: slideIn 0.3s ease-out;
}
.error-close { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; }
@keyframes slideIn { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.loading-spinner {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.3); display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 999; backdrop-filter: blur(4px);
}
.spinner { width: 50px; height: 50px; border: 4px solid rgba(255, 255, 255, 0.3); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; }
.loading-spinner p { color: white; margin-top: 16px; font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

.tooltip-info {
  background: rgba(212, 163, 115, 0.15); border-left: 4px solid var(--secondary-color);
  border-radius: 8px; padding: 16px; margin-top: 16px; animation: slideDown 0.3s ease-out;
}
.tooltip-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#tooltip-title { font-weight: bold; color: #8a643b; font-size: 1.1rem; }
.tooltip-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #8a643b; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.btn-primary:active,
.btn-primary.btn-active {
  transform: translateY(0);
  animation: pulse 0.3s ease;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(212, 163, 115, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(212, 163, 115, 0); }
  100% { box-shadow: 0 0 0 0 rgba(212, 163, 115, 0); }
}