/* ============================================================
   BOSSMANN KALENDER-MODUL – Design
   Anpassbare Bereiche sind klar markiert.
   ============================================================ */

/* ---------- FARBEN (hier global ändern) ---------- */
:root {
  --teal: #0f766e;
  --teal-dark: #0d5c56;
  --teal-soft: #f0fdfa;
  --gold: #e8a317;
  --gold-soft: #fef6e6;
  --coral: #d0a03c;
  --coral-soft: #fdf0ec;
  --violet: #7c6bb5;
  --violet-soft: #f3f0fa;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --white: #ffffff;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Termin-Farben (Kurse parallel = gut unterscheidbar) */
  --ev-teal: #0d9488;
  --ev-gold: #b8862a;
  --ev-coral: #d0a03c;
  --ev-violet: #7c3aed;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--gray-700);
  background: var(--gray-50);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- LAYOUT ---------- */
.cal-app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.cal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.cal-header h1 {
  font-size: 1.5rem;
  color: var(--teal);
  font-weight: 700;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cal-nav button {
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-700);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.15s, border-color 0.15s;
}
.cal-nav button:hover {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
}

.cal-title-label {
  min-width: 160px;
  text-align: center;
  font-weight: 600;
  color: var(--gray-900);
  font-size: 1.05rem;
}

/* View-Umschalter */
.cal-views {
  display: flex;
  gap: 0.35rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 0.25rem;
}
.cal-views button {
  border: none;
  background: transparent;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-500);
  transition: background 0.15s, color 0.15s;
}
.cal-views button.active {
  background: var(--teal);
  color: var(--white);
}
.cal-views button:hover:not(.active) {
  background: var(--gray-100);
  color: var(--teal);
}

/* ---------- LEGENDE ---------- */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--gray-500);
}
.cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.cal-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.cal-legend .c-teal { background: var(--ev-teal); }
.cal-legend .c-gold { background: var(--ev-gold); }
.cal-legend .c-coral { background: var(--ev-coral); }
.cal-legend .c-violet { background: var(--ev-violet); }

/* ---------- MONATSVIEW ---------- */
.view-panel { display: none; }
.view-panel.active { display: block; }

.month-grid {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--teal);
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}
.month-weekdays div { padding: 0.65rem 0.25rem; }

.month-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

/* Kästchen-Größe hier anpassen */
.day-cell {
  min-height: 110px;          /* ← Höhe der Tageskästchen */
  border-right: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
  padding: 0.4rem 0.35rem;
  vertical-align: top;
  position: relative;
  background: var(--white);
  transition: background 0.12s;
}
.day-cell:nth-child(7n) { border-right: none; }
.day-cell.other-month {
  background: var(--gray-50);
  color: var(--gray-500);
  opacity: 0.65;
}
.day-cell.today {
  background: var(--teal-soft);
}
.day-cell.today .day-num {
  background: var(--teal);
  color: var(--white);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.day-num {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
}

/* Termin-Chips im Monat */
.ev-chip {
  display: block;
  font-size: 0.72rem;
  line-height: 1.25;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  margin-bottom: 0.2rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--white);
  font-weight: 500;
  transition: transform 0.12s, box-shadow 0.12s;
}
.ev-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.ev-chip.teal { background: var(--ev-teal); }
.ev-chip.gold { background: var(--ev-gold); }
.ev-chip.coral { background: var(--ev-coral); }
.ev-chip.violet { background: var(--ev-violet); }

/* ---------- EINZEL-WOCHEN-VIEW (groß, wie Jahresformat) ---------- */
.weeks-wrap {
  display: block;
  width: 100%;
}
.week-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  width: 100%;
}
.week-card h3 {
  background: var(--teal);
  color: var(--white);
  font-size: 1.05rem;
  padding: 0.85rem 1.2rem;
  font-weight: 600;
}
.week-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 420px; /* großzügige Höhe wie Jahresblock */
}
.week-day-head {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-500);
  padding: 0.65rem 0.3rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}
.week-day-cell {
  min-height: 380px; /* viel Platz für Einträge, Text, Bilder */
  border-right: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
  padding: 0.5rem 0.45rem;
}
.week-day-cell:nth-child(7n) { border-right: none; }
.week-day-cell .day-num {
  font-size: 1rem;
  margin-bottom: 0.45rem;
}
.week-day-cell .ev-chip {
  font-size: 0.8rem;
  padding: 0.35rem 0.45rem;
  white-space: normal; /* mehrzeilig möglich */
  line-height: 1.3;
  margin-bottom: 0.35rem;
}
@media (max-width: 700px) {
  .week-days { grid-template-columns: 1fr; min-height: 0; }
  .week-day-cell { min-height: 100px; border-right: none; }
  .week-day-head { display: none; }
}

/* ---------- JAHRES-VIEW ---------- */
.year-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
@media (max-width: 1000px) {
  .year-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .year-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .year-grid { grid-template-columns: 1fr; }
}

