/* 月曆版專屬樣式 (index.css) */

:root {
  --primary-light: #e8f0fe;
  --holiday-bg: #ffebee;
  --workday: #2e7d32;
  --workday-bg: #e8f5e9;
  --weekend-tag: #78909c;
  --weekend-tag-bg: #eceff1;
  --adjusted: #6a1b9a;
  --adjusted-bg: #f3e5f5;
  --special: #ef6c00;
  --special-bg: #fff3e0;
  --today: #1565c0;
  --today-bg: #e3f2fd;
}

[data-theme="dark"] {
  --primary-light: #1a73e8;
  --holiday-bg: #3d2b2b;
  --workday: #81c995;
  --workday-bg: #1e3a2f;
  --weekend-tag: #90a4ae;
  --weekend-tag-bg: #2d2e30;
  --adjusted: #b39ddb;
  --adjusted-bg: #2d1b4e;
  --special: #ffb74d;
  --special-bg: #3d2b1f;
  --today: #64b5f6;
  --today-bg: #1a3a5c;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  background: var(--bg);
  min-height: 100vh;
  border-radius: 8px;
  transition: background 0.3s ease;
}

/* 頁首標題與導航 */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  border-radius: 8px;
  padding: 16px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.header h1 {
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  flex: 1;
}

.header h1 span {
  font-size: 14px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 12px;
  margin-left: 8px;
}

/* 控制按鈕區 */
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.3s ease;
}

.nav-btn:hover {
  background: var(--weekend);
  transition: background 0.3s ease;
}

.nav-btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.nav-btn.primary:hover {
  background: var(--primary-hover);
}

select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s ease;
}

/* 黑色模式切換按鈕 */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 18px;
  color: var(--text);
  transition: background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
}

.theme-toggle:hover {
  background: var(--weekend);
  transition: background 0.3s ease;
}

.theme-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 右上角切換連結 */
.nav-links {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.nav-link {
  text-decoration: none;
  color: var(--primary);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background 0.3s ease;
}

.nav-link:hover {
  background: var(--primary-light);
  transition: background 0.3s ease;
}

/* 月曆主體 */
.calendar {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--calendar-bg);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--weekend);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease;
}

.calendar-header div {
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  text-transform: uppercase;
}

.calendar-header div:first-child,
.calendar-header div:last-child {
  color: var(--holiday);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  height: auto;
  min-height: 480px;
  transition: background 0.3s ease;
}

.calendar-grid.weeks-5 { grid-template-rows: repeat(5, 1fr); }
.calendar-grid.weeks-6 { grid-template-rows: repeat(6, 1fr); }

.day-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px;
  position: relative;
  cursor: default;
  overflow: hidden;
  min-height: 100px;
  background: var(--day-bg);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.day-cell:nth-child(7n) { border-right: none; }
.day-cell.other-month { background: var(--day-hover); }
.day-cell.other-month .day-number { color: var(--text-light); }
.day-cell.weekend { background: var(--weekend); }
.day-cell.today .day-number {
  background: var(--today);
  color: #fff;
}

.day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 50%;
  margin-bottom: 2px;
}

.day-events {
  font-size: 12px;
  line-height: 1.4;
}

.event {
  padding: 2px 4px;
  border-radius: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.3s ease, color 0.3s ease;
}

.event.holiday { background: var(--holiday-bg); color: var(--holiday); }
.event.workday { background: var(--workday-bg); color: var(--workday); }
.event.weekend { background: transparent; color: var(--text-light); font-weight: 400; }
.event.weekend-special { background: var(--special-bg); color: var(--special); border: 1px dashed var(--special); font-weight: 500; }
.event.adjusted { background: var(--adjusted-bg); color: var(--adjusted); }
.event.special { background: var(--special-bg); color: var(--special); }

/* 圖例說明 */
.legend {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  padding: 12px;
  background: var(--weekend);
  border-radius: 8px;
  flex-wrap: wrap;
  transition: background 0.3s ease;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-light);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.footer {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--text-light);
}

/* Dashboard Styles */
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
  animation: fadeIn 0.5s ease-in;
}

.dashboard-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 2px var(--shadow);
  transition: transform 0.3s ease, background 0.3s ease;
  min-height: 60px;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-icon {
  font-size: 18px;
  background: var(--weekend);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background 0.3s ease;
}

.card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-title {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 2px;
  font-weight: 500;
  line-height: 1;
}

.card-desc {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  line-height: 1.2;
}

.card-desc span.highlight {
  color: var(--primary);
  font-size: 15px;
  margin: 0 2px;
}

.progress-container {
  height: 4px;
  background: var(--weekend);
  border-radius: 2px;
  overflow: hidden;
  margin: 4px 0;
  transition: background 0.3s ease;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #4285f4);
  border-radius: 4px;
  transition: width 1s ease-out, background 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 768px) {
  .day-cell { min-height: 60px; }
  .day-number { width: 24px; height: 24px; font-size: 12px; }
  .header h1 { font-size: 18px; }
}
