/* ============================================================
   CALENDAR.CSS — Calendar View
   Class names match calendar.js output exactly.
   ============================================================ */

/* ── Calendar Controls Bar ───────────────────────────────── */
.calendar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--n-0);
  border-bottom: 1px solid var(--n-150);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 16px;
  flex-wrap: wrap;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--n-800);
  width: 200px;
  text-align: center;
  font-family: var(--font-display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--n-200);
  border-radius: var(--r-sm);
  background: var(--n-0);
  color: var(--n-500);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.nav-btn:hover {
  background: var(--n-100);
  border-color: var(--n-300);
  color: var(--n-700);
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.view-controls select {
  padding: 7px 30px 7px 10px;
  font-size: 13px;
  border-radius: var(--r-sm);
  color: var(--n-600);
}

/* ── Calendar Grid Container ─────────────────────────────── */
.calendar-grid {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px - 58px);
  overflow: hidden;
}

/* ── Header Row ──────────────────────────────────────────── */
.calendar-header {
  display: grid;
  background: var(--n-0);
  border-bottom: 1.5px solid var(--n-150);
  flex-shrink: 0;
}

.header-cell {
  padding: 10px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--n-500);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-right: 1px solid var(--n-150);
  line-height: 1.5;
}
.header-cell:first-child {
  background: var(--n-50);
  color: var(--n-300);
  font-size: 10px;
}
.header-cell:last-child { border-right: none; }

/* ── Time Grid ───────────────────────────────────────────── */
#timeGrid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  align-content: start;
}

/* ── Time Slot (left label) ──────────────────────────────── */
.time-slot {
  padding: 6px 10px 0 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--n-400);
  text-align: right;
  background: var(--n-50);
  border-right: 1px solid var(--n-150);
  border-bottom: 1px solid var(--n-200);
  min-height: 56px;
  user-select: none;
}

/* ── Day Cell ────────────────────────────────────────────── */
.day-cell {
  min-height: 56px;
  border-right: 1px solid var(--n-100);
  border-bottom: 1px solid var(--n-200);
  cursor: pointer;
  position: relative;
  transition: background 0.12s ease;
}
.day-cell:last-child { border-right: none; }
.day-cell:hover { background: var(--brand-50); }

/* ── Events ──────────────────────────────────────────────── */
.event {
  position: absolute;
  left: 3px;
  right: 3px;
  top: 2px;
  bottom: 4px;
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.12s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-left: 3px solid transparent;
  z-index: 2;
}
.event:hover {
  filter: brightness(0.94);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transform: translateX(1px);
}
.event:hover .event-icons {
  opacity: 1 !important;
}
.event-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  overflow: hidden;
  background: transparent;
  width: 100%;
}
.event-title > span {
  background: transparent;
}

/* Color variants */
.event-blue   { background: #dbeafe; color: #1d4ed8; border-left-color: #3b82f6; }
.event-green  { background: #dcfce7; color: #166534; border-left-color: #22c55e; }
.event-yellow { background: #fef9c3; color: #854d0e; border-left-color: #eab308; }
.event-gray   { background: #f1f3f1; color: #4a514a; border-left-color: #9aa09a; }
.event-purple { background: #f3e8ff; color: #6b21a8; border-left-color: #a855f7; }
.event-pink   { background: #fce7f3; color: #9d174d; border-left-color: #ec4899; }
.event-red    { background: #fee2e2; color: #991b1b; border-left-color: #ef4444; }

/* ── Month View ──────────────────────────────────────────── */
.month-day-cell {
  border-right: 1px solid var(--n-150);
  border-bottom: 1px solid var(--n-150);
  padding: 8px;
  min-height: 110px;
  cursor: pointer;
  transition: background 0.12s ease;
  vertical-align: top;
}
.month-day-cell:hover { background: var(--brand-50); }
.month-day-cell.empty { background: var(--n-50); cursor: default; }

.month-day-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--n-700);
  margin-bottom: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

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

.month-event {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.month-event.event-blue   { background: #dbeafe; color: #1d4ed8; }
.month-event.event-green  { background: #dcfce7; color: #166534; }
.month-event.event-yellow { background: #fef9c3; color: #854d0e; }
.month-event.event-gray   { background: #f1f3f1; color: #4a514a; }
.month-event.event-purple { background: #f3e8ff; color: #6b21a8; }

/* ── Note & Payment Icons on Events ─────────────────────── */
.event-icons span[onclick*="openNoteModal"],
.event-icons span[title*="Add note"],
.event-icons span[onclick*="openInvoiceFromCalendar"],
.event-icons span[title*="balance"] {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  background: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 4px;
  font-size: 12px;
  flex-shrink: 0;
  transition: background 0.12s ease, transform 0.12s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.event-icons span[onclick*="openNoteModal"]:hover,
.event-icons span[title*="Add note"]:hover,
.event-icons span[onclick*="openInvoiceFromCalendar"]:hover {
  background: rgba(255,255,255,0.98);
  transform: scale(1.2);
}
