/* assets/css/calendar_embed.css
   Gekapseltes Stylesheet für das eingebettete Kalender-Modul.
   Alle Regeln sind unter .kv-cal-scope gescoped, damit:
     - Styles der externen Seite den Kalender nicht überschreiben
     - Kalender-Styles nicht in die externe Seite "auslaufen"
   Enthält alle Regeln aus app.css (kalenderrelevant) und calendar.css (vollständig).
*/

/* -------------------------
   Scoped Reset
   ------------------------- */
.kv-cal-scope *,
.kv-cal-scope *::before,
.kv-cal-scope *::after {
  box-sizing: border-box;
}

/* -------------------------
   Basis-Typografie und Links
   ------------------------- */
.kv-cal-scope {
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: #222;
  -webkit-font-smoothing: antialiased;
}
.kv-cal-scope img {
  max-width: 100%;
  height: auto;
  display: block;
}
.kv-cal-scope a {
  color: #0068c6;
  text-decoration: none;
}
.kv-cal-scope a:hover {
  text-decoration: underline;
}

/* -------------------------
   Card
   ------------------------- */
.kv-cal-scope .card {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.03);
}

/* -------------------------
   Buttons
   ------------------------- */
.kv-cal-scope .btn,
.kv-cal-scope .button {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 6px;
  background: #0078d4;
  color: #fff;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background .12s ease, transform .06s ease;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.4;
}
.kv-cal-scope .btn.secondary,
.kv-cal-scope .button.secondary {
  background: #f3f4f6;
  color: #222;
  font-weight: 600;
  border: 1px solid #e6e6e6;
}
.kv-cal-scope .btn.primary,
.kv-cal-scope .button.primary {
  background: #0078d4;
  color: #fff;
  border: none;
}
.kv-cal-scope .btn.small,
.kv-cal-scope .button.small {
  padding: 6px 8px;
  font-size: 0.9rem;
  border-radius: 5px;
}
.kv-cal-scope .btn:hover,
.kv-cal-scope .button:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}
.kv-cal-scope .btn:active,
.kv-cal-scope .button:active {
  transform: translateY(0);
}

/* -------------------------
   Formulare (nur innerhalb des Scopes)
   ------------------------- */
