/* ==========================================================================
   Wallmonitor Dashboard Stylesheet
   - Compact 24h Weather Line Graph
   - Two Stacked Calendar Weeks (One over the other, cropped to events)
   - Open Tasks, Shopping List & Wall Note
   ========================================================================== */

:root {
  --bg-color: #0b0e14;
  --card-bg: #131722;
  --card-border: #1f2738;
  --grid-border: rgba(255, 255, 255, 0.07);
  --grid-border-heavy: rgba(255, 255, 255, 0.14);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-light: #38bdf8;
  --accent-rgb: 56, 189, 248;
  --today-blue: #38bdf8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --now-indicator: #ef4444;
  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(circle at 10% 8%, rgba(var(--accent-rgb, 56, 189, 248), 0.12) 0%, transparent 45%),
    radial-gradient(circle at 92% 92%, rgba(var(--accent-rgb, 56, 189, 248), 0.08) 0%, transparent 40%);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow: hidden !important;
  user-select: none;
  -webkit-user-select: none;
}

/* Dimming Overlay */
.dim-overlay {
  position: fixed;
  inset: 0;
  background-color: #000000;
  pointer-events: none;
  z-index: 999999;
  opacity: 0;
  transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Main Container: Strict 100vh No Scrolling Fit */
.dashboard-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  padding: 0.45rem 0.65rem;
  gap: 0.45rem;
  box-sizing: border-box;
  overflow: hidden;
}

/* ==========================================================================
   Header Bar
   ========================================================================== */
.dashboard-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  gap: 0.75rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 15px rgba(var(--accent-rgb, 56, 189, 248), 0.08);
}

.header-clock-section {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
}

.digital-clock {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.clock-seconds {
  color: var(--accent);
  font-size: 1.15rem;
  margin-left: 1px;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(var(--accent-rgb, 56, 189, 248), 0.6);
}

.digital-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-weight: 600;
}

.sync-status .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.sync-status.reconnecting {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.3);
}

.sync-status.reconnecting .status-dot {
  background: var(--warning);
  animation: pulse-dot 1.2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: var(--accent);
}

/* ==========================================================================
   Compact 24h Weather Line Graph Card
   ========================================================================== */
.weather-compact-card {
  flex-shrink: 0;
  padding: 0.3rem 0.65rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.weather-compact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.weather-compact-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
}

.weather-location {
  font-weight: 700;
  color: var(--text-main);
}

.weather-temp-now {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(var(--accent-rgb, 56, 189, 248), 0.5);
}

.weather-desc {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.weather-rain-summary {
  font-size: 0.74rem;
  color: var(--accent-light);
  font-weight: 600;
  background: rgba(var(--accent-rgb, 56, 189, 248), 0.14);
  border: 1px solid rgba(var(--accent-rgb, 56, 189, 248), 0.25);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}

.weather-legend {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.legend-line.temp-line {
  width: 12px;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent);
  border-radius: 2px;
}

.legend-bar.rain-bar {
  width: 8px;
  height: 8px;
  background: rgba(var(--accent-rgb, 56, 189, 248), 0.6);
  border-radius: 2px;
}

.weather-canvas-wrap {
  width: 100%;
  height: 48px;
  position: relative;
}

#weather-graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   Main Workspace Layout: Strict Viewport Height Fit (No Page Scrolling)
   ========================================================================== */
.dashboard-main-layout {
  display: grid;
  grid-template-columns: 2.3fr 1fr;
  gap: 0.45rem;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* TWO Stacked Calendar Weeks */
.calendar-stacked-section {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.calendar-weeks-container {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.week-block-card {
  flex: 1;
  min-height: 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.week-block-header-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.6rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--grid-border-heavy);
  border-left: 3px solid var(--accent);
}

.week-block-title {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(var(--accent-rgb, 56, 189, 248), 0.4);
}

.week-block-range {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* 7-Day Day Labels */
.week-days-header-row {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 46px 1fr;
  background: #10141e;
  border-bottom: 1px solid var(--grid-border-heavy);
}

.cal-tz-box {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-dim);
  border-right: 1px solid var(--grid-border-heavy);
  font-family: var(--font-mono);
}

.cal-days-cols {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.1rem;
  border-right: 1px solid var(--grid-border);
  gap: 0.1rem;
}

.cal-day-cell:last-child {
  border-right: none;
}

.cal-day-name {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.cal-day-num {
  font-size: 0.88rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-main);
}

.cal-day-cell.today .cal-day-name {
  color: var(--accent);
}

.cal-day-cell.today .cal-day-num {
  background-color: var(--accent);
  color: #090b10;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(var(--accent-rgb, 56, 189, 248), 0.8);
}

/* All-Day Events Strip: High Contrast & Sleek */
.week-allday-row {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 46px 1fr;
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--grid-border-heavy);
  min-height: 20px;
}

.week-allday-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  color: var(--text-dim);
  border-right: 1px solid var(--grid-border-heavy);
  text-transform: uppercase;
}

.week-allday-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 1px 2px;
  gap: 2px;
}

