/* Basic reset */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root {
  --bg: #0d1117;
  --bg2: #060e20;
  --text: #dee5ff;
  --muted-text: #a3aac4;
  --surface: #0f1930;
  --surface-2: #091328;
  --border: #40485d;
  --header-bg: #192540;
  --header-text: #6bff8f;
  --primary-100: #0f1930;
  --primary-200: #192540;
  --primary-300: #40485d;
  --primary-600: #6bff8f;
  --primary: #6bff8f;
  --danger: #ff7351;
  --outside: #13171a;
  --outside2: #060a18;
  --outside-text: #474e55;
  --mark-emoji: "✗";
  --mark-color: #ff7351;
}
html, body { margin: 0; padding: 0; font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }

.container { max-width: 960px; margin: 0 auto; padding: 24px; position: relative; }

.calendar-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.month-year { font-family: 'Lexend', sans-serif; font-size: 1.75rem; font-weight: 900; margin: 0; text-transform: uppercase; letter-spacing: -0.02em; }

/* Header navigation controls */
.nav-controls { display: flex; align-items: center; gap: 8px; }
.nav-btn { appearance: none; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: 2px 10px; border-radius: 8px; height: 28px; line-height: 22px; font-size: 0.9rem; font-weight: 700; cursor: pointer; transition: background 0.2s; }
.nav-btn:hover { background: var(--surface); }
.nav-btn:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.today-btn { font-family: 'Lexend', sans-serif; background: var(--primary); color: #005f28; font-weight: 700; text-transform: uppercase; border-color: var(--primary); }
.today-btn:hover { background: var(--primary); box-shadow: 0 0 20px rgba(107, 255, 143, 0.3); }

/* Hamburger menu button */
.menu-btn { position: absolute; left: 12px; top: 12px; z-index: 30; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 2px 4px; font-weight: 800; font-size: 1.25rem; cursor: pointer; transition: background 0.2s; }
.menu-btn:hover { background: var(--surface-2); }

/* Side drawer */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); z-index: 40; }
.side-menu { position: fixed; top: 0; left: 0; height: 100vh; width: 280px; background: var(--surface); border-right: 1px solid var(--border); box-shadow: 2px 0 12px rgba(0, 0, 0, 0.5); transform: translateX(-105%); transition: transform 180ms ease-out; z-index: 50; display: flex; flex-direction: column; }
.side-menu.open { transform: translateX(0); }
.side-menu-header { display: flex; align-items: center; justify-content: center; padding: 16px; }
.side-menu-header h3 { font-size: 1.4em; }
.icon-btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; height: 28px; width: 28px; font-weight: 800; cursor: pointer; position: absolute; right: 16px; transition: background 0.2s; }
.icon-btn { font-size: 1.0rem; }
.icon-btn:hover { background: var(--surface); }
.side-menu-actions { padding: 0px 16px 22px 16px; text-align: center; }
.primary-btn { appearance: none; border: 1px solid var(--primary); background: var(--primary); color: #005f28; padding: 6px 10px; border-radius: 8px; font-weight: 700; cursor: pointer; transition: box-shadow 0.2s; }
.side-menu .primary-btn { font-size: 1.0rem; }
.primary-btn:hover { box-shadow: 0 0 20px rgba(107, 255, 143, 0.3); }
.secondary-btn { appearance: none; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: 6px 10px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.secondary-btn:hover { background: var(--surface); }
.calendar-list { list-style: none; margin: 0; padding: 8px; overflow: auto; }
.calendar-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-radius: 8px; }
.calendar-item.active { background: var(--primary-100); }
.calendar-switch { background: transparent; border: none; color: var(--text); font-weight: 600; cursor: pointer; text-align: left; flex: 1; }
.calendar-switch { font-size: 1.1rem; }
.calendar-delete { margin-left: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--danger); border-radius: 6px; padding: 2px 6px; cursor: pointer; transition: background 0.2s; }
.calendar-delete:hover { background: #450900; border-color: var(--danger); }

/* Modal */
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); z-index: 60; }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; width: min(92vw, 420px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5); }
.modal-label { display: block; margin: 8px 0 6px; font-weight: 600; color: var(--muted-text); }
.modal-input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; background: var(--surface-2); color: var(--text); }
.modal-fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 12px 0; }
.modal-fieldset legend { padding: 0 8px; font-weight: 600; color: var(--muted-text); }
.emoji-options { display: flex; gap: 12px; margin-top: 8px; }
.emoji-option { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.emoji-option input[type="radio"] { margin: 0; }
.emoji-display { font-size: 1.5em; font-weight: bold; }
/* Color the emoji symbols in edit dialog to match calendar colors */
#emojiRed + .emoji-display { color: #ff7351; }
#emojiGreen + .emoji-display { color: #6bff8f; }
#emojiCounter + .emoji-display { color: #7fc2ff; }
/* Color the emoji symbols in create dialog to match edit dialog colors */
#newEmojiRed + .emoji-display { color: #ff7351; }
#newEmojiGreen + .emoji-display { color: #6bff8f; }
#newEmojiCounter + .emoji-display { color: #7fc2ff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* CSS for styling the buttons and SVG icons */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background-color: var(--surface-2);
  cursor: pointer;
  margin: 0 2px;
  transition: all 0.2s ease;
}

