/* ============================================================
   calendar.css — Month, Week, Day view styles + time grid
   ============================================================ */

/* ─────────────────────────────────────────
   MONTH VIEW
───────────────────────────────────────── */
.month-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.month-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
  flex-shrink: 0;
}

.month-day-header {
  text-align: center;
  padding: 10px 0;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  flex: 1;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

/* ── Month Cell ── */
.month-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  min-height: 100px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  overflow: hidden;
}

.month-cell:hover { background: var(--surface-2); }

.month-cell.other-month { background: var(--bg); }
.month-cell.other-month .month-cell-day { color: var(--text-muted); }

.month-cell.today { background: var(--brand-light); }
.dark-mode .month-cell.today { background: rgba(99,102,241,.08); }

.month-cell-header { margin-bottom: 4px; }

.month-cell-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.today-badge {
  background: var(--brand);
  color: #fff !important;
  font-weight: 700;
}

.month-cell-events { display: flex; flex-direction: column; gap: 2px; }

/* ── Event Chip (month) ── */
.month-event-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: filter var(--transition), transform .1s;
  background: var(--event-color, #4f46e5);
}

.month-event-chip:hover { filter: brightness(1.1); transform: translateY(-1px); }

.chip-time { opacity: .85; font-size: .68rem; flex-shrink: 0; }
.chip-title { overflow: hidden; text-overflow: ellipsis; }

.month-more {
  font-size: .7rem;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 1px 6px;
  cursor: pointer;
  border-radius: 3px;
  transition: background var(--transition);
}

.month-more:hover { background: var(--surface-3); color: var(--brand); }

/* ─────────────────────────────────────────
   WEEK / DAY VIEW SHARED
───────────────────────────────────────── */
.week-view,
.day-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Column Headers ── */
.week-header,
.day-header {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 4;
}

.time-gutter {
  width: 58px;
  min-width: 58px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.week-col-header,
.day-col-header {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  gap: 4px;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.week-col-header:hover,
.day-col-header:hover { background: var(--surface-2); }

.week-col-header.today,
.day-col-header.today { background: var(--brand-light); }
.dark-mode .week-col-header.today,
.dark-mode .day-col-header.today { background: rgba(99,102,241,.1); }

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

.week-day-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}

/* ── Body / Scrollable area ── */
.week-body {
  display: flex;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

/* ── Time Labels Column ── */
.week-time-col {
  width: 58px;
  min-width: 58px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
}

.time-label {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 0 8px 0 0;
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-muted);
  position: relative;
  transform: translateY(-9px);
  height: var(--hour-height);
}

/* ── Days Container ── */
.week-days-container {
  display: flex;
  flex: 1;
  position: relative;
  overflow-x: auto;
}

.day-container { overflow-x: hidden; }

/* ── Single Day Column ── */
.week-day-col {
  flex: 1;
  position: relative;
  border-right: 1px solid var(--border);
  min-width: 80px;
}

.week-day-col.today-col { background: rgba(79,70,229,.02); }
.dark-mode .week-day-col.today-col { background: rgba(99,102,241,.04); }

.day-single-col { min-width: 100%; }

/* ── Hour Slots ── */
.hour-slot {
  position: relative;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  height: var(--hour-height);
}

.hour-slot:nth-child(odd) { background: rgba(0,0,0,.01); }
.dark-mode .hour-slot:nth-child(odd) { background: rgba(255,255,255,.01); }

.hour-slot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
  opacity: .5;
}

.hour-slot:hover {
  background: var(--brand-light);
}

.dark-mode .hour-slot:hover {
  background: rgba(99,102,241,.08);
}

/* ── Events Layer ── */
.events-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

/* ── Time-grid Event ── */
.time-event {
  position: absolute;
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  pointer-events: all;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  border-left: 3px solid rgba(0,0,0,.2);
  transition: filter .14s, transform .1s, box-shadow .14s;
  background: var(--event-color, #4f46e5);
  color: #fff;
  user-select: none;
  z-index: 2;
}

.time-event:hover {
  filter: brightness(1.08);
  transform: translateX(1px);
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
  z-index: 10;
}

.time-event.dragging {
  opacity: .6;
  transform: scale(.97);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.time-event-inner { display: flex; flex-direction: column; gap: 1px; pointer-events: none; }

.time-event-title {
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-event-time { font-size: .65rem; opacity: .85; }

.short-event .time-event-title { font-size: .72rem; }
.short-event .time-event-time { display: none; }

/* ── Resize Handle ── */
.resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  pointer-events: all;
  z-index: 3;
}

.resize-handle::after {
  content: '';
  display: block;
  margin: 0 auto;
  width: 24px;
  height: 3px;
  border-radius: 99px;
  background: rgba(255,255,255,.5);
  margin-top: 2px;
}

/* ── Drag Over Hour Slot ── */
.hour-slot.drag-over {
  background: var(--brand-light) !important;
  border: 2px dashed var(--brand);
}

.dark-mode .hour-slot.drag-over { background: rgba(99,102,241,.12) !important; }

/* ── Current Time Indicator ── */
.current-time-indicator {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #ef4444;
  z-index: 5;
  pointer-events: none;
}

.current-time-indicator::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
}

/* ── Scrollbar in week body ── */
.week-body::-webkit-scrollbar { width: 5px; }
.week-body::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 99px; }

/* ─────────────────────────────────────────
   ANIMATIONS
───────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.month-event-chip,
.time-event {
  animation: fadeIn .18s ease both;
}

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */
@media (max-width: 600px) {
  .week-day-num { font-size: 1rem; width: 30px; height: 30px; }
  .week-day-name { font-size: .6rem; }
  .time-gutter { width: 42px; min-width: 42px; }
  .week-time-col { width: 42px; min-width: 42px; }
  .time-label { font-size: .6rem; padding-right: 4px; }
}

/* ─────────────────────────────────────────
   COMPLETED STATE
───────────────────────────────────────── */
.completed-event {
  opacity: 0.55 !important;
  text-decoration: line-through;
  filter: grayscale(0.2);
}

.completed-event::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.8rem;
  color: #fff;
  opacity: 0.9;
  font-weight: bold;
}
