/* ===== Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@1,400;1,500&family=Noto+Color+Emoji&display=swap');

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

:root,
:root[data-theme="dark"] {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface-2:    #21262d;
  --border:       #30363d;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --accent:       #58a6ff;
  --today-bg:     #1a2d42;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';
}

:root[data-theme="light"] {
  --bg:           #ffffff;
  --surface:      #f6f8fa;
  --surface-2:    #eaeef2;
  --border:       #d0d7de;
  --text:         #1f2328;
  --text-muted:   #57606a;
  --accent:       #0969da;
  --today-bg:     #ddf4ff;
}

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

/* ===== Root layout (left panel + calendar side by side) ===== */
#root {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Left Panel ===== */
#left-panel {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 18px;
  background: url('bg-panel.jpg') center center / cover no-repeat;
  border-right: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

#left-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

#left-panel > * {
  position: relative;
}

#left-panel,
#left-panel * {
  color: inherit;
}

#left-panel {
  color: #ffffff;
}

#panel-clock {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.01);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255,255,255,0.22);
}

#panel-time {
  font-size: 4.2rem;
  font-weight: 200;
  letter-spacing: -0.02em;
  line-height: 1;
}

#panel-date {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 6px;
}

.panel-spacer {
  flex: 1;
}

.panel-card {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.01);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 14px 16px;
  margin-top: 12px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255,255,255,0.22);
}


/* Weather card */
.weather-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.weather-temp {
  font-size: 2rem;
  font-weight: 300;
  flex-shrink: 0;
}

.weather-condition {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

/* Twemoji SVG images — ensures emoji scale with surrounding text */
img.emoji {
  height: 1em;
  width: 1em;
  vertical-align: -0.15em;
  display: inline-block;
}

.weather-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.weather-label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.65);
}

.weather-hl {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
}

.weather-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0 8px;
  opacity: 0.5;
}

.weather-forecast {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.forecast-day {
  display: flex;
  align-items: center;
  gap: 8px;
}

.forecast-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  width: 2.8em;
  flex-shrink: 0;
}

.forecast-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  margin-right: 6px;
}

.forecast-low {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 4em;
  flex-shrink: 0;
}

.forecast-high {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Tasks card */
.panel-section-title {
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 10px;
}

#panel-tasks-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 340px;
  overflow-y: auto;
}

.task-item {
  padding-left: 14px;
  position: relative;
}

.task-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}

.task-name {
  font-size: 0.85em;
  line-height: 1.3;
}

#left-panel .task-due {
  display: inline-block;
  font-size: 0.72em;
  font-weight: 500;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 5px;
  vertical-align: middle;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.45);
}

#left-panel .task-overdue {
  background: rgba(255, 200, 0, 0.55);
  color: #7a4f00;
}

/* Quote */
#panel-quote {
  margin-top: auto;
  padding-top: 20px;
}

.quote-text {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.1rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.70);
}

.quote-author {
  margin-top: 6px;
  font-family: Georgia;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.38);
  text-align: right;
}

/* ===== App Shell ===== */
#app {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Header ===== */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#month-label {
  font-size: 1.25rem;
  font-weight: 600;
}

#header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

#settings-btn,
#reload-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

#settings-btn:hover,
#reload-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* ===== Status Bar ===== */
#status-bar {
  display: flex;
  justify-content: space-between;
  padding: 3px 16px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===== Calendar Grid ===== */
#calendar-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 14px; /* JS-controlled base; children use em so they scale with it */
}

/* Day-of-week header row */
.grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-cell {
  padding: 5px 8px;
  text-align: center;
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}


/* Grid body contains all week rows */
.grid-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex: 1;
  border-bottom: 1px solid var(--border);
  min-height: 0;
}

.grid-row:last-child {
  border-bottom: none;
}

/* ===== Day Cells ===== */
.day-cell {
  padding: 3px 5px 4px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

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

.day-cell.today {
  background: var(--today-bg);
}

.day-cell.past .event-chip {
  opacity: 0.30;
}

.date-number {
  font-size: 0.78em;
  font-weight: 500;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  line-height: 1;
}


.day-cell.today .date-number {
  background: var(--accent);
  color: #0d1117;
  font-weight: 700;
}

.day-cell.today.sunday .date-number {
  background: var(--sunday-color);
  color: #0d1117;
}

/* ===== Event Chips ===== */
.event-chip {
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.72em;
  line-height: 1.45;
  overflow: hidden;
  flex-shrink: 0;
  cursor: default;
}

.event-chip.all-day {
  font-weight: 500;
}

.event-chip.timed {
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.event-time {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.85em;
  padding: 0px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.28);
}

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

.evening-spacer {
  flex: 1;
  min-height: 0;
}

.overflow-indicator {
  font-size: 0.67em;
  color: var(--text-muted);
  padding: 1px 5px;
  cursor: default;
  flex-shrink: 0;
}

/* ===== Auth / Error States ===== */
.auth-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 1em;
  text-align: center;
  padding: 2rem;
}

