/* ── CALENDAR PAGE ─────────────────────────────────────── */

/* Import Inter + JetBrains Mono */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ══════════════════════════════════════════════════════════
   CALENDAR PAGE — FULL WIDTH LAYOUT
   Structure: heading → cat filters → timeframe → grid → panels
   ══════════════════════════════════════════════════════════ */

main.cal-page {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 40px 60px;
  font-family: 'Inter', var(--font-sans, sans-serif);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

/* ── 1. HEADING ── */
.cal-page-header {
  width: 100%;
  margin-bottom: 24px;
  text-align: center;
}
.cal-page-header h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 32px;
  letter-spacing: 5px;
  color: var(--text);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.cal-page-header p { font-size: 14px; color: var(--text-muted); margin-bottom: 0; }

/* ── 2. CATEGORY FILTERS ── */
.cal-filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 12px;
}

/* ── 3. TIMEFRAME BAR ── */
.cal-timeframe-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.cal-nav-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 20px;
}

/* ── 4. CALENDAR MAIN WRAP ── */
.cal-main-wrap {
  width: 100%;
  margin-bottom: 32px;
}

.cal-grid-wrap,
.cal-week-wrap,
.cal-list-wrap,
.cal-timeline-wrap {
  width: 100%;
}

/* ── 5. BOTTOM PANELS (3-col) ── */
.cal-panels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 100%;
}

.cal-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  min-height: 180px;
}

.cal-panel-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── LEGACY NAV ROW (hidden — replaced by timeframe bar) ── */
.cal-nav-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.cal-nav-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px; height: 32px;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.cal-nav-btn:hover { border-color: var(--text-dim); color: var(--text); }

.cal-month-label {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 2px;
  min-width: 160px;
}

.cal-view-toggle {
  display: flex;
  gap: 4px;
  margin-left: auto;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px;
}
.cal-view-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 7px 18px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.cal-view-btn:hover { border-color: var(--text-dim); color: var(--text); }
.cal-view-btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Legacy sidebar — now replaced by .cal-panels */
.cal-sidebar { display: none; }
.cal-layout { display: none; }

/* ── GRID VIEW ─────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  width: 100%;
  border: 1px solid #222;
  border-radius: 8px;
  overflow: hidden;
}

.cal-grid-header {
  background: var(--bg3);
  padding: 11px 0;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
}

.cal-cell {
  background: var(--bg2);
  min-height: 180px;
  padding: 12px 10px 10px;
  position: relative;
  border-right: 1px solid #222;
  border-bottom: 1px solid #222;
  transition: background 0.15s;
  box-shadow: inset 0 0 0 0 transparent;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.cal-cell:hover {
  background: var(--bg3);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}
/* Remove right border on last column */
.cal-cell:nth-child(7n) { border-right: none; }

