/* ===== BASE ===== */
:root {
  --primary: #dc291e;
  --primary-shade: #e3544b;
  --primary-contrast: #fff;
  --secondary: #352a27;
  --text: #352a27;
  --text-muted: #7e6b63;
  --highlight: #dc291e;
  --gray-1: #f8f3f2;
  --gray-2: #f0e8e5;
  --gray-3: #e4d6d2;
  --gray-4: #c6bab6;
  --gray-5: #726460;
  --body: #fcf9f8;
  --white: #fff;
  --wag-border: #e4d6d2;
  --wag-success: #28a745;
  --wag-warning: #ffc107;
  --wag-danger: #dc3545;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@import url("https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap");

body {
  font-family:
    "Figtree",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: #fff;
  scrollbar-gutter: stable;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 1290px;
  margin: 0 auto;
  padding: 20px;
}

body.iframe-mode {
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body.iframe-mode .container {
  padding: 10px;
  overflow: hidden;
}

/* ===== TYPOGRAPHY ===== */
.section-title {
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.1;
  color: var(--highlight);
  margin-bottom: 1.5rem;
}

.text-highlight {
  color: var(--highlight) !important;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-block;
  color: var(--text);
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 50rem;
  padding: 0.3125rem 1.5rem;
  font-size: 1.125rem;
  line-height: 1.55556;
  text-decoration: none;
  transition:
    color 0.15s ease-in-out,
    background-color 0.15s ease-in-out,
    border-color 0.15s ease-in-out,
    box-shadow 0.15s ease-in-out;
}


.btn-primary,
.btn-primary:visited,
a.btn-primary,
.table td a.btn-primary {
  color: var(--primary-contrast) !important;
  background-color: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover,
a.btn-primary:hover,
.table td a.btn-primary:hover {
  color: var(--primary-contrast) !important;
  background-color: var(--primary-shade);
  border-color: var(--primary-shade);
  text-decoration: none;
}

.btn-primary:focus {
  color: var(--primary-contrast);
  background-color: var(--primary-shade);
  border-color: var(--primary-shade);
  box-shadow: 0 0 0 0.2rem rgba(0, 0, 0, 0.25);
}

.btn-3d {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.3125rem 1.5rem;
  background-color: var(--primary);
  border: 1px solid var(--primary);
  color: var(--primary-contrast);
  text-decoration: none;
  font-size: 1.125rem;
  line-height: 1.55556;
  border-radius: 50rem;
  cursor: pointer;
  transition:
    color 0.15s ease-in-out,
    background-color 0.15s ease-in-out,
    border-color 0.15s ease-in-out,
    box-shadow 0.15s ease-in-out;
}

.btn-3d:hover {
  background-color: var(--primary-shade);
  border-color: var(--primary-shade);
}

/* ===== FILTERS ===== */
.model-button-container {
  margin-bottom: 25px;
}

#wohnung-filter {
  background: var(--gray-1);
  padding: 20px;
  border-radius: 4px;
  margin-bottom: 25px;
}

.wf-houses {
  margin-bottom: 20px;
}

#wf-haus-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wf-haus-btn {
  padding: 8px 16px;
  border: 1px solid var(--wag-border);
  background: white;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 4px;
}

.wf-haus-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.wf-haus-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.wf-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.wf-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wf-col label {
  font-size: 13px;
  color: var(--text-muted);
}

.wf-col input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--wag-border);
  border-radius: 3px;
  outline: none;
}

.wf-col input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
}

.wf-col input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.wf-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 15px;
  border-top: 1px solid var(--wag-border);
}

.wf-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.wf-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.wf-reset {
  padding: 8px 16px;
  background: white;
  border: 1px solid var(--wag-border);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.wf-reset:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== TABLE ===== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 12px 15px;
  vertical-align: middle;
  border-bottom: 1px solid var(--wag-border);
  text-align: right;
}

.table thead.table-highlight {
  background: var(--primary);
  color: white;
}

.table thead.table-highlight th {
  font-weight: 600;
  border-bottom: none;
  white-space: nowrap;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.sort-indicator {
  font-size: 10px;
  opacity: 0.7;
}

.table th:last-child,
.table td:last-child {
  text-align: left;
}

.table tbody tr.apartment-row.row-odd {
  background: var(--gray-1);
}

.table tbody tr.apartment-row.row-even {
  background: white;
}

.table tbody tr.apartment-row {
  cursor: pointer;
  transition: background 0.15s;
}

.table tbody tr.apartment-row:hover {
  background: #fce8ec !important;
}

.table tbody tr.apartment-row.disabled {
  cursor: default;
  opacity: 0.6;
}

.table tbody tr.apartment-row.disabled:hover {
  background: inherit !important;
}

.table tbody tr.apartment-row.disabled.row-odd:hover {
  background: var(--gray-1) !important;
}

.table tbody tr.apartment-row.disabled.row-even:hover {
  background: white !important;
}

.table tbody tr.accordion-row {
  cursor: default;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table td.price-col {
  font-weight: 600;
}

.table td a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.table td a:hover {
  text-decoration: underline;
}

#apartments-container {
  border: 1px solid var(--wag-border);
  border-radius: 4px;
  overflow: hidden;
}

.status-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-badge {
  font-size: 13px;
  font-weight: 500;
}

.status-badge[data-status="verfügbar"] {
  color: var(--wag-success);
}

.status-badge[data-status="reserviert"] {
  color: var(--wag-warning);
}

.status-badge[data-status="nicht verfügbar"] {
  color: var(--wag-danger);
}

.triangle-icon {
  width: 10px;
  height: 10px;
  transition: transform 0.2s;
  fill: var(--text-muted);
  flex-shrink: 0;
}

tr.open .triangle-icon {
  transform: rotate(180deg);
}

/* ===== ACCORDION ===== */
.accordion-row {
  display: none;
}

.accordion-row.open {
  display: table-row;
}

.accordion-row td {
  padding: 0 !important;
  background: white !important;
}

.accordion-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  padding: 20px;
  border-top: 1px solid var(--wag-border);
}

