/* ==========================================================================
   Calendar Tab Styles (Flat 2-column layout: 300px Sidebar + 1fr Main Grid)
   ========================================================================== */

.calendar-layout {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

/* Left Sidebar (300px locked) */
.calendar-sidebar {
  flex: 0 0 300px;
  width: 300px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
  min-height: 0;
}

.cal-sb-top {
  padding: 12px 12px 8px 12px;
  flex-shrink: 0;
}

.btn-cal-new {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

.cal-sb-calendars {
  padding: 2px 10px 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.cal-sb-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
}

.cal-sb-collapse-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 6px;
}

.cal-sb-collapse-btn:hover {
  background: var(--hover);
}

.cal-sb-add-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cal-sb-add-btn:hover {
  background: var(--hover);
  color: var(--fg);
}

.cal-sb-cal-list {
  max-height: 170px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.cal-sb-empty-cals {
  font-size: 12px;
  color: var(--fg-muted);
  padding: 6px;
}

.cal-list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.cal-list-row:hover {
  background: var(--hover);
}

.cal-color-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--primary);
  background: transparent;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.cal-list-name {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-ro-icon {
  color: var(--fg-muted);
  flex-shrink: 0;
}

.cal-sb-switch-wrap {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.cal-sb-segmented {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.cal-sb-lower {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Day Agenda Panel */
.cal-agenda-panel,
.cal-inline-editor,
.cal-mini-months {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px 14px 12px;
}

.cal-agenda-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-agenda-date {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
}

.cal-agenda-add-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cal-agenda-add-btn:hover {
  color: var(--fg);
  background: var(--pill-hover);
}

.cal-agenda-empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--fg-muted);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.cal-agenda-empty-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.cal-agenda-allday,
.cal-agenda-timed {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cal-agenda-allday {
  margin-bottom: 8px;
}

.cal-agenda-card {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px;
  display: flex;
  align-items: stretch;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.cal-agenda-card:hover {
  border-color: var(--primary);
}

.cal-agenda-stripe {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.cal-agenda-card-body {
  min-width: 0;
  flex: 1;
}

.cal-agenda-time {
  font-size: 11px;
  color: var(--fg-muted);
  font-weight: 600;
}

.cal-agenda-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg);
  margin-top: 1px;
  word-break: break-word;
}

.cal-agenda-loc {
  font-size: 11px;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.cal-gap-pill,
.cal-overlap-pill {
  align-self: center;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--fg-muted);
}

.cal-overlap-pill {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Inline Event Editor */
.cal-ed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-ed-heading {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--fg);
}

.cal-ed-close {
  border: none;
  background: transparent;
  color: var(--fg-muted);
  display: inline-flex;
  padding: 3px;
  border-radius: 5px;
  cursor: pointer;
}

.cal-ed-close:hover {
  background: var(--hover);
  color: var(--fg);
}

.cal-ed-ro-banner {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--surface-low);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--fg-muted);
  margin-bottom: 10px;
}

.cal-ed-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.cal-ed-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-ed-lbl {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg-muted);
}

.cal-ed-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}

.cal-ed-input,
.cal-ed-select,
.cal-ed-textarea {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 12.5px;
}

.cal-ed-input.is-title {
  font-weight: 600;
  font-size: 13.5px;
}

.cal-ed-dt-row {
  display: flex;
  gap: 6px;
}

.cal-ed-dt-btn {
  flex: 1;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.cal-ed-dt-btn.is-time {
  flex: 0 0 74px;
  text-align: center;
}

.cal-ed-dt-btn:hover:not(:disabled) {
  border-color: var(--primary);
}

.cal-ed-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.cal-ed-footer-spacer {
  flex: 1;
}

/* Infinite Month Overview (Sidebar) */
.cal-mini-months {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cal-mini-month-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 6px;
}

.cal-mini-month-row {
  display: grid;
  grid-template-columns: 24px repeat(7, 1fr);
  gap: 2px;
  align-items: center;
}

.cal-mini-wk {
  font-size: 10px;
  color: var(--fg-muted);
  text-align: center;
}

.cal-mini-dow {
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-muted);
  text-align: center;
}

.cal-mini-day {
  position: relative;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.cal-mini-day:hover:not(:disabled) {
  background: var(--hover);
}

.cal-mini-day.is-empty {
  cursor: default;
}

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

.cal-mini-day.is-selected {
  outline: 1.5px solid var(--primary);
}

.cal-mini-dots {
  display: flex;
  gap: 2px;
  margin-top: 1px;
}

.cal-mini-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

/* Custom DateTimePickerPopup */
.cal-dt-popup {
  position: fixed;
  z-index: 120;
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

.dtp-cal-col {
  width: 214px;
}

.dtp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.dtp-month-lbl {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg);
}

.dtp-nav-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dtp-nav-btn:hover {
  background: var(--hover);
  color: var(--fg);
}

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

.dtp-dow {
  font-size: 10.5px;
  color: var(--fg-muted);
  text-align: center;
  padding-bottom: 3px;
}

.dtp-day-btn {
  height: 26px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.dtp-day-btn.is-outside {
  color: var(--fg-muted);
  opacity: 0.45;
}

.dtp-day-btn.is-today {
  border: 1px solid var(--primary);
}

.dtp-day-btn.is-selected {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
}

.dtp-time-col {
  width: 82px;
  max-height: 220px;
  overflow-y: auto;
  border-left: 1px solid var(--border-subtle);
  padding-left: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dtp-time-btn {
  width: 100%;
  padding: 4px 6px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}

.dtp-time-btn:hover {
  background: var(--hover);
}

.dtp-time-btn.is-selected {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

/* Main Area */
.calendar-main {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

.cal-main-toolbar {
  height: 52px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cal-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-nav-step-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-low);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cal-nav-step-btn:hover {
  background: var(--pill-hover);
}

.cal-period-title {
  margin: 0 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
}

.cal-grid-host {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.cal-view-pane {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Month View */
.cal-month-grid-root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.cal-month-dow-hdr {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  height: 30px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-low);
  flex-shrink: 0;
}

.cal-month-uge-hdr,
.cal-month-dow-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  border-right: 1px solid var(--border-subtle);
}

.cal-month-dow-cell.is-weekend {
  color: color-mix(in srgb, var(--fg-muted) 80%, transparent);
}

.cal-month-weeks {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
}

.cal-month-week-row {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 0;
}

.cal-month-uge-cell {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  background: var(--surface-low);
  border-right: 1px solid var(--border-subtle);
}

.cal-month-day-cell {
  padding: 5px 6px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
}

.cal-month-day-cell.is-weekend {
  background: color-mix(in srgb, var(--surface-low) 55%, var(--surface));
}

.cal-month-day-cell.is-outside-blank {
  background: var(--surface-low);
  cursor: default;
}

.cal-month-day-cell.is-selected {
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  box-shadow: inset 0 0 0 1.5px var(--primary);
}

.cal-month-day-top {
  display: flex;
  align-items: center;
}

.cal-month-day-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  padding: 1px 6px;
  border-radius: 999px;
}

.cal-month-day-cell.is-today .cal-month-day-num {
  background: var(--primary);
  color: var(--on-primary);
}

.cal-month-pills {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cal-month-pill {
  height: 19px;
  padding: 0 5px;
  border: none;
  border-left: 3px solid var(--primary);
  border-radius: 3px;
  color: var(--fg);
  font-family: inherit;
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-month-pill.is-draft {
  outline: 1.5px dashed var(--primary);
  opacity: 0.85;
}

.cal-month-pill-time {
  font-weight: 600;
  font-size: 10.5px;
}

.cal-month-more-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  padding: 1px 4px;
  cursor: pointer;
}

/* Week View */
.cal-week-root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cal-week-header {
  flex: 0 0 auto;
  min-height: 54px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-low);
}

.cal-week-hdr-days {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  height: 44px;
}

.cal-week-gutter-hdr {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--fg-muted);
  border-right: 1px solid var(--border-subtle);
}

.cal-week-day-hdr {
  border: none;
  border-right: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.cal-week-day-hdr:hover {
  background: var(--hover);
}

.cal-week-dow {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
}

.cal-week-day-num {
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}

.cal-week-day-hdr.is-today .cal-week-day-num {
  background: var(--primary);
  color: var(--on-primary);
}

.cal-week-allday-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  border-top: 1px solid var(--border-subtle);
  padding: 4px 0;
}

.cal-week-allday-lbl {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-week-allday-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px 4px;
  padding-right: 4px;
}

.cal-week-allday-pill {
  height: 20px;
  padding: 0 6px;
  border: none;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  color: var(--fg);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.cal-week-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.cal-week-canvas {
  display: grid;
  grid-template-columns: 56px 1fr;
  height: 1440px;
  position: relative;
}

.cal-week-time-gutter {
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-low);
}

.cal-week-hour-lbl {
  height: 60px;
  padding: 0 6px;
  font-size: 10.5px;
  color: var(--fg-muted);
  text-align: right;
  transform: translateY(-7px);
}

.cal-week-cols {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  height: 1440px;
}

.cal-week-col {
  position: relative;
  border-right: 1px solid var(--border-subtle);
  height: 1440px;
}

.cal-week-col.is-today {
  background: color-mix(in srgb, var(--primary) 4%, transparent);
}

.cal-week-col.is-weekend {
  background: color-mix(in srgb, var(--surface-low) 45%, transparent);
}

.cal-week-hour-cell {
  height: 60px;
  border-bottom: 1px solid var(--border-subtle);
  background-image: linear-gradient(
    to bottom,
    transparent 29px,
    color-mix(in srgb, var(--border-subtle) 50%, transparent) 30px,
    transparent 31px
  );
}

.cal-week-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--danger);
  z-index: 50;
  pointer-events: none;
}

.cal-week-now-dot {
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.cal-week-event {
  position: absolute;
  padding: 3px 6px 4px 7px;
  border-radius: 5px;
  border: 1px solid var(--surface);
  border-left: 3.5px solid var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}

.cal-week-event.is-draft {
  outline: 1.5px dashed var(--primary);
  opacity: 0.85;
}

.cal-week-ev-time {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--fg-muted);
  white-space: nowrap;
}

.cal-week-ev-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.25;
}

.cal-week-ev-loc {
  font-size: 11px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-week-resize-handle {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
}

.cal-week-resize-handle.is-top {
  top: 0;
}

.cal-week-resize-handle.is-bottom {
  bottom: 0;
}

.cal-week-drag-ghost {
  position: absolute;
  left: 3%;
  width: 94%;
  border-radius: 6px;
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  border: 1.5px dashed var(--primary);
  color: var(--fg);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 6px;
  z-index: 45;
  pointer-events: none;
}

/* Floating EventHoverCard */
.cal-hover-card {
  position: fixed;
  z-index: 140;
  width: 300px;
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.cal-hover-stripe {
  height: 4px;
  width: 100%;
}

.cal-hover-body {
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cal-hover-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--fg);
}

.cal-hover-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-muted);
}

.cal-hover-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-hover-desc {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--fg);
  line-height: 1.4;
}

.cal-hover-day-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 220px;
  overflow-y: auto;
}

.cal-hover-day-row {
  width: 100%;
  border: none;
  background: transparent;
  padding: 5px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}

.cal-hover-day-row:hover {
  background: var(--hover);
}

.cal-hover-day-time {
  color: var(--fg-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.cal-hover-day-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
