/**
 * Anarivo SPA - Calendar Styles
 * Sticky calendar with time column and header
 */

/* ============================================
   CALENDAR CONTAINER
   ============================================ */

.calendar-container {
  overflow: auto;
  max-height: 70vh;
  /* Clip any bleed at the rounded corners */
  border-radius: 0 0 0.75rem 0.75rem;
  isolation: isolate;
}

/* ============================================
   CALENDAR TABLE BASE
   ============================================ */

.calendar-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

/* All body cells need position:relative for the absolute + button */
.calendar-table td {
  position: relative;
  min-height: 3rem;
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  vertical-align: top;
}

.dark .calendar-table td,
html.dark .calendar-table td {
  border-bottom-color: #374151;
  border-right-color: #374151;
}

/* ============================================
   STICKY TIME COLUMN (Middle Layer - z-index: 40)
   ============================================ */

.calendar-table tbody td:first-child,
.calendar-table tbody td.calendar-time-cell {
  position: sticky;
  left: 0;
  /* Fully opaque – nothing can bleed through */
  background-color: #ffffff;
  z-index: 40;
  width: 4rem;
  /* Crisp right shadow to visually separate from scrolling content */
  box-shadow: 3px 0 0 0 #e5e7eb;
}

.dark .calendar-table tbody td:first-child,
.dark .calendar-table tbody td.calendar-time-cell,
html.dark .calendar-table tbody td:first-child,
html.dark .calendar-table tbody td.calendar-time-cell {
  background-color: #1f2937;
  color: #9ca3af;
  box-shadow: 3px 0 0 0 #374151;
}

/* ============================================
   STICKY HEADER ROW (High Layer - z-index: 50)
   ============================================ */

.calendar-table thead th {
  position: sticky;
  top: 0;
  /* Fully opaque – blocks any bleed from rows below */
  background-color: #f9fafb;
  z-index: 50;
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  /* Crisp bottom shadow instead of transparent border-collapse gap */
  box-shadow: 0 3px 0 0 #e5e7eb;
  /* Force composited layer so paint stays sharp */
  will-change: transform;
}

.dark .calendar-table thead th,
html.dark .calendar-table thead th {
  background-color: #374151;
  color: #e5e7eb;
  border-bottom-color: #4b5563;
  border-right-color: #4b5563;
  box-shadow: 0 3px 0 0 #4b5563;
}

/* Header cell content */
.calendar-table thead th .day-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.dark .calendar-table thead th .day-name,
html.dark .calendar-table thead th .day-name {
  color: #9ca3af;
}

.calendar-table thead th .day-number {
  display: block;
  color: #4b5563;
}

.dark .calendar-table thead th .day-number {
  color: #9ca3af;
}

.calendar-table thead th.today {
  background-color: #dbeafe;
  box-shadow: 0 3px 0 0 #e5e7eb;
}

.dark .calendar-table thead th.today,
html.dark .calendar-table thead th.today {
  background-color: rgba(30, 58, 138, 0.2);
  box-shadow: 0 3px 0 0 #4b5563;
}

.calendar-table thead th.today .day-number {
  color: var(--primary-600, #2563eb);
}

/* ============================================
   TOP-LEFT CORNER CELL (Highest Layer - z-index: 60)
   ============================================ */

.calendar-table thead th:first-child {
  left: 0;
  z-index: 60;
  width: 4rem;
  /* Two-directional shadow covers both scroll axes */
  box-shadow: 3px 3px 0 0 #e5e7eb;
}

.dark .calendar-table thead th:first-child,
html.dark .calendar-table thead th:first-child {
  box-shadow: 3px 3px 0 0 #4b5563;
}

/* ============================================
   CALENDAR APPOINTMENT CELLS
   ============================================ */

.calendar-table td .appointment-slot {
  padding: 0.25rem;
  position: relative;
}

/* Appointment card inside calendar cell - 3 part layout */
.calendar-appointment {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  height: 1.75rem;
  flex-shrink: 0;
}

.calendar-appointment:hover {
  transform: scale(1.01);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.calendar-appointment span {
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   ADD APPOINTMENT BUTTON (Part of row layout)
   ============================================ */

.calendar-table td button[class*="w-1/4"] {
  border-radius: 0.125rem;
  background-color: var(--gray-400, #9ca3af);
  color: white;
  transition: background-color 0.2s ease, opacity 0.2s ease;
  cursor: pointer;
}

.calendar-table td button[class*="w-1/4"]:hover {
  background-color: var(--primary-500, #3b82f6);
}

/* ============================================
   CALENDAR NAVIGATION
   ============================================ */

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.calendar-nav button {
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s ease;
}

.calendar-nav button:hover {
  background-color: #f3f4f6;
}

.dark .calendar-nav button:hover,
html.dark .calendar-nav button:hover {
  background-color: #374151;
}

.calendar-nav .current-week {
  font-weight: 600;
  font-size: 1.125rem;
  color: #111827;
}

.dark .calendar-nav .current-week,
html.dark .calendar-nav .current-week {
  color: #f9fafb;
}