.year-month {
  background: var(--white);
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 4px 14px rgba(15,23,42,0.05);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.year-month:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.year-month h4 {
  text-align: center;
  font-size: 0.9rem;
  padding: 0.55rem;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
}
.year-month .mini-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-size: 0.65rem;
  text-align: center;
  color: var(--gray-500);
  padding: 0.25rem 0.2rem 0;
  font-weight: 600;
}
.year-month .mini-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0.2rem;
  gap: 1px;
}
.mini-day {
  aspect-ratio: 1;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  position: relative;
  color: var(--gray-700);
}
.mini-day.other { color: var(--gray-200); }
.mini-day.today {
  background: var(--teal);
  color: var(--white);
  font-weight: 700;
}
.mini-day.has-event {
  font-weight: 700;
}
.mini-day .dot {
  position: absolute;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  left: 50%;
  transform: translateX(-50%);
}
.mini-day .dot.teal { background: var(--ev-teal); }
.mini-day .dot.gold { background: var(--ev-gold); }
.mini-day .dot.coral { background: var(--ev-coral); }
.mini-day .dot.violet { background: var(--ev-violet); }

/* ---------- POPUP / MODAL ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: pop 0.2s ease;
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-colorbar {
  height: 6px;
}
.modal-colorbar.teal { background: var(--ev-teal); }
.modal-colorbar.gold { background: var(--ev-gold); }
.modal-colorbar.coral { background: var(--ev-coral); }
.modal-colorbar.violet { background: var(--ev-violet); }

.modal-body { padding: 1.35rem 1.4rem 1.5rem; }
.modal-body h2 {
  font-size: 1.25rem;
  color: var(--gray-900);
  margin-bottom: 0.4rem;
}
.modal-meta {
  font-size: 0.88rem;
  color: var(--gray-500);
  margin-bottom: 0.9rem;
}
.modal-desc {
  font-size: 0.95rem;
  color: var(--gray-700);
  margin-bottom: 1.2rem;
  line-height: 1.55;
}
.modal-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: none;
}
.modal-img.show { display: block; }
.modal-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.15rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.12s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: var(--teal-dark); }
.btn-ghost {
  background: var(--gray-100);
  color: var(--gray-700);
}
.btn-ghost:hover { background: var(--gray-200); }

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.85rem;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
}
.modal { position: relative; }

/* ---------- HINWEIS / FOOTER MODUL ---------- */
.cal-note {
  margin-top: 1.5rem;
  font-size: 0.82rem;
  color: var(--gray-500);
  text-align: center;
}

/* ---------- INHALTSBLOCK unter der Ansicht ---------- */
.view-content-block {
  margin-top: 1.5rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
  display: none;
}
.view-content-block.visible { display: block; }
.view-content-block h3 {
  color: var(--teal);
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}
.view-content-block p {
  color: var(--gray-700);
  font-size: 0.95rem;
  line-height: 1.55;
}
.view-content-block img {
  max-width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 0.85rem;
}

/* ---------- ADMIN BUTTON (nur nach Login sichtbar) ---------- */
.admin-toggle {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 900;
  background: var(--teal);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(15,118,110,0.35);
  display: none;
}
.admin-toggle.visible { display: inline-flex; }
.admin-toggle:hover { background: var(--teal-dark); }

/* Login-Hinweis klein */
.admin-login-link {
  position: fixed;
  bottom: 0.5rem;
  left: 0.75rem;
  font-size: 0.7rem;
  color: var(--gray-500);
  opacity: 0.5;
  cursor: pointer;
  z-index: 800;
  border: none;
  background: none;
  text-decoration: underline;
}
.admin-login-link:hover { opacity: 1; color: var(--teal); }

/* ---------- ADMIN PANEL ---------- */
.admin-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  background: var(--white);
  box-shadow: -8px 0 32px rgba(0,0,0,0.15);
  z-index: 1100;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.admin-panel.open { transform: translateX(0); }

.admin-panel-header {
  padding: 1rem 1.2rem;
  background: var(--teal);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.admin-panel-header h2 { font-size: 1.1rem; margin: 0; }
.admin-panel-header button {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.admin-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem 2rem;
}

.admin-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--gray-100);
}
.admin-section h3 {
  font-size: 0.95rem;
  color: var(--teal);
  margin-bottom: 0.75rem;
}
.admin-section label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 0.25rem;
  margin-top: 0.6rem;
}
.admin-section input[type="text"],
.admin-section input[type="password"],
.admin-section input[type="number"],
.admin-section input[type="url"],
.admin-section input[type="datetime-local"],
.admin-section input[type="date"],
.admin-section select,
.admin-section textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}
.admin-section textarea { min-height: 70px; resize: vertical; }

.cat-row {
  display: grid;
  grid-template-columns: 28px 1fr 70px;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.45rem;
}
.cat-row input[type="color"] {
  width: 28px;
  height: 28px;
  border: none;
  padding: 0;
  cursor: pointer;
  background: none;
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.admin-actions .btn { font-size: 0.85rem; padding: 0.45rem 0.9rem; }

.event-list-admin {
  list-style: none;
  margin: 0.5rem 0;
  max-height: 180px;
  overflow-y: auto;
}
.event-list-admin li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
}
.event-list-admin li button {
  border: none;
  background: transparent;
  color: var(--coral);
  cursor: pointer;
  font-size: 0.8rem;
}

/* Login modal */
.login-box {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 16px 40px rgba(0,0,0,0.2);
}
.login-box h3 { color: var(--teal); margin-bottom: 1rem; }
.login-box label { display: block; font-size: 0.85rem; margin-bottom: 0.25rem; font-weight: 600; }
.login-box input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}
.login-error { color: #b91c1c; font-size: 0.85rem; margin-bottom: 0.5rem; display: none; }
.login-error.show { display: block; }

.year-jump {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.year-jump button {
  border: 1px solid var(--gray-200);
  background: white;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--gray-700);
}
.year-jump button.active,
.year-jump button:hover {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}
