/* =============================================
   SALON BOOKING SaaS — CALENDAR.CSS
   Weekly/Daily Calendar Grid & Events
   ============================================= */

/* ── Calendar Container ─────────────────────── */
.calendar-wrapper {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 32px);
  min-height: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.03);
}

/* ── Calendar Sidebar ───────────────────────── */
.calendar-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  padding: var(--sp-5) var(--sp-4);
  gap: var(--sp-5);
  overflow-y: auto;
}

.calendar-sidebar-header {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.calendar-view-toggle {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 2px;
}

.calendar-view-btn {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.calendar-view-btn.active {
  background: var(--color-primary);
  color: white;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calendar-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.calendar-nav-btn {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
}
.calendar-nav-btn:hover { color: var(--text-primary); }

.calendar-today-btn {
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.calendar-today-btn:hover { background: var(--bg-elevated); }

.calendar-sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-2) 0;
}

/* Sidebar mini-calendar */
.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
  font-size: 0.75rem;
}
.mini-cal-dow {
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.mini-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  color: var(--text-secondary);
}
.mini-cal-day:hover { background: var(--bg-elevated); }
.mini-cal-day.active { background: var(--color-primary); color: white; }
.mini-cal-day.other-month { color: var(--border-strong); }

/* Employee filters */
.emp-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.emp-chip {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: all 0.2s ease;
  user-select: none;
}
.emp-chip:hover {
  border-color: var(--border-strong);
  background: var(--bg-base);
}
.emp-chip.active {
  box-shadow: var(--shadow-sm);
}

/* ── Main Calendar Area ─────────────────────── */
.calendar-main {
  flex: 1;
  display: flex;
  flex-direction: row;
  position: relative;
  background: var(--bg-base);
}

/* Time axis */
.calendar-time-axis {
  width: 64px;
  flex-shrink: 0;
  border-right: 1px solid #cbd5e1;
  background: white;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: hidden;
  scrollbar-width: none;
}

.time-axis-header-spacer {
  height: 52px;
  box-sizing: border-box;
  background: white;
  border-bottom: 1px solid #cbd5e1;
  flex-shrink: 0;
}

.time-axis-labels-body {
  display: flex;
  flex-direction: column;
  position: relative;
  margin-top: 12px;
}

.time-label-group {
  height: 80px;
  box-sizing: border-box;
  position: relative;
}

.time-label-text {
  position: absolute;
  top: -7px;
  right: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #475569;
  background: white;
  padding: 0 3px;
  z-index: 5;
  line-height: 1;
  white-space: nowrap;
}

/* Days container */
.calendar-days-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  position: relative;
  background: white;
}

/* Day headers row */
.calendar-days-header {
  display: grid;
  height: 52px;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
  border-bottom: 1px solid #cbd5e1;
}

.calendar-day-header {
  padding: 4px var(--sp-2);
  text-align: center;
  border-right: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-sizing: border-box;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  user-select: none;
}

.calendar-day-header:hover {
  background: rgba(124, 111, 247, 0.08) !important;
}

.calendar-day-header:nth-child(even) {
  background: #f8fafc;
}

.calendar-day-header:last-child { border-right: none; }

.day-header-name {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  line-height: 1;
}

.day-header-num {
  font-size: 0.9rem;
  font-weight: 800;
  color: #1e293b;
  display: flex;
  align-items: baseline;
  gap: 3px;
  line-height: 1;
}

.day-header-num .num-val {
  font-size: 1.05rem;
  font-weight: 800;
}

.day-header-num .month-val {
  font-size: 0.62rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
}

.day-header-num.today .num-val {
  background: #f97316;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(249, 115, 22, 0.4);
}

/* Grid rows (hours) with 15-min dashed subdivisions */
.calendar-grid {
  display: flex;
  flex-direction: column;
  position: relative;
}

.calendar-grid-row {
  display: grid;
  height: 80px;
  box-sizing: border-box;
  border-bottom: 1px solid #cbd5e1;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 19px,
    #f1f5f9 20px,
    #f1f5f9 20px
  );
}