.detail-section h4 {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 15px;
}

.detail-section p {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
}

.detail-section hr {
  border: none;
  border-top: 1px solid var(--wag-border);
  margin: 12px 0;
}

.price-main {
  font-weight: 600;
  font-size: 16px;
  color: var(--primary);
}

.price-secondary {
  font-size: 14px;
  color: var(--text-muted);
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

/* ===== FLOOR PLAN ===== */
.floor-plan-section {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-1);
  border-radius: 4px;
  padding: 15px;
}

.floorplan-carousel {
  width: 100%;
  position: relative;
}

.floorplan-carousel .fp-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  z-index: 2;
}

.floorplan-carousel .fp-prev {
  left: 8px;
}

.floorplan-carousel .fp-next {
  right: 8px;
}

.floorplan-carousel .fp-btn:hover {
  opacity: 1;
  background: rgba(240, 240, 240, 0.9);
  border-color: var(--wag-border);
}

.floorplan-carousel .fp-hit-left:hover ~ .fp-btn.fp-prev,
.floorplan-carousel .fp-hit-right:hover ~ .fp-btn.fp-next {
  opacity: 1;
  background: rgba(240, 240, 240, 0.9);
  border-color: var(--wag-border);
}

.floorplan-carousel[data-multi="false"] .fp-btn {
  display: none;
}

.floorplan-carousel[data-multi="false"] .fp-hit {
  display: none;
}

.floorplan-carousel .fp-viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
  position: relative;
}

.floorplan-carousel .fp-hit {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 15%;
  z-index: 1;
  cursor: pointer;
}

.floorplan-carousel .fp-hit-left {
  left: 0;
}

.floorplan-carousel .fp-hit-right {
  right: 0;
}

.floorplan-carousel .fp-track {
  display: flex;
  transition: transform 0.3s ease;
  will-change: transform;
  pointer-events: none;
}

.floorplan-carousel .fp-link {
  flex: 0 0 100%;
  display: block;
  pointer-events: auto;
}

.floorplan-carousel .fp-track img {
  flex: 0 0 100%;
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
  cursor: zoom-in;
}

.floor-plan-section img {
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
}

/* ===== STATES ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 15px;
}

.error {
  text-align: center;
  padding: 40px;
  color: var(--wag-danger);
  background: #ffebee;
  border-radius: 4px;
}

.table-footnote {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-left: 4px;
}

.mobile-card {
  display: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .wf-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .wf-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .table thead {
    display: none;
  }

  .table .desktop-cell {
    display: none !important;
  }

  .table .mobile-card {
    display: block !important;
    padding: 12px 15px;
    border-bottom: none;
    text-align: left !important;
  }

  .mobile-headline {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    margin-bottom: 4px;
    text-align: left;
  }

  .mobile-info {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 2px;
    text-align: left;
  }

  .mobile-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    gap: 4px;
  }

  .accordion-content {
    display: flex;
    flex-direction: column;
  }

  .accordion-content .detail-section {
    order: 2;
  }

  .accordion-content .floor-plan-section {
    order: 1;
    margin-bottom: 15px;
  }

  .table tbody tr.apartment-row.row-odd + tr.accordion-row.open td,
  .table
    tbody
    tr.apartment-row.row-odd
    + tr.accordion-row.open
    .accordion-content,
  .table
    tbody
    tr.apartment-row.row-odd
    + tr.accordion-row.open
    .floor-plan-section {
    background: var(--gray-1);
  }

  .table tbody tr.apartment-row.row-even + tr.accordion-row.open td,
  .table
    tbody
    tr.apartment-row.row-even
    + tr.accordion-row.open
    .accordion-content,
  .table
    tbody
    tr.apartment-row.row-even
    + tr.accordion-row.open
    .floor-plan-section {
    background: white;
  }

  .accordion-content .detail-section h4,
  .accordion-content .detail-section p,
  .accordion-content .detail-section hr {
    display: none;
  }

  .accordion-content .detail-section .button-group {
    display: flex;
    margin-top: 0;
  }

  .table tbody tr.apartment-row {
    display: block;
    border-bottom: 1px solid var(--wag-border);
  }

  .table tbody tr.apartment-row.open {
    border-bottom: none;
  }

  .table tbody tr.accordion-row {
    display: none !important;
  }

  .table tbody tr.accordion-row.open {
    display: block !important;
  }

  .accordion-row td {
    display: block !important;
    padding: 0 !important;
  }

  .accordion-row td::before {
    display: none;
  }

  .accordion-content {
    grid-template-columns: 1fr;
    padding: 15px;
  }

  .btn {
    font-size: 0.9rem;
    padding: 0.25rem 1rem;
  }

  .btn-3d {
    font-size: 0.9rem;
    padding: 0.25rem 1rem;
  }

  .button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .button-group .btn {
    text-align: center;
  }

  .button-group .btn:first-child {
    width: 100%;
  }

  .button-group .btn:nth-child(2),
  .button-group .btn:nth-child(3) {
    flex: 1;
    min-width: 0;
  }

  .status-cell {
    justify-content: flex-end;
  }
}

@media (max-width: 400px) {
  .button-group .btn:first-child,
  .button-group .btn:nth-child(2),
  .button-group .btn:nth-child(3) {
    width: 100%;
    flex: none;
  }
}
