/* DuoVerse Self-Hosted Web Fonts (DSGVO-konform, keine externen Web-Fonts) */
@import url('https://duoverse.de/fonts/fonts.css');

:root {
  --bg: #faf5ef;
  --bg-warm: #f6ede3;
  --sidebar-bg: #fdfaf7;
  --sidebar-border: #f0e5db;
  --card-bg: #ffffff;
  --card-border: #ede3da;
  --card-shadow: 0 4px 20px rgba(70, 45, 35, 0.04);
  --card-shadow-hover: 0 8px 28px rgba(70, 45, 35, 0.08);

  --text-main: #2b221b;
  --text-secondary: #5e4d41;
  --text-muted: #8e7c70;

  --terracotta: #a96b5b;
  --terracotta-hover: #94594a;
  --terracotta-light: #eedfd7;
  --terracotta-soft: #fbf3ed;

  --chip-green-bg: #eaf5ec;
  --chip-green-text: #27673c;
  --chip-yellow-bg: #fdf5e8;
  --chip-yellow-text: #936a1c;
  --chip-red-bg: #fdeeed;
  --chip-red-text: #a73c38;
  --chip-blue-bg: #eaf1f8;
  --chip-blue-text: #2d5a88;
  --chip-pink-bg: #fbeaf0;
  --chip-pink-text: #a33d62;

  --radius-pill: 9999px;
  --radius-card: 18px;
  --radius-sm: 12px;
  --touch-min: 44px;
}

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

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

/* ==========================================
   LAYOUT
   ========================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 270px;
  min-width: 270px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
  padding: 0.25rem 0.25rem 0.5rem;
}

.sidebar-brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.sidebar-brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.sidebar-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.55rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 500;
  font-size: 0.94rem;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-btn:hover {
  background: var(--terracotta-soft);
  color: var(--text-main);
}

.nav-btn.active {
  background: var(--terracotta);
  color: #ffffff;
  font-weight: 600;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.74rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--terracotta-light);
  color: var(--text-main);
  font-weight: 700;
}

.nav-btn.active .nav-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.source-filters {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.source-filter-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 36px;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.source-filter-label:hover {
  background: var(--bg-warm);
}

.source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.5rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--terracotta-light);
  color: var(--terracotta);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-meta {
  min-width: 0;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-household {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ==========================================
   MAIN CONTENT & TOPBAR
   ========================================== */
.main-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.4rem;
  background: rgba(253, 250, 247, 0.92);
  border-bottom: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mobile-menu-btn {
  display: none;
}

.current-period-label {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  min-width: 165px;
}

.content-area {
  padding: 1.25rem 1.4rem 2.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

/* ==========================================
   BUTTONS & INPUTS (>= 44px Touch-Target)
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: var(--touch-min);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-main);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover {
  background: var(--bg-warm);
}

.btn-primary {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--terracotta-hover);
  border-color: var(--terracotta-hover);
}

.btn-danger {
  background: var(--chip-red-bg);
  border-color: #f3c8c6;
  color: var(--chip-red-text);
}

.btn-danger:hover {
  background: #f9d9d7;
}

.btn-icon {
  min-width: var(--touch-min);
  padding: 0.5rem;
}

.btn-sm {
  min-height: var(--touch-min);
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  font: inherit;
  font-size: 0.94rem;
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid var(--terracotta-light);
  border-color: var(--terracotta);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--touch-min);
  cursor: pointer;
  font-size: 0.92rem;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--terracotta);
}

/* ==========================================
   CARDS & CALENDAR GRIDS
   ========================================== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 1.1rem 1.25rem;
}

.conflict-banner {
  background: var(--chip-yellow-bg);
  border: 1px solid #f0d7a8;
  color: var(--chip-yellow-text);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.calendar-grid-header {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.35rem 0;
}

.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.day-cell {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  min-height: 112px;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
}

.day-cell:hover {
  border-color: var(--terracotta);
  background: var(--terracotta-soft);
}

.day-cell.other-month {
  opacity: 0.48;
  background: var(--bg-warm);
}

.day-cell.is-today {
  border: 2px solid var(--terracotta);
  background: var(--terracotta-soft);
}

.day-number {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.day-cell.is-today .day-number {
  color: var(--terracotta);
}

.event-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
  border-radius: 7px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
  min-height: 24px;
}

.event-pill.is-done {
  opacity: 0.6;
  text-decoration: line-through;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.6rem;
}

.week-col {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 0.65rem;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.week-col-header {
  font-weight: 700;
  font-size: 0.88rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.agenda-list,
.task-list,
.birthday-grid,
.sync-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sync-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.sync-overview-item {
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--bg-soft, rgba(127, 127, 127, 0.06));
  font-size: 0.85rem;
  line-height: 1.45;
}

.sync-overview-item strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.88rem;
}

.sync-hint {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.45;
}

.sync-guide {
  margin-top: 0.75rem;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  background: var(--bg-soft, rgba(127, 127, 127, 0.05));
  font-size: 0.84rem;
  line-height: 1.5;
}

.sync-guide summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 32px;
}

.sync-guide summary::-webkit-details-marker {
  display: none;
}

.sync-guide[open] summary {
  margin-bottom: 0.45rem;
}

.sync-guide ol,
.sync-guide ul {
  margin: 0.25rem 0 0.25rem 1.2rem;
  padding: 0;
}

.sync-guide li {
  margin-bottom: 0.25rem;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

.custom-cal-add-btn {
  min-width: 32px;
  min-height: 32px;
  padding: 0 0.5rem;
  font-weight: 700;
  line-height: 1;
}

.custom-cal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.custom-cal-row .source-filter-label {
  flex: 1;
  min-width: 0;
}

.custom-cal-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1;
}

.custom-cal-delete:hover {
  color: var(--danger, #c0392b);
  background: rgba(192, 57, 43, 0.1);
}

.birthday-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  flex-wrap: wrap;
}

.item-row-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 220px;
}

.item-color-bar {
  width: 6px;
  height: 40px;
  border-radius: 4px;
  flex-shrink: 0;
}

.item-title {
  font-weight: 700;
  font-size: 0.96rem;
}

.item-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
}

.chip-green { background: var(--chip-green-bg); color: var(--chip-green-text); }
.chip-yellow { background: var(--chip-yellow-bg); color: var(--chip-yellow-text); }
.chip-red { background: var(--chip-red-bg); color: var(--chip-red-text); }
.chip-blue { background: var(--chip-blue-bg); color: var(--chip-blue-text); }
.chip-pink { background: var(--chip-pink-bg); color: var(--chip-pink-text); }

/* ==========================================
   MODALS & STRICT SCROLL-LOCK (DuoVerse Global Rule)
   ========================================== */
html.modal-open,
body.modal-open {
  overflow: hidden !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 34, 27, 0.52);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  overscroll-behavior: contain;
  touch-action: none;
}