.kv-cal-scope input[type="text"],
.kv-cal-scope input[type="email"],
.kv-cal-scope input[type="number"],
.kv-cal-scope input[type="date"],
.kv-cal-scope input[type="time"],
.kv-cal-scope select,
.kv-cal-scope textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #dcdcdc;
  border-radius: 6px;
  background: #fff;
  font-size: 1rem;
  color: #111;
  outline: none;
  transition: box-shadow .12s ease, border-color .12s ease;
  font-family: inherit;
  box-sizing: border-box;
}
.kv-cal-scope input:focus,
.kv-cal-scope select:focus,
.kv-cal-scope textarea:focus {
  border-color: #80b7ff;
  box-shadow: 0 0 0 3px rgba(0,120,212,0.08);
}
.kv-cal-scope label {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: #333;
}
.kv-cal-scope .small { font-size: 0.9rem; }
.kv-cal-scope .muted { color: #666; font-size: 0.95rem; }
.kv-cal-scope h2 { font-size: 1.4rem; font-weight: 700; margin-top: 0; color: #111; }

/* -------------------------
   Calendar Container
   ------------------------- */
.kv-cal-scope .calendar-root {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* -------------------------
   Toolbar
   ------------------------- */
.kv-cal-scope .calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.kv-cal-scope .calendar-toolbar .nav {
  display: flex;
  gap: 8px;
  align-items: center;
}
.kv-cal-scope .calendar-toolbar .nav button {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #e6e6e6;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  color: #111;
}
.kv-cal-scope .calendar-toolbar .period-label {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 8px;
}
.kv-cal-scope .view-switch {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* -------------------------
   Month grid table
   ------------------------- */
.kv-cal-scope .month-calendar {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}
.kv-cal-scope .month-calendar th,
.kv-cal-scope .month-calendar td {
  border: 1px solid #e6e6e6;
  vertical-align: top;
  padding: 6px;
  width: 14.2857%;
}
.kv-cal-scope .month-calendar tbody {
  --rows: 5;
}
.kv-cal-scope .month-calendar td {
  height: calc(min(80vh, 600px) / var(--rows));
}
.kv-cal-scope .month-calendar th {
  background: #fafafa;
  font-weight: 600;
  text-align: center;
}

/* -------------------------
   Day cell
   ------------------------- */
.kv-cal-scope .cal-day {
  min-height: 100%;
  position: relative;
  padding-top: 22px;
}
.kv-cal-scope .cal-day .day-num {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 12px;
  color: #666;
  line-height: 1;
}
.kv-cal-scope .cal-today {
  background: linear-gradient(90deg, #fffbe6, #fff);
  box-shadow: inset 0 0 0 2px rgba(74,144,226,0.06);
}
.kv-cal-scope .cal-muted {
  opacity: 0.45;
}

/* -------------------------
   Event item (calendar cells)
   ------------------------- */
.kv-cal-scope .cal-event {
  display: block;
  background: #f3f8ff;
  border-left: 4px solid #4a90e2;
  padding: 4px 6px;
  margin: 4px 0;
  border-radius: 3px;
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.kv-cal-scope .cal-event:hover {
  opacity: 0.82;
}
.kv-cal-scope .cal-event .time {
  font-weight: 600;
  margin-right: 5px;
}
.kv-cal-scope .cal-event .meta {
  font-size: 0.82rem;
  color: #444;
  margin-top: 4px;
}

/* Club-internal event marker */
.kv-cal-scope .cal-event.club-internal {
  outline: 1.5px solid var(--club-internal-color, #00e600);
  box-shadow: 0 0 8px 3px color-mix(in srgb, var(--club-internal-color, #00e600) 40%, transparent);
}

/* Conflict marker */
.kv-cal-scope .cal-event.conflict {
  outline: 2px solid rgba(255,185,77,0.65);
}

/* Status indicators (for app.css compat.) */
.kv-cal-scope .event-item.status-accepted { background: #f7fff0; border-left-color: #2e7d32; }
.kv-cal-scope .event-item.status-reserved { background: #fffbe6; border-left-color: #f6c24b; }
.kv-cal-scope .event-item.status-rejected { background: #fff5f5; border-left-color: #d32f2f; }

/* -------------------------
   Trainer color dot
   ------------------------- */
.kv-cal-scope .trainer-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06) inset;
}

/* -------------------------
   List view
   ------------------------- */
.kv-cal-scope .calendar-list {
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fff;
}
.kv-cal-scope .calendar-list .item {
  padding: 10px;
  border-bottom: 1px solid #f5f5f5;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: background .1s;
}
.kv-cal-scope .calendar-list .item:hover {
  background: #f9fafb;
}
.kv-cal-scope .calendar-list .item:last-child {
  border-bottom: none;
}
.kv-cal-scope .calendar-list .item .left {
  max-width: 70%;
}
.kv-cal-scope .calendar-list .item .right {
  text-align: right;
  color: #666;
  font-weight: 600;
}

/* -------------------------
   Week / Day views
   ------------------------- */
.kv-cal-scope .calendar-dayview,
.kv-cal-scope .calendar-weekview {
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fff;
  padding: 8px;
}
.kv-cal-scope .calendar-week {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 8px;
}
.kv-cal-scope .dayview-grid {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 8px;
}
.kv-cal-scope .dayview-hours {
  border-right: 1px solid #f0f0f0;
}
.kv-cal-scope .hour-slot {
  height: 48px;
  padding: 6px;
  color: #666;
  font-size: 0.85rem;
  box-sizing: border-box;
}
.kv-cal-scope .dayview-events {
  position: relative;
}
.kv-cal-scope .dayview-event {
  position: absolute;
  left: 6px;
  right: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #fff;
  border-left: 4px solid #666;
  box-shadow: 0 6px 14px rgba(16,24,40,0.06);
  overflow: hidden;
}

/* -------------------------
   Detail popup / tooltip
   ------------------------- */
.kv-cal-scope .calendar-tooltip {
  position: fixed;
  z-index: 1200;
  min-width: 220px;
  max-width: 420px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 6px;
  padding: 10px;
  box-shadow: 0 12px 36px rgba(16,24,40,0.12);
  font-size: 0.95rem;
}
.kv-cal-scope .calendar-tooltip h4 {
  margin: 0 0 6px 0;
  font-size: 1rem;
}
.kv-cal-scope .calendar-tooltip .contacts {
  margin-top: 8px;
  font-size: 0.92rem;
}

/* Gepinntes Popover (HTML Popover API) */
[popover].kv-cal-popover {
  position: fixed;
  inset: unset;
  margin: 0;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 8px 28px rgba(16,24,40,0.14);
  max-width: 280px;
  font-size: 15px;
  pointer-events: auto;
  color: #222;
  overflow: visible;
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
  text-align: left;
  word-break: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}
[popover].kv-cal-popover:popover-open {
  border-color: rgba(26,115,232,0.35);
  box-shadow: 0 8px 28px rgba(26,115,232,0.25);
}

/* Flyer preview */
.kv-cal-scope .flyer-preview {
  display: block;
  width: 100%;
  max-height: 360px;
  margin-top: 8px;
  border: 1px solid #eee;
  border-radius: 4px;
  overflow: hidden;
  background: #fafafa;
  text-align: center;
  padding: 8px;
}

/* -------------------------
   Legend
   ------------------------- */
.kv-cal-scope .calendar-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.kv-cal-scope .calendar-legend-trainers {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.kv-cal-scope .calendar-legend-status {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.kv-cal-scope .calendar-legend .item {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.9rem;
  color: #555;
}
.kv-cal-scope .calendar-legend .swatch {
  width: 12px         !important;
  height: 12px        !important;
  min-width: 12px     !important;
  min-height: 12px    !important;
  border-radius: 3px  !important;
  display: inline-block !important;
  flex-shrink: 0      !important;
  padding: 0          !important;
  margin: 0           !important;
  box-sizing: border-box !important;
}
.kv-cal-scope .calendar-legend .swatch.club-internal {
  outline: 1.5px solid var(--club-internal-color, #00e600);
  box-shadow: 0 0 8px 3px color-mix(in srgb, var(--club-internal-color, #00e600) 40%, transparent);
}

/* -------------------------
   Empty state
   ------------------------- */
.kv-cal-scope .calendar-empty {
  padding: 28px;
  text-align: center;
  color: #666;
}

/* -------------------------
   Error / info banners
   ------------------------- */
.kv-cal-scope .kv-error-banner {
  border-left: 4px solid #e81123;
  background: #fff5f5;
  color: #4a1212;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 3px;
}

/* -------------------------
   Drag & Drop placeholder
   ------------------------- */
.kv-cal-scope .drag-placeholder {
  border: 2px dashed rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.6);
  border-radius: 6px;
  padding: 8px;
  min-height: 30px;
}

/* -------------------------
   Hover-Tooltip & Pinned Popover
   (ausserhalb .kv-cal-scope, direkt an body angehaengt → ID-Scope statt Klassen-Scope)
   ------------------------- */
#kvCalHoverTip {
  box-sizing: border-box;
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #222;
  line-height: 1.4;
  text-align: left;
}
#kvCalHoverTip * {
  box-sizing: border-box;
}
#kvCalHoverTip a {
  color: #1a73e8;
  text-decoration: none;
}
#kvCalHoverTip a:hover {
  text-decoration: underline;
}
#kvCalHoverTip img {
  max-width: 100%;
  border: none;
  vertical-align: middle;
}
/* Flyer-Bild im Tooltip: gegen externe img-Resets absichern */
#kvCalHoverTip .kv-flyer-img,
#kvCalPinnedPop .kv-flyer-img {
  width:         100%       !important;
  max-width:     100%       !important;
  max-height:    160px      !important;
  height:        auto       !important;
  object-fit:    contain    !important;
  display:       block      !important;
  margin-bottom: 6px        !important;
  border-radius: 4px        !important;
  border:        none       !important;
}
/* Zoom-Cursor im gepinnten Popover */
#kvCalPinnedPop .kv-flyer-img,
#kvCalPinnedPop .kv-avatar-wrap {
  cursor: zoom-in !important;
}
/* Vollbild-Overlay (kvShowFullImage): gegen externe CSS-Resets absichern */
.kv-fullimg-overlay {
  position:        fixed                   !important;
  inset:           0                       !important;
  background:      rgba(0,0,0,.82)         !important;
  z-index:         99999                   !important;
  display:         flex                    !important;
  align-items:     center                  !important;
  justify-content: center                  !important;
  cursor:          zoom-out                !important;
  width:           100%                    !important;
  height:          100%                    !important;
  padding:         0                       !important;
  margin:          0                       !important;
  border:          none                    !important;
  box-sizing:      border-box              !important;
}
.kv-fullimg-overlay .kv-fullimg-img {
  max-width:     90vw                      !important;
  max-height:    90vh                      !important;
  width:         auto                      !important;
  height:        auto                      !important;
  object-fit:    contain                   !important;
  border-radius: 6px                       !important;
  box-shadow:    0 8px 40px rgba(0,0,0,.6) !important;
  display:       block                     !important;
  border:        none                      !important;
  margin:        0                         !important;
  padding:       0                         !important;
}
#kvCalHoverTip strong {
  font-weight: 600;
}
#kvCalHoverTip div {
  margin: 0;
  padding: 0;
}
/* Avatar-Wrapper: Größe per !important gegen externe CSS-Resets absichern */
#kvCalHoverTip .kv-avatar-wrap,
#kvCalPinnedPop .kv-avatar-wrap {
  width:      40px !important;
  height:     40px !important;
  min-width:  40px !important;
  max-width:  40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  overflow:   hidden !important;
  flex-shrink: 0    !important;
  border-radius: 50% !important;
  border: 2px solid #e6e6e6 !important;
  float: right !important;
  margin: 0 0 6px 10px !important;
  padding: 0 !important;
  display: block !important;
  box-sizing: border-box !important;
}
#kvCalHoverTip .kv-avatar-wrap img,
#kvCalPinnedPop .kv-avatar-wrap img {
  width:        100% !important;
  height:       100% !important;
  max-width:    100% !important;
  max-height:   100% !important;
  object-fit:   cover !important;
  display:      block !important;
  border-radius: 50% !important;
  border: none !important;
}

#kvCalPinnedPop {
  box-sizing: border-box;
}
#kvCalPinnedPop * {
  box-sizing: border-box;
}
#kvCalPinnedPop a {
  color: #1a73e8;
  text-decoration: none;
}
#kvCalPinnedPop a:hover {
  text-decoration: underline;
}
#kvCalPinnedPop img {
  max-width: 100%;
  border: none;
  vertical-align: middle;
}
#kvCalPinnedPop strong {
  font-weight: 600;
}

/* -------------------------
   Responsive
   ------------------------- */
@media (max-width: 900px) {
  .kv-cal-scope .calendar-toolbar { flex-wrap: wrap; gap: 6px; }
}
@media (max-width: 640px) {
  .kv-cal-scope .month-calendar { font-size: 0.85rem; }
  .kv-cal-scope .view-switch { margin-left: 8px; }
  .kv-cal-scope .dayview-grid { grid-template-columns: 50px 1fr; }
}

/* -------------------------
   Print
   ------------------------- */
@media print {
  .kv-cal-scope .calendar-toolbar,
  .kv-cal-scope .view-switch,
  .kv-cal-scope .calendar-legend,
  .kv-cal-scope .calendar-empty { display: none !important; }
  .kv-cal-scope .calendar-list { page-break-after: auto; }
  .kv-cal-scope .cal-day { page-break-inside: avoid; }
}
