/* ==========================================================================
   BBasic Kalender – moderne UI (BBRazorLib)
   Tokens aus bb-theme.css (--bb-*)
   ========================================================================== */

.bc-cal {
  --bc-cal-bg: var(--bb-bg-soft, #111827);
  --bc-cal-panel: var(--bb-surface, #1e293b);
  --bc-cal-elevated: var(--bb-surface-2, #243247);
  --bc-cal-border: var(--bb-border, rgba(148, 163, 184, 0.22));
  --bc-cal-fg: var(--bb-fg, #f1f5f9);
  --bc-cal-muted: var(--bb-fg-muted, #94a3b8);
  --bc-cal-accent: var(--bb-accent, #14b8a6);
  --bc-cal-danger: var(--bb-danger, #f87171);
  --bc-cal-radius: var(--bb-radius, 14px);
  --bc-cal-font: var(--bb-font, system-ui, sans-serif);
  color: var(--bc-cal-fg);
  font-family: var(--bc-cal-font);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.85));
  border: 1px solid var(--bc-cal-border);
  border-radius: var(--bb-radius-lg, 18px);
  box-shadow: var(--bb-shadow-sm, 0 2px 10px rgba(0,0,0,0.2));
  display: flex;
  flex-direction: column;
  min-height: 520px;
  max-height: 100%;
  overflow: hidden;
}

.bc-cal * { box-sizing: border-box; }

.bc-cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bc-cal-panel);
  border-bottom: 1px solid var(--bc-cal-border);
}

.bc-cal-toolbar-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-right: 8px;
  min-width: 10rem;
}

.bc-cal-toolbar-spacer { flex: 1; }

.bc-cal-body {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  flex: 1 1 auto;
  min-height: 0;
  /* Wichtig für Grid-Kinder mit overflow:auto */
  overflow: hidden;
}

/* Handy: Kalenderliste oben, Terminliste darunter scrollt */
@media (max-width: 720px) {
  .bc-cal-body {
    grid-template-columns: 1fr;
    /* Sidebar zuerst – Höhe passt sich an (zugeklappt vs. Liste) */
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    flex: 1;
  }
  .bc-cal-sidebar {
    min-height: 0;
    max-height: 38vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-right: 0 !important;
    border-bottom: 1px solid var(--bc-cal-border);
    flex-shrink: 0;
  }
  .bc-cal-cal-item {
    min-height: 48px;
  }
  .bc-cal {
    /* Feste Mindesthöhe entfällt – nutzt Height-Parameter (vh), sonst clippt die Agenda */
    min-height: 0;
  }
  .bc-cal-main {
    min-height: 0;
  }
}

.bc-cal-sidebar {
  background: var(--bc-cal-panel);
  border-right: 1px solid var(--bc-cal-border);
  padding: 8px 10px 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bc-cal-sidebar-toggle {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin: 0 0 6px;
  padding: 8px 10px;
  border: 1px solid var(--bc-cal-border);
  border-radius: 10px;
  background: var(--bc-cal-elevated, #243247);
  color: var(--bc-cal-fg, #f1f5f9);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
}

.bc-cal-sidebar-toggle:hover {
  border-color: var(--bc-cal-accent, #14b8a6);
}

.bc-cal-sidebar-toggle-title {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.78rem;
  color: var(--bc-cal-muted);
}

.bc-cal-sidebar-toggle-meta {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--bc-cal-fg);
  text-align: right;
}

.bc-cal-sidebar-toggle-chevron {
  font-size: 0.85rem;
  color: var(--bc-cal-accent, #14b8a6);
  min-width: 1.25rem;
  text-align: center;
}

.bc-cal-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bc-cal-sidebar h4 {
  margin: 0 0 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bc-cal-muted);
}

.bc-cal-cal-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bc-cal-cal-item,
button.bc-cal-cal-item,
label.bc-cal-cal-item {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  pointer-events: auto !important;
  touch-action: manipulation;
  min-height: 44px;
  box-sizing: border-box;
  margin: 0;
}

button.bc-cal-cal-item:focus-visible {
  outline: 2px solid var(--bc-cal-accent, #14b8a6);
  outline-offset: 1px;
}

.bc-cal-cal-item:hover { background: rgba(255,255,255,0.05); }

.bc-cal-check {
  flex-shrink: 0;
  width: 1.35rem;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--bc-cal-muted);
}

.bc-cal-check.is-on {
  color: var(--bc-cal-accent, #14b8a6);
}

.bc-cal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid transparent;
}

.bc-cal-dot.off { opacity: 0.35; }

.bc-cal-cal-meta {
  font-size: 0.7rem;
  color: var(--bc-cal-muted);
  margin-left: auto;
}

.bc-cal-select {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--bc-cal-border);
  background: var(--bc-cal-elevated, #243247);
  color: var(--bc-cal-fg, #f1f5f9);
  font-size: 1rem;
  font-family: inherit;
}

.bc-cal-main {
  min-width: 0;
  /* min-height:0 + flex:1 → füllt Rest unter Toolbar/Sidebar und scrollt intern */
  min-height: 0;
  flex: 1;
  padding: 4px;
  background: var(--bc-cal-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bc-cal-main .k-scheduler {
  flex: 1;
  min-height: 0;
  border: 0;
  background: transparent;
}

/* Agenda / Liste – intern scrollen (Parent .bc-cal hat overflow:hidden) */
.bc-cal-agenda {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 8px 12px 16px;
}

.bc-cal-agenda-day {
  margin: 12px 0 6px;
  font-size: 0.85rem;
  font-weight: 900;
  /* Hoher Kontrast: dunkel auf Amber, nie Gelb auf Weiß */
  color: #0f172a !important;
  background: #facc15;
  border: 2px solid #0f172a;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bc-cal-agenda-item,
button.bc-cal-agenda-item {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--bc-cal-elevated);
  border-radius: var(--bb-radius-sm, 10px);
  border: 1px solid var(--bc-cal-border);
  border-left: 4px solid var(--bc-cal-accent);
  cursor: pointer;
  transition: transform var(--bb-motion, 160ms ease), background var(--bb-motion, 160ms ease), border-color var(--bb-motion, 160ms ease);
  min-height: 64px;
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.15);
  user-select: none;
  width: 100%;
  text-align: left;
  color: inherit;
  font: inherit;
}

.bc-cal-agenda-item:hover {
  background: var(--bb-surface-elevated, #2a3a52);
  border-color: rgba(20, 184, 166, 0.35);
  transform: translateY(-1px);
}

.bc-cal-agenda-time {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--bc-cal-muted);
}

.bc-cal-agenda-title {
  font-weight: 600;
  margin: 0 0 2px;
}

.bc-cal-agenda-sub {
  margin: 0;
  font-size: 0.8rem;
  color: var(--bc-cal-muted);
}

.bc-cal-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0,168,132,0.2);
  color: var(--bc-cal-accent);
  white-space: nowrap;
}

.bc-cal-status {
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--bc-cal-muted);
  border-top: 1px solid var(--bc-cal-border);
}

.bc-cal-status.is-error { color: #ff8a80; }
.bc-cal-status.is-ok { color: var(--bc-cal-accent); }

/* Dialog – hoher z-index; overflow nicht clippen (Dropdowns) */
.bc-cal-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2147482000;
}

.bc-cal-dialog {
  position: fixed;
  z-index: 2147482100;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 24px));
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bb-surface, #1e293b), var(--bb-bg-soft, #111827));
  color: var(--bc-cal-fg);
  border: 1px solid var(--bc-cal-border);
  border-radius: var(--bb-radius-xl, 24px);
  box-shadow: var(--bb-shadow, 0 16px 48px rgba(0,0,0,0.45));
  /* visible: native select / Telerik-Popup nicht abschneiden */
  overflow: visible;
}

.bc-cal-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--bc-cal-border);
}

