/* ─── Animations ─── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin .7s linear infinite; }

/* ─── Layout ─── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: #f0f2f5; }

.app-wrapper { display: flex; min-height: 100vh; }

/* ─── Sidebar ─── */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: linear-gradient(180deg, #1a237e 0%, #283593 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .3px;
}
.sidebar-brand-row i { font-size: 1.4rem; color: #90caf9; }

/* Logo in sidebar */
.sidebar-logo-wrap img {
  max-width: 180px;
  max-height: 80px;
  object-fit: contain;
  display: block;
  border-radius: 4px;
}

.sidebar-menu {
  list-style: none;
  padding: 10px 0;
  margin: 0;
  flex: 1;
}
.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 20px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .9rem;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.sidebar-menu a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.sidebar-menu a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-weight: 600;
  border-left-color: #90caf9;
}
.sidebar-menu a i { font-size: 1rem; width: 18px; text-align: center; }
.menu-section {
  padding: 14px 20px 6px;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: rgba(255,255,255,.38);
}

/* ─── Main content ─── */
.main-content {
  flex: 1;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ─── Page header ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a237e;
  margin: 0;
}

/* ─── Cards ─── */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #eee;
  border-radius: 12px 12px 0 0 !important;
  font-weight: 600;
  padding: 14px 20px;
}

/* ─── Stat cards ─── */
.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.1); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .82rem; color: #888; margin-top: 4px; }

/* ─── Occupancy grid ─── */
.occupancy-wrapper {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid #e0e0e0;
  background: #fff;
}
.occupancy-grid { display: block; min-width: 100%; }
.occ-row { display: flex; flex-direction: row; position: relative; }
.occ-row:hover .day-cell { filter: brightness(.97); }