.icon-button:hover {
  background-color: var(--surface);
  border-color: var(--muted-text);
}

.icon-button svg {
  width: 28px;
  height: 28px;
  stroke: var(--muted-text);
  stroke-width: 2;
  fill: none;
}

.icon-button.delete:hover {
  border-color: var(--danger);
}

.icon-button.delete:hover svg {
  stroke: var(--danger);
}

.icon-button.edit:hover {
  border-color: var(--primary);
}

.icon-button.edit:hover svg {
  stroke: var(--primary);
}

/* Month/Year emphasis */
.month-year .month { font-weight: 900; }
.month-year .year { font-weight: 400; color: var(--primary); margin-left: 6px; }

.calendar { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }

/* Weekday header cells */
.weekday { font-family: 'Lexend', sans-serif; height: 24px; line-height: 22px; padding: 0 6px; text-align: center; font-size: 0.9rem; font-weight: 900; color: var(--muted-text); background: var(--header-bg); border-bottom: 1px solid var(--border); text-transform: uppercase; }
.weekday + .weekday { border-left: 1px solid var(--border); }
.weekday:first-child { border-top-left-radius: 12px; }
.weekday:nth-child(7) { border-top-right-radius: 12px; }

/* Days grid wrapper fills 6 rows x 7 cols */
.days { display: contents; }

/* Day cells */
.day { min-height: 88px; padding: 8px; border-top: 1px solid var(--border); border-left: 1px solid var(--border); position: relative; background: var(--surface-2); }
.day:nth-child(7n + 1) { border-left: none; }
.day:nth-child(36) { border-bottom-left-radius: 12px; }
.day:nth-child(42) { border-bottom-right-radius: 12px; }

.date-number { font-family: 'Lexend', sans-serif; font-size: 0.95rem; font-weight: 900; color: var(--text); background: transparent; }

/* Outside current month shading */
.day.outside { background: var(--outside); }
.day.outside .date-number { color: var(--outside-text); }

/* Today indicator: highlighted with green glow */
.day.today { background: var(--surface); outline: 2px solid rgba(107, 255, 143, 0.4); outline-offset: -2px; box-shadow: inset 0 0 40px rgba(107, 255, 143, 0.1); }
/* Focused day visible outline for keyboard navigation */
.day:focus { outline: 2px solid var(--primary); outline-offset: -2px; }

/* Marked day: symbol will be set dynamically by JavaScript with color styling */
.day.marked::after {
  content: var(--mark-emoji);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 64px;
  line-height: 1;
  pointer-events: none;
  color: var(--mark-color); /* Defaults to red X from :root */
}
/* Color for red X symbol */
.day.marked[data-symbol="✗"]::after { color: #ff7351; }
/* Color for green check symbol */
.day.marked[data-symbol="✓"]::after { color: #6bff8f; }

.counter-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: 'Lexend', sans-serif;
  font-size: 2.4rem;
  font-weight: 900;
  color: #7fc2ff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.counter-clear-btn {
  position: absolute;
  right: 6px;
  bottom: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 6px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.day.show-clear .counter-clear-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .container { padding: 12px; }
  .month-year { font-size: 1.35rem; }
  .tracker-title { font-size: 1.35rem; }
  .day { min-height: 72px; padding: 4px; }
  .day.marked::after { font-size: 36px; }
  .counter-value { font-size: 1.6rem; }
  .date-number { font-size: 0.8rem; }
}

/* Tracker header row */
.tracker-header { display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.title-picker { position: relative; }
.tracker-title-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 10px;
}
.tracker-title-btn:hover { border-color: var(--border); background: var(--surface-2); }
.tracker-title-btn:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.tracker-title-btn.single { cursor: default; }
.tracker-title-btn.single:hover { border-color: transparent; background: transparent; }
.tracker-title-caret { font-size: 0.95rem; color: var(--muted-text); }
.tracker-title-btn.single .tracker-title-caret { visibility: hidden; }
.tracker-title { font-family: 'Lexend', sans-serif; font-size: 1.75rem; font-weight: 900; color: var(--text); margin: 0; text-transform: uppercase; letter-spacing: -0.02em; }
.title-calendar-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  padding: 6px;
}
.title-calendar-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 900;
  font-size: 1.5rem;
}
.title-calendar-item:hover { background: var(--surface-2); }
.title-calendar-item.active { background: var(--primary-100); color: var(--primary); }