/* ===== Settings Overlay ===== */
#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
}

/* ===== Settings Panel ===== */
#settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 11;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

#settings-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}

#settings-close:hover {
  color: var(--text);
}

.settings-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.coming-soon {
  font-size: 0.65rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  font-weight: 400;
}

.field-group {
  margin-bottom: 10px;
}

.field-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.field-group input {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
  font-family: monospace;
  outline: none;
  transition: border-color 0.15s;
}

.field-group input:focus {
  border-color: var(--accent);
}

.field-group input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#connect-btn {
  width: 100%;
  padding: 9px 14px;
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

#connect-btn:hover {
  opacity: 0.88;
}

#connect-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-message {
  margin-top: 8px;
  font-size: 0.78rem;
  min-height: 1.2em;
}

.settings-message.success { color: #56d364; }
.settings-message.error   { color: #f85149; }

.settings-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===== City Autocomplete ===== */
.city-autocomplete {
  margin-top: 8px;
  position: relative;
}

#city-search {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

#city-search:focus {
  border-color: var(--accent);
}

#city-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  list-style: none;
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

#city-suggestions li {
  padding: 8px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.1s;
}

#city-suggestions li:hover,
#city-suggestions li.active {
  background: var(--surface-2);
  color: var(--accent);
}

/* ===== Calendar Toggles ===== */
.calendar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

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

.calendar-name {
  flex: 1;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-toggle {
  flex-shrink: 0;
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ===== Font Size Control ===== */
.font-size-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.font-size-control button {
  width: 30px;
  height: 30px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.font-size-control button:hover {
  background: var(--border);
}

#font-size-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 30px;
  text-align: center;
}

/* ===== Theme Radio Buttons ===== */
.theme-options {
  display: flex;
  gap: 6px;
}

.theme-option {
  flex: 1;
}

.theme-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-option label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
  width: 100%;
}

.theme-option label:hover {
  background: var(--surface-2);
}

.theme-option input[type="radio"]:checked + label {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.theme-hint {
  margin-top: 8px;
  font-size: 0.78rem;
}

/* ===== Settings select & secondary button ===== */
.settings-select {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
  appearance: none;
}

.settings-select:focus {
  border-color: var(--accent);
}


/* ===== Save Button ===== */
#save-btn {
  width: 100%;
  padding: 9px 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

#save-btn:hover {
  background: var(--border);
}

/* ===== Night Blackout ===== */
#blackout {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 20;
  cursor: pointer;
}

.blackout-enable {
  margin-bottom: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.blackout-times .time-row {
  display: flex;
  gap: 12px;
}

.blackout-times .field-group {
  flex: 1;
  margin-bottom: 0;
}

.blackout-times .field-group input {
  font-family: var(--font);
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Stock Widget ===== */
.stock-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#panel-stocks {
  padding: 6px 8px 6px 18px;
  overflow: hidden !important;
  font-size: 12px;
  --stock-widget-scale: 0.50;
}

.stock-tv-list {
  gap: 0.14em;
}

.stock-tv-row {
  display: flex;
  align-items: center;
  height: 1.8em !important;
  overflow: hidden !important;
}

.stock-tv-label {
  width: 4.1em;
  flex: 0 0 4.1em;
  overflow: hidden;
  font-size: 1.02em;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-tv-price-crop {
  flex: 1;
  height: 1.8em !important;
  overflow: hidden !important;
}

.stock-tv-price-crop iframe {
  display: block !important;
  width: 460px !important;
  height: 126px !important;
  margin-top: -23px;
  margin-left: -3px;
  transform: scale(var(--stock-widget-scale));
  transform-origin: top left;
}

.stock-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stock-symbol {
  font-size: 0.85em;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  width: 72px;
}

.stock-chart {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stock-sparkline {
  display: block;
}

.stock-price-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.stock-price {
  font-size: 0.85em;
  font-weight: 700;
  white-space: nowrap;
}

.stock-change {
  font-size: 0.7em;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.stock-pos {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
}

.stock-neg {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
}

/* ===== Stock Settings ===== */
.stock-add-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

#stock-search {
  flex: 1;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

#stock-search:focus {
  border-color: var(--accent);
}

#stock-add-btn {
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

#stock-add-btn:hover {
  opacity: 0.85;
}

#stock-add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stock-add-message {
  margin-top: 6px;
  min-height: 1.2em;
}

.stock-add-error {
  color: #f85149 !important;
}

.stock-settings-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.stock-settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.stock-settings-item > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.stock-settings-symbol {
  font-size: 0.82rem;
  font-weight: 700;
}

.stock-settings-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.stock-remove-btn:hover {
  color: #f87171;
}