.apt-name-cell {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 140px; min-width: 140px;
  padding: 0 12px;
  font-weight: 600;
  font-size: .82rem;
  color: #333;
  background: #fafafa;
  border-right: 2px solid #e0e0e0;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
  height: 44px;
  position: relative;
  z-index: 4; /* above span labels */
}
.apt-name-cell.header { height: 52px; font-size: .78rem; color: #666; font-weight: 500; }

.day-cell {
  display: block;
  flex-shrink: 0;
  width: 42px; min-width: 42px;
  height: 44px;
  /*border-right: 1px solid #f0f0f0;*/
  border-bottom: 1px solid #eee;
  position: relative;
  cursor: default;
}
.day-cell.free { background: #fff; }
.day-cell.free:hover { background: #e8f5e9; cursor: pointer; }
.day-cell.weekend-col { background: #fafafa; }
.day-cell.weekend-col.free:hover { background: #e8f5e9; }
.day-cell.today-col { background: #e3f2fd !important; }

.day-header-cell {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex-shrink: 0;
  width: 42px; min-width: 42px;
  text-align: center;
  padding: 6px 2px 4px;
  font-size: .72rem;
  color: #777;
  border-right: 1px solid #f0f0f0;
  border-bottom: 2px solid #ddd;
  background: #fafafa;
  white-space: nowrap;
}
.day-header-cell.today-col { background: #e3f2fd; color: #1565c0; font-weight: 700; }
.day-header-cell.weekend-col { color: #c62828; }

/* Booking name label spanning multiple days */
.booking-span-label {
  position: absolute;
  top: 4px; bottom: 4px;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: .72rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  pointer-events: auto; /* enable drag/resize */
  cursor: grab;
  z-index: 3;
  text-shadow: 0 1px 3px rgba(0,0,0,.35);
  user-select: none;
}
.booking-span-label:active { cursor: grabbing; }
.booking-span-label.occ-dragging { opacity: .35; cursor: grabbing; }

/* Icons inside span label (deposit + invoice state) */
.occ-icons {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  padding-right: 12px; /* clear right resize handle */
  flex-shrink: 0;
  font-size: .78rem;
  pointer-events: none;
}
.occ-icon-ok      { color: #a5d6a7; }   /* light green – paid / ok */
.occ-icon-pending { color: rgba(255,255,255,.45); } /* dimmed – unpaid / open */

/* Resize handles on span label edges */
.occ-resize-handle {
  position: absolute; top: 0; bottom: 0; width: 8px;
  cursor: ew-resize; z-index: 10; opacity: 0;
  transition: opacity .15s;
  flex-shrink: 0;
}
.occ-resize-handle.occ-resize-left  { left: 0; }
.occ-resize-handle.occ-resize-right { right: 0; }
.booking-span-label:hover .occ-resize-handle { opacity: 1; }

/* Floating ghost during drag */
.occ-drag-ghost {
  position: fixed; pointer-events: none; z-index: 9999;
  background: rgba(13,110,253,.18); border: 2px dashed #0d6efd;
  border-radius: 6px; font-size: .78rem; padding: 3px 10px;
  color: #0d6efd; font-weight: 600; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}

.booking-block {
  position: absolute;
  top: 4px; bottom: 4px; left: 0; right: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  padding-left: 6px;
  font-size: .72rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  z-index: 1;
}
/* Half-day: check-in = right half, check-out = left half */
.booking-block.start { left: 50%; right: 0;   border-radius: 6px 0 0 6px; padding-left: 3px; }
.booking-block.end   { left: 0;   right: 50%; border-radius: 0 6px 6px 0; }
.booking-block.solo  { left: 15%; right: 15%; border-radius: 6px; }
/* Mid + start cells: remove right border so adjacent booking blocks are seamless */
.day-cell.occ-mid,
.day-cell.occ-start { border-right: none; }

.occ-paid-icon {
  margin-left: auto;
  padding-right: 5px;
  font-size: .75rem;
  opacity: .9;
  flex-shrink: 0;
}

.status-anfrage     .booking-block { background: #7b1fa2; }
.status-angebot     .booking-block { background: #f57f17; }
.status-confirmed   .booking-block { background: #1565c0; }
.status-checked_in  .booking-block { background: #00695c; }
.status-checked_out .booking-block { background: #757575; }
.status-cancelled   .booking-block { background: #bdbdbd; }
.status-pending     .booking-block { background: #f57c00; }
.status-bezahlt     .booking-block { background: #388e3c; }

/* ─── Guest search dropdown ─── */
#bGuestDropdown .list-group-item { font-size: .88rem; padding: .4rem .75rem; cursor: pointer; }
#bGuestDropdown .list-group-item:hover { background: #f0f4ff; }

/* ─── Quill editors ─── */
.offer-editor { min-height: 260px; font-size: 0.875rem; }
.ql-toolbar.ql-snow { border-radius: 0.375rem 0.375rem 0 0; border-color: #dee2e6; background: #f8f9fa; }
.ql-container.ql-snow { border-radius: 0 0 0.375rem 0.375rem; border-color: #dee2e6; font-family: 'Segoe UI', system-ui, sans-serif; }
.ql-editor { min-height: 240px; font-size: 0.875rem; }
.ql-editor.ql-blank::before { font-style: italic; color: #6c757d; }
/* Compact signature editor — smaller min-height, no fixed height on container */
#sSignatureEditor .ql-editor { min-height: 100px; }

/* ─── Status badges ─── */
.badge-anfrage     { background: #f3e5f5; color: #6a1b9a; }
.badge-angebot     { background: #fff8e1; color: #f57f17; }
.badge-confirmed   { background: #e3f2fd; color: #1565c0; }
.badge-checked_in  { background: #e0f2f1; color: #00695c; }
.badge-cancelled   { background: #ffebee; color: #c62828; }
.badge-checked_out { background: #f5f5f5; color: #616161; }
.badge-pending     { background: #fff3e0; color: #e65100; } /* legacy */
.badge-bezahlt     { background: #e8f5e9; color: #2e7d32; } /* legacy */
.badge-draft       { background: #f5f5f5; color: #616161; }
.badge-sent        { background: #e3f2fd; color: #1565c0; }
.badge-paid        { background: #e8f5e9; color: #2e7d32; }
.status-badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: .78rem; font-weight: 600;
}

/* ─── Radio tile groups ─── */
.radio-tile-group { display: flex; flex-wrap: wrap; gap: 5px; }
.radio-tile-group input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.radio-tile-group label {
  cursor: pointer; padding: 5px 12px; border-radius: 6px;
  border: 1.5px solid #dee2e6; font-size: .82rem; font-weight: 500;
  background: #fff; color: #555; transition: background .1s, color .1s, border-color .1s;
  display: inline-flex; align-items: center; gap: 5px;
  user-select: none; line-height: 1.3;
}
.radio-tile-group label:hover { border-color: #adb5bd; background: #f8f9fa; }
/* Anreiseart → blue */
.rtg-blue  input[type="radio"]:checked + label { background:#0d6efd; color:#fff; border-color:#0a58ca; }
/* Anreisezeit → green */
.rtg-green input[type="radio"]:checked + label { background:#198754; color:#fff; border-color:#146c43; }
/* Abreisezeit → amber */
.rtg-amber input[type="radio"]:checked + label { background:#fd7e14; color:#fff; border-color:#dc6c0c; }

/* ─── Tables ─── */
.table th { font-size: .8rem; text-transform: uppercase;
  letter-spacing: .5px; color: #888; font-weight: 600; background: #fafafa; }
.table td { font-size: .88rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f5f7ff; }

/* ─── Invoice items ─── */
.invoice-totals { min-width: 220px; font-size: .95rem; }
.invoice-totals .d-flex { margin-bottom: 4px; }

/* ─── Occupancy nav ─── */
.occ-nav { display: flex; align-items: center; gap: 12px; }
.occ-nav .month-label { font-weight: 600; font-size: 1rem; min-width: 160px; text-align: center; }

/* ─── Occupancy month-jump tiles ─── */
.occ-month-nav { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; padding: 4px 0; }
.occ-month-tile {
  cursor: pointer; padding: 3px 7px; border-radius: 5px;
  border: 1.5px solid #dee2e6; font-size: .72rem; font-weight: 600;
  background: #fff; color: #555; transition: background .1s, color .1s, border-color .1s;
  text-align: center; line-height: 1.4; min-width: 34px; user-select: none;
  display: inline-flex; flex-direction: column; align-items: center;
}
.occ-month-tile:hover { border-color: #adb5bd; background: #f8f9fa; }
.occ-month-tile.active { background: #0d6efd; color: #fff; border-color: #0a58ca; }
.occ-month-tile.yr-next { opacity: .65; }
.occ-month-tile.yr-next.active { opacity: 1; background: #6610f2; border-color: #520dc2; }
.occ-month-yr { font-size: .58rem; opacity: .7; font-weight: 400; line-height: 1; }
.occ-month-sep { display: inline-block; width: 1px; height: 28px; background: #dee2e6; margin: 0 3px; align-self: center; }

/* ─── Misc ─── */
.search-bar { max-width: 320px; }
.text-primary-dark { color: #1a237e; }
.btn-icon { padding: 4px 8px; font-size: .85rem; }

/* ─── Mobile topbar (hidden on desktop) ─── */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 200;
  background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
  color: #fff;
  padding: 0 12px;
  height: 56px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  flex-shrink: 0;
}
.hamburger-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .15s;
}
.hamburger-btn:hover { background: rgba(255,255,255,.15); }
.mobile-brand {
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 100px);
}

/* ─── Sidebar backdrop (mobile) ─── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 149;
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.open { display: block; }

/* ─── Mobile responsive ─── */
@media (max-width: 1349px) {
  /* Show topbar */
  .mobile-topbar { display: flex; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    height: 100vh;
    z-index: 150;
    width: 270px;
    min-width: 270px;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }

  /* Main content fills full width */
  .app-wrapper { flex-direction: column; }
  .main-content { width: 100%; min-height: calc(100vh - 56px); }

  /* Tighter page padding */
  #page-content { padding: 14px !important; }

  /* Page header stacks on very small screens */
  .page-header {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header h2 { font-size: 1.2rem; }

  /* Filter bars wrap nicely */
  .card-header.d-flex { flex-wrap: wrap; gap: 8px !important; }
  .card-header .form-control,
  .card-header .form-select { max-width: 100% !important; }

  /* Bigger touch targets for icon buttons */
  .btn-icon { padding: 7px 10px; font-size: .9rem; }

  /* Stat cards: 2 per row */
  #statCards .col-md-3 { flex: 0 0 50%; max-width: 50%; }
  .stat-card { padding: 16px; gap: 12px; }
  .stat-value { font-size: 1.4rem; }
  .stat-icon  { width: 42px; height: 42px; font-size: 1.2rem; }

  /* Occupancy nav wraps */
  .occ-nav { flex-wrap: wrap; justify-content: center; gap: 8px; }
  .occ-nav .month-label { min-width: unset; }

  /* Modal dialogs use full width on small screens */
  .modal-dialog { margin: 8px; }
  .modal-xl { max-width: calc(100vw - 16px); }

  /* Kanban: account for 56px mobile topbar */
  .kanban-board { height: calc(100vh - 56px - 200px); }
}

/* ─── Narrow screens: action buttons move to bottom of each row ─── */
@media (max-width: 924px) {
  /* Disable horizontal scroll – rows become cards */
  .card .table-responsive { overflow-x: visible; }

  /* Break table display model */
  .card .table         { display: block; }
  .card .table thead   { display: none; }
  .card .table tbody   { display: block; width: 100%; }

  /* Each row → card */
  .card .table tbody tr {
    display: block;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    margin: 8px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
  }
  .card .table tbody tr:hover { background: #f5f7ff; }

  /* Data cells flow inline */
  .card .table tbody td {
    display: inline-block;
    border: none !important;
    padding: 6px 10px;
    font-size: .83rem;
    vertical-align: middle;
    width: auto;
    max-width: 100%;
  }

  /* Action buttons cell → full-width bottom strip */
  .card .table tbody td.text-end {
    display: block !important;
    width: 100% !important;
    text-align: left !important;
    padding: 8px 10px;
    background: #f8f9fa;
    border-top: 1px solid #efefef !important;
    margin-top: 2px;
  }
}

/* ─── Kanban Board ─── */
.kanban-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 0 0;
  align-items: stretch;
  height: calc(100vh - 175px);
}
.kanban-col {
  flex: 0 0 210px;
  min-width: 210px;
  background: #f4f5f7;
  border-radius: 10px;
  border: 1px solid #dde1e7;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.kanban-col-header {
  padding: 8px 10px 7px;
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,.08);
  user-select: none;
}
.kanban-col-count {
  border-radius: 10px;
  padding: 1px 7px;
  font-size: .75rem;
  font-weight: 700;
}
.kanban-col-body {
  padding: 7px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 64px;
  overflow-y: auto;
  transition: background .12s;
}
.kanban-col-body.drag-over {
  background: rgba(25,118,210,.08);
  outline: 2px dashed #1976d2;
  outline-offset: -3px;
  border-radius: 0 0 10px 10px;
}
.kanban-card {
  background: #fff;
  border-radius: 7px;
  border: 1px solid #e2e5ec;
  padding: 9px 11px;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: box-shadow .15s;
  font-size: .82rem;
  user-select: none;
}
.kanban-card:active  { cursor: grabbing; }
.kanban-card:hover   { box-shadow: 0 3px 8px rgba(0,0,0,.12); }
.kanban-card.dragging { opacity: .4; }
.kanban-card .kcard-name   { font-weight: 600; font-size: .84rem; }
.kanban-card .kcard-meta   { color: #555; font-size: .77rem; line-height: 1.5; margin-top: 3px; }
.kanban-card .kcard-footer { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.kanban-empty { text-align: center; color: #bbb; font-size: .8rem; padding: 14px 0; }
.view-toggle  { flex-shrink: 0; }
.view-toggle .btn { padding: 4px 10px; }