.bc-cal-dialog-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.bc-cal-icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--bc-cal-muted);
  font-size: 1.5rem;
  line-height: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
}

.bc-cal-icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--bc-cal-fg); }

.bc-cal-dialog-body {
  padding: 14px 16px;
  overflow-y: auto;
  overflow-x: visible;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(70vh, 560px);
  -webkit-overflow-scrolling: touch;
}

/* Telerik-Popups über dem Termin-Dialog */
.k-animation-container,
.k-animation-container-shown {
  z-index: 2147483600 !important;
}

.bc-cal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.bc-cal-field > span {
  color: var(--bc-cal-muted);
  font-weight: 600;
}

.bc-cal-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 480px) {
  .bc-cal-field-row { grid-template-columns: 1fr; }
}

/* Datum/Zeit im Termin-Dialog: volle Breite der Spalte */
.bc-cal-field .bb-datetime-picker {
  width: 100%;
}

.bc-cal-field .bb-dt-input {
  width: 100%;
  background: var(--bc-cal-elevated, var(--bb-surface-2, #243247));
  border-color: var(--bc-cal-border, var(--bb-border));
  color: var(--bc-cal-fg, var(--bb-fg));
}

.bc-cal-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.bc-cal-hint {
  color: var(--bc-cal-muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.bc-cal-vorgang-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.bc-cal-vorgang-row > :first-child { flex: 1; }

.bc-cal-dialog-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--bc-cal-border);
  align-items: center;
}

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

.bc-cal-error {
  background: rgba(234, 67, 53, 0.15);
  color: #ff8a80;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.bc-cal-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bc-cal-muted);
}

.bc-cal-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.bc-cal-doc-preview {
  margin-top: 8px;
  max-height: 360px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--bc-border, rgba(134,150,160,0.25));
}

/* Kompaktmodus: kein interner Höhen-Käfig */
.bc-cal.is-compact {
  min-height: 0;
  max-height: none;
  height: auto !important;
}

.bc-cal.is-compact .bc-cal-sidebar {
  display: none;
}

.bc-cal.is-compact .bc-cal-body {
  grid-template-columns: 1fr;
}

.bc-cal.is-compact .bc-cal-toolbar {
  padding: 8px;
  gap: 6px;
}

/* Kompakt/Home: mit der Seite mitscrollen, kein interner Käfig */
.bc-cal.is-compact .bc-cal-main,
.bc-cal.is-compact .bc-cal-agenda {
  overflow: visible !important;
  max-height: none !important;
  height: auto !important;
  min-height: 0;
  flex: none;
}

.bc-cal-agenda-item {
  min-height: 64px;
}

/* TermineListe – hoher Kontrast (Baustelle), page scroll, Buttons */
.bc-term-list,
.bc-term-list-hi {
  width: 100%;
  color: #0f172a !important;
  font-family: var(--bb-font, system-ui, sans-serif);
  padding: 4px 8px 20px;
  position: relative;
  z-index: 20;
  pointer-events: auto !important;
  isolation: isolate;
}

.bc-term-list-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 8px;
}

