/*
 * @hb/shared-frontend/styles/calendar.css
 * Styles für die CalendarView-Komponente. Pro Seite separat einbinden.
 */

.cv-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 480px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.cv-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  gap: var(--space-3);
  flex-wrap: wrap;
}

.cv-nav { display: flex; gap: 4px; }
.cv-nav .btn { padding: 6px 10px; font-size: var(--font-size-md); }
.cv-title { margin: 0; font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); }
.cv-view-toggle { display: flex; gap: 0; border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.cv-view-toggle .btn { padding: 6px 14px; font-size: var(--font-size-sm); border-radius: 0; }
.cv-view-toggle .is-active { background: var(--color-brand-primary); color: var(--color-brand-primary-on); }

.cv-body { flex: 1; overflow-y: auto; }

.cv-toast {
  padding: 10px 16px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  background: #fde2e2;
  color: #991b1b;
  border-bottom: 1px solid #fca5a5;
}
.cv-toast[data-type="success"] {
  background: #d1fae5;
  color: #065f46;
  border-bottom-color: #6ee7b7;
}
.cv-toast[data-type="warn"] {
  background: #fef3c7;
  color: #92400e;
  border-bottom-color: #fcd34d;
}

/* === Wochenansicht === */
.cv-week-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  grid-template-rows: auto auto 1fr;
  position: relative;
}

.cv-week-corner { border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border); }

