/* RE:BERRY Calendar + Time-Slot Picker v2.0
   All colors via CSS variables from shell :root
   Works on dark (gangnam/myeongdong) and light (incheon) themes */

.rb-cal {
  position: relative;
  width: 100%;
  touch-action: manipulation;
}

/* ── Display Bar (replaces text input visually) ── */
.rb-cal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  background: var(--cream-light, #FAFAF8);
  border: 1px solid var(--border, rgba(201,169,110,.18));
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted, #8A8888);
  transition: border-color 0.2s;
  user-select: none;
  -webkit-user-select: none;
}
.rb-cal-bar:hover,
.rb-cal-bar:focus {
  border-color: var(--accent, #C9A96E);
  outline: none;
}
.rb-cal-bar-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rb-cal-bar-filled {
  color: var(--text-dark, #1A1A1A);
  font-weight: 600;
}
.rb-cal-bar-icon {
  font-size: 10px;
  color: var(--text-muted, #8A8888);
  transition: transform 0.2s;
}
.rb-cal-bar-clear {
  font-size: 14px;
  color: var(--text-muted, #8A8888);
  padding: 4px 8px;
  border-radius: 50%;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
}
.rb-cal-bar-clear:hover {
  color: var(--text-dark, #1A1A1A);
  background: rgba(0,0,0,0.06);
}

/* ── Dropdown Panel ── */
.rb-cal-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white, #FFFFFF);
  border: 1px solid var(--border, rgba(201,169,110,.18));
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.12);
  z-index: 50;
  padding: 16px;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.rb-cal-panel.rb-cal-open {
  display: block;
}

/* ── Calendar Header ── */
.rb-cal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.rb-cal-title {
  font-family: 'Montserrat', 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark, #1A1A1A);
}
.rb-cal-prev,
.rb-cal-next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border, rgba(201,169,110,.18));
  border-radius: 50%;
  background: transparent;
  font-size: 20px;
  color: var(--text-dark, #1A1A1A);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
  line-height: 1;
}
.rb-cal-prev:hover,
.rb-cal-next:hover {
  border-color: var(--accent, #C9A96E);
  color: var(--accent, #C9A96E);
}

/* ── Day-of-Week Headers ── */
.rb-cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}
.rb-cal-dow-cell {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #8A8888);
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rb-cal-dow-cell.rb-cal-weekend {
  color: var(--accent, #C9A96E);
}

/* ── Calendar Grid ── */
.rb-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.rb-cal-day {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  font-size: 14px;
  color: var(--text-dark, #1A1A1A);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}
.rb-cal-day:not(.rb-cal-disabled):not(.rb-cal-empty):hover {
  background: color-mix(in srgb, var(--accent, #C9A96E) 12%, transparent);
}
.rb-cal-empty {
  cursor: default;
}

/* Past dates */
.rb-cal-past {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* Holidays */
.rb-cal-holiday {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
  text-decoration: line-through;
}

/* Weekend dates */
.rb-cal-wknd:not(.rb-cal-disabled) {
  color: var(--accent, #C9A96E);
}

/* Today */
.rb-cal-today {
  font-weight: 700;
}
.rb-cal-today::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent, #C9A96E);
}

/* Selected date */
.rb-cal-selected {
  background: var(--accent, #C9A96E) !important;
  color: var(--white, #FFFFFF) !important;
  font-weight: 700;
}
.rb-cal-selected::after {
  display: none;
}

/* ── KST Note ── */
.rb-cal-kst {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted, #8A8888);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border, rgba(201,169,110,.18));
}

/* ── Time Slots ── */
.rb-cal-time {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border, rgba(201,169,110,.18));
}
.rb-cal-time-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark, #1A1A1A);
  margin-bottom: 10px;
}
.rb-cal-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rb-cal-slot {
  padding: 8px 14px;
  font-size: 13px;
  font-family: 'DM Sans', 'Inter', sans-serif;
  border: 1px solid var(--border, rgba(201,169,110,.18));
  border-radius: 20px;
  background: transparent;
  color: var(--text-dark, #1A1A1A);
  cursor: pointer;
  transition: all 0.15s;
  min-width: 70px;
  text-align: center;
  line-height: 1;
  touch-action: manipulation;
}
.rb-cal-slot:hover {
  border-color: var(--accent, #C9A96E);
  color: var(--accent, #C9A96E);
}
.rb-cal-slot-sel,
.rb-cal-slot-sel:hover {
  background: var(--accent, #C9A96E);
  border-color: var(--accent, #C9A96E);
  color: var(--white, #FFFFFF);
  font-weight: 600;
}
.rb-cal-no-slots {
  font-size: 13px;
  color: var(--text-muted, #8A8888);
  padding: 8px 0;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .rb-cal-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
    padding: 20px 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .rb-cal-day {
    min-height: 44px;
    font-size: 15px;
  }
  .rb-cal-slot {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