.modal-overlay.open {
  display: flex;
}

.modal-dialog {
  width: 100%;
  max-width: 580px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: 0 20px 50px rgba(43, 34, 27, 0.2);
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 90dvh);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.08rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.15rem 1.25rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ==========================================
   TOAST & NOTIFICATION BELL
   ========================================== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 340px;
}

.toast {
  background: var(--text-main);
  color: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
}

.toast.error {
  background: var(--chip-red-text);
}

.hidden {
  display: none !important;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43, 34, 27, 0.45);
  z-index: 25;
}

.sidebar-backdrop.open {
  display: block;
}

/* ==========================================
   MINI-CALENDAR, DASHBOARD, TIME GRID & STATS
   ========================================== */
.mini-cal {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 0.65rem;
}

.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  text-align: center;
}

.mini-cal-dow {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
}

.mini-cal-day {
  border: none;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  font-size: 0.74rem;
  border-radius: 6px;
  height: 26px;
  cursor: pointer;
}

.mini-cal-day:hover {
  background: var(--terracotta-soft);
}

.mini-cal-day.is-today {
  background: var(--terracotta);
  color: #ffffff;
  font-weight: 700;
}

.mini-cal-day.other-month {
  opacity: 0.35;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.15rem;
}

.time-grid {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card-bg);
  overflow: hidden;
}

.time-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  min-height: 48px;
  border-bottom: 1px solid var(--sidebar-border);
}

.time-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  padding: 0.35rem 0.5rem;
  border-right: 1px solid var(--sidebar-border);
  text-align: right;
  font-weight: 600;
}

.time-slot-content {
  padding: 0.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.time-slot-content:hover {
  background: var(--terracotta-soft);
}

.topbar-search {
  min-width: 180px;
  max-width: 240px;
}

.day-cell.drag-over {
  border: 2px dashed var(--terracotta);
  background: var(--terracotta-light);
}

.modal-dialog.fullscreen-detail {
  max-width: min(920px, 95vw);
}

.stat-bar-track {
  width: 100%;
  height: 12px;
  background: var(--bg-warm);
  border-radius: 999px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 999px;
}

/* ==========================================
   MOBILE-FIRST RESPONSIVE (<= 768px & <= 480px)
   ========================================== */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    left: -290px;
    top: 0;
    bottom: 0;
    transition: left 0.22s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.12);
  }

  .sidebar.open {
    left: 0;
  }

  .topbar {
    padding: 0.7rem 0.9rem;
  }

  .content-area {
    padding: 0.9rem 0.9rem 2rem;
  }

  .week-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .day-cell {
    min-height: 78px;
    padding: 0.3rem;
  }
}

@media (max-width: 480px) {
  .current-period-label {
    font-size: 1rem;
    min-width: auto;
  }

  .calendar-month-grid {
    gap: 3px;
  }

  .day-cell {
    min-height: 64px;
    border-radius: 8px;
  }

  .event-pill {
    font-size: 0.68rem;
    padding: 0.12rem 0.25rem;
  }

  .item-row {
    padding: 0.75rem;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-end;
  }
}
