/* ===== Theme Variables ===== */
:root {
  --bg:#0a1124;
  --surface:#0f1b39;
  --text:#e6ecff;
  --muted:#8ea2c6;
  --accent:#3ea2ff;
  --selected:#3ea2ff;
  --border:rgba(255,255,255,0.14);
  --ring:rgba(62,162,255,0.25);
  --card:rgba(255,255,255,0.06);
  --date-size:14px;
}

html[data-theme="light"] {
  --bg:#e8e9ed;
  --surface:#ffffff;
  --text:#0b1321;
  --muted:#5b636e;
  --accent:#1e90ff;
  --selected:#1e90ff;
  --border:rgba(0,0,0,0.12);
  --ring:rgba(30,144,255,0.18);
  --card:#ffffff;
}

/* ===== Global ===== */
* { box-sizing:border-box; }
html, body { height:100%; margin:0; }

body {
  background:var(--bg);
  color:var(--text);
  font-family: ui-sans-serif, system-ui;
}

/* ===== Text helpers ===== */
.muted { color:var(--muted); }
.small { font-size:13px; }

/* ===== Navbar ===== */
.navbar {
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:10px 16px;
  border-bottom:1px solid var(--border);
  background:var(--surface);
  position:sticky;
  top:0;
  z-index:10;
}

.navbar ul {
  display:flex;
  gap:12px;
  margin:0;
  padding:0;
  list-style:none;
}

.navbar a {
  padding:8px 10px;
  color:var(--text);
  text-decoration:none;
  border-radius:8px;
}

.navbar a:hover {
  border:1px solid var(--accent);
}

/* Theme toggle button */
.theme-btn {
  min-width:64px;
}

/* ===== Container ===== */
.container {
  max-width:1400px;
  margin:20px auto;
  padding:0 16px;
}

.view.hidden { display:none; }

/* ===== Panel ===== */
.panel {
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:16px;
}

.source-note {
  font-size: 0.75rem;
  line-height: 1.4;
  margin-top: 8px;
  color: var(--muted);
}

/* Weather source link - force same color in all states */
.source-note a,
.source-note a:visited {
  color: rgb(107, 160, 235) !important;
  text-decoration: underline;
}

.source-note a:hover {
  color: #c7d8f5 !important;
}

/* ===== Calendar Layout ===== */
.calendar-layout {
  display:grid;
  grid-template-columns:4fr 1fr;
  gap:20px;
  margin-top:20px;
}

/* ===== Card ===== */
.card {
  background:var(--card);
  border:1px solid var(--border);
  border-radius:20px;
  padding:20px;
}

/* ===== Calendar Header ===== */
.header {
  display:grid;
  grid-template-columns:1fr 1fr auto;
  align-items:center;
  gap:10px;
  margin-bottom:12px;
}

.calendar {
  display:grid;
  grid-template-rows:auto 1fr;
  gap:8px;
}

/* Generic hidden utility class */
.hidden {
  display: none !important;
}

/* 🔍 Calendar top search bar */
.calendar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
}

.calendar-search input {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

/* 🔍 Search results area: replaces the calendar grid */
.search-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 520px;
  overflow-y: auto;
}

/* Summary row shown above search results */
.search-summary {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

/* Single search result row (similar to Google Calendar list style) */
.search-row {
  display: grid;
  grid-template-columns: 2.5fr 2fr 6fr;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
}

.search-row:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--ring);
}

.search-date {
  font-weight: 600;
}

.search-time {
  color: var(--muted);
  font-size: 12px;
}

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

/* ===== Weekdays + Grid ===== */
.weekdays, .grid {
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:6px;
}

/* ===== Calendar Cell ===== */
.cell {
  height: 120px;         /* Fixed height to prevent layout shifts */
  border-radius: 14px;
  padding: 6px;
  border:1px solid var(--border);
  background: rgba(255,255,255,0.03);
  font-size: var(--date-size);

  display: flex;
  flex-direction: column;

  overflow: hidden;       /* Prevent content from stretching the cell */
}

.date-num {
  font-weight:600;
  margin-bottom:4px;
}

.cell:hover {
  background:rgba(255,255,255,0.1);
  border-color:var(--accent);
}

/* Highlight today's date */
.today {
  border-color:var(--accent);
  background:rgba(62,162,255,0.15);
}

/* Selected cell outline */
.selected {
  border-color:var(--selected);
  box-shadow:0 0 0 3px var(--ring);
}

/* ===== Tags Sidebar ===== */
.tag-sidebar h3 {
  margin:0 0 12px 0;
  font-size:16px;
}

.tag-list {
  list-style:none;
  padding:0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.tag-item label {
  display:flex;
  gap:8px;
}

/* Small inline layout helper (reusable) */
.inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Date range filter card in tag sidebar */
.date-filter-panel {
  margin-top: 14px;
  margin-bottom: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.date-filter-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* Date input layout */
.range-filter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-filter-wrap input[type="date"] {
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
}

/* Clear button */
.date-clear-btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
}

/* Dim cells that are outside the selected date range */
.cell.out-of-range {
  opacity: 0.35;
}

/* ===== Create Event Button ===== */
.add-event-btn {
  background:var(--accent);
  color:white;
  padding:8px 14px;
  border:none;
  border-radius:8px;
  cursor:pointer;
}

.add-event-btn:hover {
  background:#67b7ff;
  box-shadow:0 0 0 4px var(--ring);
}

/* ===== Modal ===== */
.modal-overlay {
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.55);
  display:flex;
  justify-content:center;
  align-items:center;
  z-index:200;
}