.cv-week-dayhead {
  padding: var(--space-2) var(--space-2);
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}
.cv-week-dayhead.is-today { background: var(--color-brand-primary-soft); }
.cv-week-dayhead.is-feiertag { background: #fef3c7; }
.cv-week-dayhead.is-ferien { background: #e0f2fe; }
.cv-week-day-holiday {
  font-size: 10px;
  color: #92400e;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-week-day-absence {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}
.cv-week-day-absence-urlaub { background: #d1fae5; color: #065f46; }
.cv-week-day-absence-krank  { background: #fde2e2; color: #991b1b; }

.cv-week-day-occasion {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cv-week-day-occasion-geburtstag      { background: #fce7f3; color: #9d174d; }
.cv-week-day-occasion-jubilaeum       { background: #dbeafe; color: #1e40af; }
.cv-week-day-occasion-firmenjubilaeum { background: #fef3c7; color: #92400e; }

/* Klickbar wenn ein Urlaubs-/Krank-Eintrag dranhängt */
.cv-week-dayhead[data-entry-id] { cursor: pointer; }
.cv-week-dayhead[data-entry-id]:hover .cv-week-day-absence { filter: brightness(0.95); }
.cv-week-dayname { font-size: var(--font-size-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: var(--font-weight-semibold); }
.cv-week-daydate { font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); }

.cv-week-allday-label,
.cv-week-allday-cell {
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  min-height: 28px;
  padding: 4px;
  font-size: var(--font-size-xs);
  cursor: pointer;
}
.cv-week-allday-cell.is-feiertag      { background: rgba(254, 243, 199, 0.55); }
.cv-week-allday-cell.is-ferien        { background: rgba(224, 242, 254, 0.45); }
.cv-week-allday-cell.is-absence-urlaub { background: rgba(187, 247, 208, 0.55); }
.cv-week-allday-cell.is-absence-krank  { background: rgba(254, 202, 202, 0.55); }
.cv-week-allday-label { color: var(--color-text-muted); text-align: right; padding-right: 8px; line-height: 28px; }
.cv-week-allday {
  display: block;
  padding: 2px 6px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cv-week-hours {
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}
.cv-week-hour {
  position: relative;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.cv-week-hour span { position: absolute; top: -8px; right: 4px; background: var(--color-surface-alt); padding: 0 4px; }

.cv-week-daycol {
  position: relative;
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 35px,
      var(--color-border) 35px,
      var(--color-border) 36px
    );
}
.cv-week-daycol.is-feiertag::before,
.cv-week-daycol.is-ferien::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.cv-week-daycol.is-feiertag::before { background: rgba(254, 243, 199, 0.55); }
.cv-week-daycol.is-ferien::before   { background: rgba(224, 242, 254, 0.45); }

.cv-week-daycol.is-absence-urlaub::after,
.cv-week-daycol.is-absence-krank::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.cv-week-daycol.is-absence-urlaub::after { background: rgba(187, 247, 208, 0.55); }
.cv-week-daycol.is-absence-krank::after  { background: rgba(254, 202, 202, 0.55); }

.cv-week-dayhead.is-absence-urlaub { background: rgba(187, 247, 208, 0.6); }
.cv-week-dayhead.is-absence-krank  { background: rgba(254, 202, 202, 0.6); }

.cv-week-daycol-bg {
  position: absolute;
  left: 0; right: 0;
  background: color-mix(in srgb, var(--color-brand-primary) 6%, transparent);  /* dezente Markenfarbe für Arbeitszeit-Hintergrund */
  pointer-events: none;
}

.cv-week-selection {
  position: absolute;
  left: 2px;
  right: 2px;
  background: var(--color-brand-primary-soft);
  border: 2px dashed var(--color-brand-primary);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: var(--font-size-xs);
  font-family: var(--font-family-mono);
  font-weight: var(--font-weight-semibold);
  color: var(--color-brand-primary);
  z-index: 3;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.cv-week-entry {
  position: absolute;
  /* left + width werden inline gesetzt (Side-by-Side bei Überlappung) */
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: var(--font-size-xs);
  border: 1px solid rgba(0, 0, 0, 0.05);
  cursor: grab;
  z-index: 2;
  overflow: hidden;
}
.cv-week-entry:active { cursor: grabbing; }
.cv-week-entry.is-dragging {
  cursor: grabbing;
  opacity: 0.85;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  z-index: 5;
}
.cv-week-entry-title { font-weight: var(--font-weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-week-entry-time { opacity: 0.7; font-family: var(--font-family-mono); }

/* Vorlauf/Tour/Nachlauf als 3 separate Blöcke mit Rahmen + Gap */
.cv-week-entry-wrap {
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
  background: transparent;
  border: none !important;
}
.cv-week-entry-seg {
  box-sizing: border-box;
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.cv-week-entry-vorlauf,
.cv-week-entry-nachlauf {
  background-color: rgba(0, 0, 0, 0.03);
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(0, 0, 0, 0) 0 5px,
    rgba(0, 0, 0, 0.18) 5px 10px
  );
}
.cv-week-entry-tour {
  flex: 1;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
}
.cv-week-entry-gap { flex: 0 0 auto; }

.cv-week-resize {
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  z-index: 3;
}
.cv-week-resize-top { top: -2px; }
.cv-week-resize-bottom { bottom: -2px; }
.cv-week-entry:hover .cv-week-resize::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.5;
}
.cv-week-entry:hover .cv-week-resize-top::after { top: 2px; }
.cv-week-entry:hover .cv-week-resize-bottom::after { bottom: 2px; }

/* === Monatsansicht === */
.cv-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(110px, auto);
}
.cv-month-dayhead {
  padding: var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  text-align: center;
}
.cv-month-cell {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cv-month-cell.is-other-month { background: var(--color-surface-muted); color: var(--color-text-subtle); }
.cv-month-cell.is-today { background: var(--color-brand-primary-soft); }
.cv-month-cell.is-feiertag { background: #fef3c7; }
.cv-month-cell.is-ferien   { background: #e0f2fe; }
.cv-month-cell.is-absence-urlaub { background: #d1fae5; }
.cv-month-cell.is-absence-krank  { background: #fee2e2; }
.cv-month-holiday-tag {
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  color: #92400e;
  margin-left: 6px;
}
.cv-month-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  vertical-align: baseline;
  line-height: 1.3;
}
.cv-month-tag-feiertag        { background: #fef3c7; color: #92400e; }
.cv-month-tag-geburtstag      { background: #fce7f3; color: #9d174d; }
.cv-month-tag-jubilaeum       { background: #dbeafe; color: #1e40af; }
.cv-month-tag-firmenjubilaeum { background: #fde68a; color: #78350f; font-weight: var(--font-weight-semibold); }
.cv-month-tag-urlaub   { background: #bbf7d0; color: #065f46; }
.cv-month-tag-krank    { background: #fecaca; color: #991b1b; }
.cv-month-cell.is-selecting {
  background: var(--color-brand-primary-soft);
  outline: 2px dashed var(--color-brand-primary);
  outline-offset: -2px;
}
.cv-month-cell-head { font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); margin-bottom: 4px; }
.cv-month-entry {
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cv-month-more { font-size: var(--font-size-xs); color: var(--color-text-muted); }