.week-allday-col {
  border-right: 1px solid var(--grid-border);
  padding: 1px 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.week-allday-col:last-child {
  border-right: none;
}

.allday-pill {
  font-size: 0.64rem;
  font-weight: 600;
  color: #ffffff;
  border-radius: 3px;
  padding: 1px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left-width: 3px;
  border-left-style: solid;
  border-left-color: var(--accent);
  display: flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.allday-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.allday-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cropped Timetable Body (Dynamically fills flex space, zero scrolling) */
.week-timetable-body {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: 46px 1fr;
  position: relative;
  background: #0d1018;
  overflow: hidden;
}

.cal-time-axis {
  position: relative;
  height: 100%;
  border-right: 1px solid var(--grid-border-heavy);
  background: #0f131d;
  overflow: hidden;
}

.cal-time-mark {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 500;
  color: var(--text-dim);
  transform: translateY(-50%);
  pointer-events: none;
}

.cal-grid-area {
  position: relative;
  height: 100%;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  overflow: hidden;
}

.cal-grid-day-col {
  border-right: 1px solid var(--grid-border);
  position: relative;
  height: 100%;
  overflow: hidden;
}

.cal-grid-day-col:last-child {
  border-right: none;
}

.cal-grid-day-col.today {
  background: linear-gradient(180deg, rgba(var(--accent-rgb, 56, 189, 248), 0.12) 0%, rgba(var(--accent-rgb, 56, 189, 248), 0.02) 100%);
  border-left: 1px solid rgba(var(--accent-rgb, 56, 189, 248), 0.35);
  border-right: 1px solid rgba(var(--accent-rgb, 56, 189, 248), 0.35);
}

.cal-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--grid-border);
  pointer-events: none;
}

/* Red / Accent Time Indicator */
.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  z-index: 10;
  pointer-events: none;
}

.now-dot {
  position: absolute;
  left: -3px;
  top: -2.5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Event Block: Ultra-readable, high-contrast dark card with colored left accent bar */
.event-block {
  position: absolute;
  left: 2px;
  right: 2px;
  min-height: 20px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left-width: 3.5px;
  border-left-style: solid;
  border-left-color: var(--accent);
  color: #ffffff;
  padding: 1px 4px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.15s ease, z-index 0.15s ease, box-shadow 0.15s ease;
}

.event-block:hover {
  transform: scale(1.02);
  z-index: 20;
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}

/* Compact Events: Single Row, 100% Readable */
.event-block.is-compact {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  line-height: 1;
}

.event-time-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.event-title-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Expanded Events: Two Rows */
.event-block.is-expanded {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  line-height: 1.15;
}

.event-block-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-block-time {
  font-size: 0.64rem;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
  color: var(--accent);
}

/* ==========================================================================
   Sidebar: Tasks, Shopping, Note
   ========================================================================== */
.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.tasks-card {
  flex: 1.15;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.shopping-card {
  flex: 1.15;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.note-card {
  flex: 0.9;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.card-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--card-border);
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.card-title-group svg {
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(var(--accent-rgb, 56, 189, 248), 0.4));
}

.card-title-group h2 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.48rem;
  border-radius: 9999px;
  background: rgba(var(--accent-rgb, 56, 189, 248), 0.14);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb, 56, 189, 248), 0.35);
}

.card-content {
  flex: 1;
  min-height: 0;
  padding: 0.35rem 0.65rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.scroll-container::-webkit-scrollbar,
.calendar-stacked-section::-webkit-scrollbar {
  width: 4px;
}

.scroll-container::-webkit-scrollbar-thumb,
.calendar-stacked-section::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: 3px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-style: italic;
  text-align: center;
  padding: 0.85rem;
}

/* Item List */
.item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.42rem 0.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
  cursor: pointer;
}

.item-row:hover {
  background: rgba(var(--accent-rgb, 56, 189, 248), 0.06);
}

.item-row.completing {
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
}

.custom-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(var(--accent-rgb, 56, 189, 248), 0.55);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: transparent;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.custom-checkbox:hover {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb, 56, 189, 248), 0.4);
}

.custom-checkbox:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb, 56, 189, 248), 0.7);
}

.custom-checkbox:checked::after {
  content: "";
  display: block;
  width: 4px;
  height: 8px;
  border: solid #090b10;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: hidden;
}

.item-title {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.25;
  word-break: break-word;
}

.item-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.note-card {
  border-left: 3.5px solid var(--accent);
}

.note-body {
  font-size: 0.88rem;
  line-height: 1.45;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   Floating Undo Toast (Bottom Right)
   ========================================================================== */
.undo-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #131722;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.65), 0 0 15px rgba(var(--accent-rgb, 56, 189, 248), 0.15);
  padding: 0.55rem 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  z-index: 100000;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  overflow: hidden;
}

.undo-toast.hidden {
  opacity: 0;
  transform: translateY(18px) scale(0.95);
  pointer-events: none;
}

.undo-content {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.undo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  background: var(--accent);
  color: #090b10;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 50%;
  flex-shrink: 0;
}

.undo-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: #f8fafc;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.undo-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent);
  color: #090b10;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(var(--accent-rgb, 56, 189, 248), 0.35);
}

.undo-action-btn:hover {
  filter: brightness(1.15);
}

.undo-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  width: 100%;
  transform-origin: left;
}

.undo-toast:not(.hidden) .undo-progress-bar {
  animation: undo-bar 6s linear forwards;
}

@keyframes undo-bar {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