.modal-overlay.hidden { display:none; }

.modal {
  background:var(--surface);
  padding:20px;
  width:360px;
  border-radius:16px;
}

.modal-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
}

/* Icon-close buttons */
.icon-btn {
  background:transparent;
  border:none;
  color:var(--text);
  cursor:pointer;
  font-size:18px;
  padding:4px;
}

.field {
  display:flex;
  flex-direction:column;
  margin-bottom:12px;
}

.field-label {
  font-size:13px;
  color:var(--muted);
  margin-bottom:4px;
}

.primary-btn {
  width:100%;
  padding:10px;
  background:var(--accent);
  border:none;
  color:white;
  border-radius:8px;
}

/* Extra style for the detail modal */
.modal-detail {
  width: 420px;
  max-width: 90vw;
}

/* Rows inside the detail modal */
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0;
  font-size: 14px;
}

.detail-row .field-label {
  font-weight: 600;
  color: var(--muted);
}

.detail-description {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
}

.detail-description a {
  color: var(--accent);
  text-decoration: underline;
  word-break: break-all;
}

/* ===== Event detail: description block ===== */
#detailDescRow {
  white-space: normal;
}

#detailDesc {
  font-size: 13px;
  line-height: 1.4;
}

/* Place each link in the description on its own line for readability */
#detailDesc a {
  display: block;
  margin-top: 4px;
  text-decoration: underline;
  word-break: break-all;   /* Long URLs wrap automatically */
  font-size: 13px;
}

/* ===== Tableau Viewer ===== */
#view-tableau .tableauPlaceholder {
  display:block;
  margin:1.5rem auto;
}

.tableau-frame {
  margin-top:16px;
}

/* ===== Control Bar ===== */
.control-bar {
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.date-size-wrap {
  display:flex;
  align-items:center;
  gap:10px;
}

/* ===== Buttons (Today/Prev/Next/Theme) ===== */
button {
  background: rgb(248, 247, 247);
  color: black;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  cursor:pointer;
  font-size:14px;
}

button:hover {
  border-color: var(--accent);
  background: rgba(62,162,255,0.15);
}

/* ===== Select Dropdowns ===== */
select {
  background: rgb(248, 247, 247);
  color: black;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
}

select:hover {
  border-color:var(--accent);
}

/* ===== Event List Inside Cell ===== */
.event-list {
  list-style: none;
  margin:4px 0 0;
  padding:0;

  display:flex;
  flex-direction:column;
  gap:2px;

  font-size:10px;
  line-height:1.2;

  overflow-y:auto;       /* Allow scrolling if too many events */
  max-height:70px;       /* Prevent events from overflowing the cell */
}

/* Event pill style + tooltip anchor */
.event-pill {
  position: relative;
  padding: 1px 4px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* "+N more" row shown inside a calendar cell */
.event-more-pill {
  padding: 1px 4px;
  margin-top: 2px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
}

.event-more-pill:hover {
  text-decoration: underline;
}

/* List inside the day events modal */
.day-events-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.day-event-item {
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
}

.day-event-item:hover {
  text-decoration: underline;
}

/* Tooltip on hover with full title */
.event-pill:hover::after {
  content: attr(data-full-title);
  position: absolute;
  left: 0;
  top: 105%;
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--accent);
  padding: 4px 8px;
  border-radius: 6px;
  z-index: 2000;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Holiday special color */
.tag-holiday {
  border-left: 3px solid #ff9800;   /* orange */
  background: rgba(255, 152, 0, 0.15);
}

/* Academic Calendar special color */
.tag-academic-calendar {
  border-left: 3px solid #A3D1D1;   
  background: #a3d1d162;
  color: #051433;
}

/* Constructions Closures special color */
.tag-construction-closures {
  border-left: 3px solid #CF9E9E;   
  background: #cf9e9ea3;
}

/* School Closures special color */
.tag-school-closures {
  border-left: 3px solid #CF9E9E;   
  background: #cf9e9ea3;
}

/* Base color for Weather tag */
.tag-weather {
  border-left: 2px solid var(--muted);
}

/* Hot day (high average temperature) */
.weather-hot {
  background: rgba(255, 99, 71, 0.25);
  border-left-color: #ff6347; /* tomato */
}

/* Cold day (low average temperature) */
.weather-cold {
  background: rgba(65, 105, 225, 0.25);
  border-left-color: #4169e1; /* royalblue */
}

/* Base color for Weather tag */
.tag-weather {
  border-left: 2px solid var(--muted);
}

/* Hot day (high average temperature) */
.weather-hot {
  background: rgba(255, 99, 71, 0.25);
  border-left-color: #ff6347; /* tomato */
}

/* Cold day (low average temperature) */
.weather-cold {
  background: rgba(65, 105, 225, 0.25);
  border-left-color: #4169e1; /* royalblue */
}

/* Heavy rain warning style */
.weather-rain-heavy {
  background: rgba(30, 144, 255, 0.25);
  border-left: 3px solid #1e90ff; /* dodgerblue */
  font-weight: 600;
}

/* Sports Events special color */
.tag-sports-events {
  border-left: 3px solid #ff00b3;
}

/* Footer under calendar */
.foot {
  font-size:13px;
  color:var(--muted);
  margin-top:8px;
}