.bc-term-list-title {
  font-weight: 900;
  font-size: 1.15rem;
  color: #0f172a !important;
  background: #facc15 !important;
  border: 2px solid #0f172a;
  padding: 4px 10px;
  border-radius: 8px;
}

.bc-term-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bc-term-list-range {
  font-size: 0.9rem;
  color: #0f172a;
  font-weight: 800;
  padding: 0 4px 10px;
}

a.bc-term-btn,
button.bc-term-btn,
.bc-term-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0f172a;
  background: #e2e8f0;
  color: #0f172a !important;
  font-weight: 900;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none !important;
  box-sizing: border-box;
}

a.bc-term-btn-primary,
.bc-term-btn-primary {
  background: #0369a1 !important;
  color: #ffffff !important;
  border-color: #0f172a;
}

/* Tageskopf: SCHWARZ auf GELB – nie Gelb auf Weiß */
.bc-term-day {
  margin: 12px 4px 6px;
  font-size: 0.9rem;
  font-weight: 900;
  color: #0f172a !important;
  background: #facc15 !important;
  border: 2px solid #0f172a;
  display: inline-block;
  padding: 4px 12px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 0 #0f172a;
}

/* Terminzeile als Button */
a.bc-term-row,
button.bc-term-row,
.bc-term-row {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  grid-template-columns: 78px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 14px 12px;
  margin: 0 0 8px;
  background: #ffffff;
  color: #0f172a !important;
  text-decoration: none !important;
  border: 3px solid #0f172a;
  border-left: 8px solid #0369a1;
  border-radius: 12px;
  cursor: pointer;
  min-height: 72px;
  box-shadow: 0 3px 0 #020617;
  touch-action: manipulation;
  pointer-events: auto !important;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  font: inherit;
}

a.bc-term-row:hover,
button.bc-term-row:hover {
  background: #f0f9ff;
  color: #0f172a !important;
  text-decoration: none !important;
}

a.bc-term-row:active,
button.bc-term-row:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #020617;
}

.bc-term-row > * {
  pointer-events: none;
}

.bc-term-time {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  font-weight: 900;
  color: #0f172a;
}

.bc-term-name {
  font-weight: 900;
  font-size: 1.05rem;
  color: #020617;
  line-height: 1.2;
}

.bc-term-meta {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 2px;
}

.bc-term-badge {
  font-size: 0.7rem;
  font-weight: 900;
  padding: 4px 8px;
  border-radius: 999px;
  background: #facc15;
  color: #0f172a;
  border: 2px solid #0f172a;
  white-space: nowrap;
}

.bc-term-empty {
  text-align: center;
  padding: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  background: #fef9c3;
  border: 2px solid #0f172a;
  border-radius: 12px;
  margin: 8px 4px;
}

.bc-term-status {
  padding: 8px;
  font-weight: 800;
  color: #7f1d1d;
  background: #fecaca;
  border-radius: 8px;
}
