/* -- Reset & base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-alt: #0f3460;
  --text: #e0e0e0;
  --text-dim: #8899aa;
  --accent: #e94560;
  --accent-soft: #533483;
  --border: #2a2a4a;
  --success: #4ecca3;
  --warning: #f0a500;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* -- Dashboard grid (viewport) --------------------------------------------- */
.viewport .dashboard-grid {
  display: grid;
  height: 100vh;
  width: 100vw;
  padding: 16px;
  gap: 16px;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.widget-header h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

.widget-header .widget-time {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.widget-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.widget-body::-webkit-scrollbar { width: 4px; }
.widget-body::-webkit-scrollbar-track { background: transparent; }
.widget-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Widget spans */
.widget[data-span="2"] { grid-column: span 2; }
.widget[data-span="3"] { grid-column: span 3; }
.widget[data-span="full"] { grid-column: 1 / -1; }
.widget[data-rowspan="2"] { grid-row: span 2; }

/* -- Weather widget -------------------------------------------------------- */
.weather-current {
  text-align: center;
}
.weather-current .temp {
  font-size: 72px;
  font-weight: 300;
  line-height: 1;
}
.weather-current .condition {
  font-size: 18px;
  color: var(--text-dim);
  margin-top: 8px;
}
.weather-current .details {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-dim);
}

.weather-hourly {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.weather-hour {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 60px;
  font-size: 13px;
}
.weather-hour .hour-temp {
  font-size: 18px;
  font-weight: 500;
}

/* -- Calendar widget ------------------------------------------------------- */
.calendar-month {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 13px;
}
.calendar-month .day-header {
  text-align: center;
  font-weight: 600;
  color: var(--text-dim);
  padding: 4px;
  font-size: 11px;
  text-transform: uppercase;
}
.calendar-month .day {
  text-align: center;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: default;
}
.calendar-month .day.today {
  background: var(--accent);
  color: white;
  font-weight: 700;
}
.calendar-month .day.other-month {
  color: var(--border);
}
.calendar-month .day.has-event {
  border-bottom: 2px solid var(--accent-soft);
}

.calendar-week {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.calendar-week .week-day {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.calendar-week .week-day:last-child { border-bottom: none; }
.calendar-week .week-day-label {
  min-width: 60px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dim);
}
.calendar-week .week-day-label.today { color: var(--accent); }
.calendar-week .week-day-events {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calendar-event {
  font-size: 13px;
  padding: 4px 8px;
  background: var(--bg-card-alt);
  border-radius: 4px;
  border-left: 3px solid var(--accent-soft);
}
.calendar-event .event-time {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* -- Photo widget ---------------------------------------------------------- */
.photo-widget {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  flex: 1;
}
.photo-widget img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 1s ease;
}
.photo-widget img.photo-active {
  opacity: 1;
}
.photo-counter {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  font-family: var(--font-mono);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* -- Fortune widget -------------------------------------------------------- */
.fortune-widget {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  flex: 1;
  padding: 20px;
}
.fortune-widget .fortune-text {
  font-size: 20px;
  font-style: italic;
  line-height: 1.5;
  max-width: 500px;
}
.fortune-widget .fortune-author {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 14px;
}

/* -- Todo widget ----------------------------------------------------------- */
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.todo-item:last-child { border-bottom: none; }
.todo-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.todo-item.checked .todo-text {
  text-decoration: line-through;
  color: var(--text-dim);
}
.todo-text { flex: 1; }

/* -- Placeholder / error states -------------------------------------------- */
.widget-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  gap: 8px;
}
.widget-placeholder .hint {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--border);
}

/* -- Transition overlay ---------------------------------------------------- */
.transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}
.transition-overlay.active {
  opacity: 1;
}

/* -- Clock overlay --------------------------------------------------------- */
.clock-overlay {
  position: fixed;
  bottom: 16px;
  right: 24px;
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--text-dim);
  z-index: 10;
}