.calendar-grid-cell {
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #e2e8f0;
  position: relative;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.calendar-grid-cell:nth-child(even) {
  background: #f8fafc;
}

.calendar-grid-cell:last-child { border-right: none; }

.calendar-grid-cell:hover {
  background: var(--bg-card-hover) !important;
}

.calendar-grid-cell.past {
  background: repeating-linear-gradient(
    45deg,
    #f8fafc,
    #f8fafc 10px,
    #f1f5f9 10px,
    #f1f5f9 20px
  ) !important;
  opacity: 0.8;
  cursor: not-allowed;
}

/* Half-hour line */
.calendar-grid-cell::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  border-top: 1px dashed #cbd5e1;
  opacity: 0.7;
}

/* ── Calendar Events ────────────────────────── */
.calendar-events-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.calendar-event {
  position: absolute;
  border-radius: var(--radius-md);
  padding: 4px 6px;
  font-size: 0.72rem;
  font-weight: 500;
  pointer-events: all;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--transition-fast);
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 20px;
}

.calendar-event:hover {
  z-index: 5;
  filter: brightness(0.95);
  box-shadow: var(--shadow-sm);
}

/* Event types */
.event-booking {
  background: var(--color-primary-light, #BAE6FD);
  color: #0f172a;
}

.event-blocked {
  background: repeating-linear-gradient(
    45deg,
    rgba(248,113,113,0.1),
    rgba(248,113,113,0.1) 4px,
    rgba(248,113,113,0.05) 4px,
    rgba(248,113,113,0.05) 8px
  );
  color: var(--color-danger);
  border: 1px dashed rgba(248,113,113,0.4);
}

.event-title { font-weight: 700; line-height: 1.2; color: #0f172a; }
.event-sub   { font-size: 0.65rem; color: #334155; }

/* Current time indicator */
.current-time-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-secondary);
  z-index: 8;
  pointer-events: none;
}

.current-time-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-secondary);
}

/* ── Day View ───────────────────────────────── */
.calendar-day-view .calendar-grid-row {
  grid-template-columns: 1fr;
}

/* ── Week View ──────────────────────────────── */
.calendar-week-view .calendar-grid-row {
  grid-template-columns: repeat(7, 1fr);
}

.calendar-week-view .calendar-days-header {
  grid-template-columns: repeat(7, 1fr);
}

/* ── Employee Day View ──────────────────────── */
.calendar-employee-view .calendar-grid-row {
  display: grid;
}


/* ── Legend ─────────────────────────────────── */
.calendar-legend {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ── Mini Calendar (Date Picker) ─────────────── */
.mini-calendar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  width: 100%;
}

.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.mini-cal-title {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
}

.mini-cal-nav {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
}

.mini-cal-nav:hover {
  background: var(--color-primary-glow);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mini-cal-dow {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
  letter-spacing: 0.04em;
}

.mini-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  font-weight: 500;
}

.mini-cal-day:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.mini-cal-day.today {
  background: var(--color-primary-glow);
  color: var(--color-primary);
  font-weight: 700;
}

.mini-cal-day.selected {
  background: var(--color-primary);
  color: white;
  font-weight: 700;
  box-shadow: var(--shadow-primary);
}

.mini-cal-day.other-month {
  opacity: 0.3;
}

.mini-cal-day.disabled {
  opacity: 0.2;
  cursor: not-allowed;
  pointer-events: none;
}

.mini-cal-day.has-events::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-primary);
}

.mini-cal-day { position: relative; }

/* ── Non-working day styles ─────────────────── */
.day-non-working {
  opacity: 0.75;
  background: rgba(120, 120, 160, 0.04);
}

.cell-non-working {
  background: rgba(120, 120, 160, 0.03) !important;
  cursor: not-allowed !important;
}

.cell-non-working:hover {
  background: rgba(120, 120, 160, 0.03) !important;
}