.cal-cell:hover { background: var(--bg3); }
.cal-cell.other-month { background: var(--bg); opacity: 0.5; }
.cal-cell.today { background: #0c1829; }

/* Heat scale — cells with urgent events get a pulsing glow */
@keyframes heat-pulse {
  0%   { box-shadow: inset 0 0 0 0 rgba(230,57,70,0); }
  50%  { box-shadow: inset 0 0 12px 0 rgba(230,57,70,0.12); }
  100% { box-shadow: inset 0 0 0 0 rgba(230,57,70,0); }
}
.cal-cell.heat-high {
  background: rgba(230,57,70,0.04);
  animation: heat-pulse 3s ease-in-out infinite;
  border-color: rgba(230,57,70,0.2);
}
.cal-cell.heat-medium {
  background: rgba(244,162,97,0.03);
  border-color: rgba(244,162,97,0.15);
}
.cal-cell.heat-low {
  /* Default — no extra styling */
}
.cal-cell.today .cal-cell-num {
  background: var(--accent2);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.cal-cell-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: block;
}

.cal-event-dot {
  display: flex;
  align-items: center;
  gap: 5px;
  border-radius: 4px;
  padding: 3px 7px;
  margin-bottom: 3px;
  font-size: 10px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.cal-event-dot::before {
  content: '';
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.cal-event-dot:hover { opacity: 0.85; transform: translateX(2px); }

/* Status pills — LIVE, DEVELOPING, RESOLVED */
.cal-status-pill {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}
.cal-status-pill.live { background: rgba(230,57,70,0.25); color: #e63946; }
.cal-status-pill.developing { background: rgba(251,191,36,0.2); color: #fbbf24; }
.cal-status-pill.resolved { background: rgba(74,222,128,0.15); color: #4ade80; }

/* Bracketed metadata tags — [WAR] [ENERGY] */
.cal-bracket-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-right: 3px;
}
.cal-event-dot.urgent {
  background: rgba(230,57,70,0.15);
  color: #e63946;
  border-left: 2px solid #e63946;
}
.cal-event-dot.urgent::before { background: #e63946; }
.cal-event-dot.watch  {
  background: rgba(244,162,97,0.15);
  color: #f4a261;
  border-left: 2px solid #f4a261;
}
.cal-event-dot.watch::before  { background: #f4a261; }
.cal-event-dot.info   {
  background: rgba(69,123,157,0.15);
  color: #7aafcf;
  border-left: 2px solid #7aafcf;
}
.cal-event-dot.info::before   { background: #7aafcf; }
.cal-event-dot.sports {
  background: rgba(100,200,100,0.12);
  color: #6cc070;
  border-left: 2px solid #6cc070;
}
.cal-event-dot.sports::before { background: #6cc070; }

.more-events {
  font-size: 9px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  cursor: pointer;
  padding: 1px 4px;
}
.more-events:hover { color: var(--text-dim); }

/* ── TIMELINE VIEW (Horizon) ───────────────────────────── */
.cal-timeline-wrap { width: 100%; }
.cal-timeline {
  position: relative;
  padding-left: 80px;
  max-height: 70vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
/* Vertical line */
.cal-timeline::before {
  content: '';
  position: absolute;
  left: 74px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, #e63946 0%, #222 30%, #222 100%);
}

.cal-timeline-day {
  position: relative;
  margin-bottom: 24px;
  padding-left: 32px;
}

/* Date node on the timeline */
.cal-timeline-node {
  position: absolute;
  left: -38px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #333;
  border: 2px solid #555;
  z-index: 2;
}
.cal-timeline-node.today-node {
  background: var(--accent2);
  border-color: var(--accent2);
  box-shadow: 0 0 8px rgba(251,191,36,0.4);
}
.cal-timeline-node.urgent-node {
  background: #e63946;
  border-color: #e63946;
  animation: heat-pulse 2s ease-in-out infinite;
}

.cal-timeline-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.cal-timeline-date .day-name {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 8px;
  font-size: 11px;
}
.cal-timeline-date .today-label {
  color: var(--accent2);
  font-size: 10px;
  font-weight: 700;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.cal-timeline-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cal-timeline-event {
  background: var(--bg2);
  border: 1px solid #222;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.cal-timeline-event:hover {
  background: var(--bg3);
  border-color: #333;
  transform: translateX(3px);
}
.cal-timeline-event.urgent-event {
  border-left: 3px solid #e63946;
  background: rgba(230,57,70,0.04);
}
.cal-timeline-event.watch-event {
  border-left: 3px solid #f4a261;
}

.cal-timeline-event-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 50px;
  padding-top: 2px;
}
.cal-timeline-event-body { flex: 1; }
.cal-timeline-event-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 3px;
}
.cal-timeline-event-desc {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}
.cal-timeline-event-tags {
  margin-top: 4px;
}

.cal-timeline-empty {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}

/* ── EVENT TOOLTIP / PEEK CARD ─────────────────────────── */
.cal-tooltip {
  position: fixed;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  max-width: 300px;
  min-width: 220px;
  z-index: 999;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.cal-tooltip.visible { opacity: 1; transform: translateY(0); }
.cal-tooltip-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  margin-bottom: 8px;
  background: rgba(230,57,70,0.15);
  color: #e63946;
}
.cal-tooltip-badge.watch  { background: rgba(244,162,97,0.15); color: #f4a261; }
.cal-tooltip-badge.info   { background: rgba(69,123,157,0.15); color: #7aafcf; }
.cal-tooltip-badge.sports { background: rgba(100,200,100,0.12); color: #6cc070; }
.cal-tooltip-title {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.35;
}
.cal-tooltip-desc  {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.55;
  margin-bottom: 10px;
}
.cal-tooltip-meta  {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 2px;
}

/* ── LIST VIEW ─────────────────────────────────────────── */
.hidden { display: none !important; }

.cal-list-wrap .calendar-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

/* Override calendar-item for grid */
.cal-list-wrap .calendar-item {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cal-list-wrap .cal-content { flex: 1; }
.cal-list-wrap .cal-date { margin-bottom: 8px; }

/* ── SIDEBAR (now below calendar as 3-col grid) ────────── */
/* Main .cal-sidebar styles defined in layout section above */

/* Pulse animation for LIVE NOW */
@keyframes pulse-live {
  0%   { box-shadow: 0 0 0 0 rgba(230,57,70,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(230,57,70,0); }
  100% { box-shadow: 0 0 0 0 rgba(230,57,70,0); }
}

.live-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid #e63946;
  background: rgba(230,57,70,0.06);
  border-radius: 0 4px 4px 0;
  margin-bottom: 4px;
  position: relative;
}
.live-item:last-child { border-bottom: none; }
.live-item::before {
  content: '';
  position: absolute;
  top: 14px;
  right: 10px;
  width: 8px;
  height: 8px;
  background: #e63946;
  border-radius: 50%;
  animation: pulse-live 1.8s infinite;
}

.urgent-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.urgent-item:last-child { border-bottom: none; }

.next7-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.next7-item:last-child { border-bottom: none; }

.next7-date {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--accent2);
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.next7-title {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.4;
}
.next7-empty { font-size: 12px; color: var(--text-muted); padding: 8px 0; }

/* ── WEEK VIEW ─────────────────────────────────────────── */
.cal-week-wrap { width: 100%; }

.cal-week-header {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 2px;
}

.cal-week-day-head {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px 4px 0 0;
  padding: 10px 8px;
  text-align: center;
}
.cal-week-day-name {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-muted);
}
.cal-week-day-num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dim);
  line-height: 1.1;
  margin-top: 2px;
}
.cal-week-day-num.today-num {
  color: #fff;
  background: var(--accent2);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px auto 0;
  font-size: 17px;
}

.cal-week-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 2px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.cal-week-time-col { background: var(--bg2); }
.cal-week-time-slot {
  height: 48px;
  padding: 4px 8px 0;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
}

.cal-week-cell {
  background: var(--bg2);
  min-height: 48px;
  border-bottom: 1px solid var(--border);
  padding: 2px 3px;
  position: relative;
}
.cal-week-cell.today-col { background: #0d1a2e; }

.cal-week-event {
  display: block;
  border-radius: 3px;
  padding: 3px 6px;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.cal-week-event.urgent { background: rgba(230,57,70,0.25); color: #e63946; }
.cal-week-event.watch  { background: rgba(244,162,97,0.2); color: #f4a261; }
.cal-week-event.info   { background: rgba(69,123,157,0.2); color: #7aafcf; }
.cal-week-event.sports { background: rgba(244,162,97,0.15); color: #f4a261; }

.cal-week-allday-row {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 2px;
}
.cal-week-allday-label {
  background: var(--bg3);
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
}
.cal-week-allday-cell {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 4px;
  min-height: 36px;
}
.cal-week-allday-cell.today-col { background: #0d1a2e; }

/* ── DENSITY TOGGLE & SIDEBAR TOGGLE ───────────────────── */
.cal-density-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px;
}
.cal-density-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  width: 28px;
  height: 24px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-density-btn.active { background: var(--text); color: var(--bg); }

.cal-sidebar-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.cal-sidebar-toggle:hover { border-color: var(--text-dim); color: var(--text); }
.cal-sidebar-toggle.collapsed { opacity: 0.6; }

/* Sidebar hidden state */
.cal-layout.sidebar-hidden .cal-sidebar {
  display: none;
}

/* ── COMPACT MODE ───────────────────────────────────────── */
.cal-grid.compact .cal-cell {
  min-height: 72px;
  padding: 6px 6px 4px;
}
.cal-grid.compact .cal-cell-num {
  font-size: 11px;
  margin-bottom: 4px;
}
.cal-grid.compact .cal-event-dot {
  font-size: 9px;
  padding: 2px 5px;
  margin-bottom: 2px;
}
.cal-grid.compact .cal-event-dot::before {
  width: 5px;
  height: 5px;
}

@media (max-width: 900px) {
  .cal-sidebar { grid-template-columns: 1fr; }
  .cal-grid { grid-template-columns: repeat(7, 1fr); font-size: 10px; }
  .cal-cell { min-height: 70px; }
  .cal-week-header { grid-template-columns: 40px repeat(7, 1fr); }
  .cal-week-grid { grid-template-columns: 40px repeat(7, 1fr); }
  .cal-week-allday-row { grid-template-columns: 40px repeat(7, 1fr) !important; }
  .cal-density-toggle, .cal-sidebar-toggle { display: none; }
}
