/**
 * FS27 Custom Modern Calendar Styles
 * Rule 9 & Material Design 3 Spec Compliant
 */

.calendar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.calendar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.calendar-modal {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-3);
  width: 90%;
  max-width: 360px;
  padding: 1.25rem;
  transform: translateY(12px) scale(0.97);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calendar-overlay.active .calendar-modal {
  transform: translateY(0) scale(1);
}

/* Header */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calendar-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calendar-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: var(--border-subtle);
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.calendar-nav-btn:hover:not(:disabled) {
  background-color: var(--md-sys-color-surface-variant);
}

.calendar-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.calendar-view-btn {
  font-size: 1rem;
  font-weight: 600;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background-color: transparent;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
}

.calendar-view-btn:hover {
  background-color: var(--md-sys-color-surface-variant);
}

/* Weekday labels */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--md-sys-color-outline);
  margin-bottom: 0.25rem;
}

.calendar-weekdays span:first-child {
  color: #E53935; /* 日曜 */
}

.calendar-weekdays span:last-child {
  color: #1E88E5; /* 土曜 */
}

/* Days Grid */
.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  border-radius: var(--radius-full);
  border: none;
  background-color: transparent;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.calendar-day-cell:hover:not(:disabled) {
  background-color: var(--md-sys-color-surface-variant);
}

.calendar-day-cell.other-month {
  color: var(--md-sys-color-outline);
  opacity: 0.4;
}

.calendar-day-cell.today {
  border: 1px solid var(--md-sys-color-primary);
  font-weight: 600;
}

.calendar-day-cell.selected {
  background-color: var(--md-sys-color-primary) !important;
  color: var(--md-sys-color-on-primary) !important;
  font-weight: 700;
}

.calendar-day-cell:disabled {
  color: var(--md-sys-color-outline);
  opacity: 0.25;
  cursor: not-allowed;
  text-decoration: line-through;
}

/* Year & Month Grid Mode */
.calendar-grid-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.25rem;
}

.calendar-grid-card {
  padding: 0.75rem 0.5rem;
  text-align: center;
  border-radius: var(--radius-sm);
  border: var(--border-subtle);
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.calendar-grid-card:hover {
  background-color: var(--md-sys-color-surface-variant);
  border-color: var(--md-sys-color-outline);
}

.calendar-grid-card.selected {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

/* Footer Controls */
.calendar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: var(--border-subtle);
  padding-top: 0.75rem;
}

.calendar-footer-btn {
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-button);
  cursor: pointer;
  border: none;
  background-color: transparent;
  color: var(--md-sys-color-primary);
  transition: background-color var(--transition-fast);
}

.calendar-footer-btn:hover {
  background-color: var(--md-sys-color-surface-variant);
}

.calendar-footer-btn.btn-confirm {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.calendar-footer-btn.btn-confirm:hover {
  opacity: 0.9;
}
