.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

/* Stepper Styles */
.stepper-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  flex: 1;
  cursor: pointer;
  overflow: visible;
}

/* Line connecting steps */
.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 20px;
  left: 50%;
  width: 100%;
  height: 2px;
  background-color: #e2e8f0;
  z-index: 1;
}

.step-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #f1f5f9;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  margin-bottom: 0.5rem;
  z-index: 2;
  border: 2px solid #e2e8f0;
  background-clip: padding-box;
  /* Ensures border doesn't overlap background */
  background-color: white;
  /* Ensure line doesn't show through */
  transition: all 0.3s ease;
}

.step-title {
  font-size: 0.875rem;
  color: #64748b;
  font-weight: 500;
  text-align: center;
  z-index: 2;
  /* Ensure title is above line if needed */
}

.step-item.active .step-circle {
  background-color: var(--primary, #3b82f6);
  color: white;
  border-color: var(--primary, #3b82f6);
}

.step-item.active .step-title {
  color: #1e293b;
  font-weight: 600;
}

.step-item.active:not(:last-child)::after {
  background-color: var(--primary, #3b82f6);
  /* Color line if active */
}

.upload-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}


.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: #1e293b;
}

.add-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background-color: var(--primary);
  color: white;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: background-color 0.2s;
}

.add-btn:hover {
  background-color: var(--primary-dark, #2563eb);
}

.filters-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  align-items: center;
}

.filter-group {
  flex: 1;
  min-width: 200px;
}

.properties-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.property-card {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  /* overflow: hidden; Removed to allow tooltip to overflow */
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  position: relative;
  /* Ensure z-index works */
}

.property-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 500;
  /* Ensure active card is above sidebar (z-100) */
}

.card-image-placeholder {
  height: 160px;
  background-color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  border-radius: 1rem 1rem 0 0;
  /* Clip top corners manually */
}

.card-content {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.property-id {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
}

.property-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.property-detail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #64748b;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.card-tags {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-active {
  background-color: #dcfce7;
  color: #166534;
}

.status-inactive {
  background-color: #fee2e2;
  color: #991b1b;
}

.card-actions {
  padding: 1rem 1.5rem;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.action-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.375rem;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-ghost {
  color: #64748b;
  background: transparent;
}

.btn-ghost:hover {
  background-color: #f1f5f9;
  color: #1e293b;
}

.btn-primary-ghost {
  color: var(--primary);
  background: transparent;
}

.btn-primary-ghost:hover {
  background-color: #eff6ff;
}

.loading-state,
.error-state,
.empty-state {
  padding: 4rem;
  text-align: center;
  color: #64748b;
}

/* Pagination */
.pagination-toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  background-color: #fff;
  border-radius: 0 0 1rem 1rem;
}

@media (min-width: 640px) {
  .pagination-toolbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.pagination-controls-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

@media (min-width: 640px) {
  .pagination-controls-group {
    flex-direction: row;
    gap: 1.5rem;
  }
}

.per-page-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #64748b;
}

.form-select-sm {
  padding: 0.25rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  color: #1e293b;
  background-color: #fff;
}

.page-navigation {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #64748b;
  margin: 0 0.5rem;
}

.page-input {
  width: 3rem;
  padding: 0.25rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.25rem;
  text-align: center;
  font-size: 0.875rem;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.btn-outline {
  border: 1px solid #cbd5e1;
  color: #334155;
  background-color: white;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover:not(:disabled) {
  background-color: #f8fafc;
}

.btn-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #f1f5f9;
}

/* Form Styles */
.form-container {
  background: white;
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  max-width: 800px;
  margin: 0 auto;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  font-size: 1rem;
  color: #1e293b;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  background-color: #fff;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #f1f5f9;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 0.875rem;
}

.btn-primary {
  background-color: var(--primary, #3b82f6);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark, #2563eb);
}

.btn-secondary {
  background-color: #f1f5f9;
  color: #64748b;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #e2e8f0;
  color: #1e293b;
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.error-msg {
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Detail View Styles */
.detail-container {
  max-width: 1000px;
  margin: 0 auto;
}

.detail-card {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.detail-header {
  padding: 2rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.detail-body {
  padding: 2rem;
}

.detail-section {
  margin-bottom: 2rem;
}

.detail-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

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

.detail-item label {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.detail-item p {
  font-size: 1rem;
  color: #1e293b;
  font-weight: 500;
}

/* Existing styles... I will append new ones */

.card-image-container {
  position: relative;
  width: 100%;
  height: 200px;
  background-color: #f3f4f6;
  overflow: hidden;
}

.image-slider {
  width: 100%;
  height: 100%;
  position: relative;
}

.slider-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE/Edge */
}

.slider-track::-webkit-scrollbar {
  display: none;
}

.slider-item {
  min-width: 100%;
  height: 100%;
  scroll-snap-align: start;
}

.slider-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #f1f5f9;
}

.slider-nav {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  /* Let clicks pass through to card unless on button */
  opacity: 0;
  transition: opacity 0.2s;
  background: rgba(0, 0, 0, 0.1);
}

.property-card:hover .slider-nav {
  opacity: 1;
}

.nav-btn {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0 10px;
  font-weight: bold;
  color: #333;
  transition: background 0.2s;
}

.nav-btn:hover {
  background: white;
}

.slider-dots {
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 8px;
  border-radius: 10px;
  color: white;
  font-size: 0.75rem;
}

/* Ensure placeholder matches container height */
.card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  background-color: #f3f4f6;
}

/* Image Management Styles for Edit View */
.image-management-section {
  margin-top: 2rem;
  border-top: 1px solid #e5e7eb;
  padding-top: 2rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 1rem;
}

.upload-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.upload-btn-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
}

.upload-btn-wrapper input[type='file'] {
  font-size: 100px;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  cursor: pointer;
}

.url-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.images-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.images-sort-hint {
  margin-bottom: 0.9rem;
  color: #64748b;
  font-size: 0.875rem;
}

.image-item {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.sortable-image-item {
  cursor: grab;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.sortable-image-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.sortable-image-item.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.sortable-image-item.is-drag-over {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}

.sortable-image-item.is-reordering {
  pointer-events: none;
}

.image-order-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  min-width: 1.9rem;
  height: 1.9rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.82);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.image-drag-handle {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.image-preview {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.image-actions {
  padding: 0.5rem;
  display: flex;
  justify-content: flex-end;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.img-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
  padding: 4px;
  border-radius: 4px;
}

.img-action-btn:hover {
  background: #e5e7eb;
  color: #374151;
}

.img-action-btn.delete:hover {
  color: #ef4444;
  background: #fee2e2;
}

/* Gallery Styles */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.gallery-item {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
}

.gallery-item:hover {
  transform: scale(1.02);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Search Input */
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  color: #94a3b8;
}

.search-input {
  padding-left: 2.5rem !important;
  width: 100%;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #1e293b;
}


/* Badges & Price */
.property-badges {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.badge-success {
  background-color: #dcfce7;
  color: #166534;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.price-tag {
  font-weight: 700;
  color: #3b82f6;
  font-size: 0.95rem;
}

/* Tooltip */
/* Tooltip Styles Updated */
.property-info-tooltip {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  cursor: help;
}

.info-icon {
  color: #4b5563;
  fill: #fff;
  background: white;
  border-radius: 50%;
  padding: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tooltip-content {
  visibility: hidden;
  background-color: #1f2937;
  color: #f9fafb;
  text-align: left;
  border-radius: 0.5rem;
  padding: 1rem;
  position: absolute;
  z-index: 9999;
  /* Ensure it stays on top */

  /* Default to Bottom Center if JS fails */
  top: 100%;
  left: 50%;
  transform: translateX(-50%);

  /* Constraint dimensions */
  width: 380px;
  /* Reduced specific width */
  max-width: 90vw;
  /* Avoid overflow on mobile */
  max-height: 400px;
  /* Prevent it from being too tall */
  overflow-y: auto;
  /* Internal scroll if content is too long */

  opacity: 0;
  /* Delay hiding: wait 0.3s before setting visibility:hidden */
  transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: 0.5rem;
  pointer-events: auto;
  /* Allow scrolling */

  /* Grid Layout for 2 columns */
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-flow: dense;
  gap: 0.5rem 1rem;
  align-items: start;
  /* Align to top of rows */

  scrollbar-width: thin;
  /* Firefox */
  scrollbar-color: #4b5563 #1f2937;
  /* Firefox */
}

/* Custom Scrollbar */
.tooltip-content::-webkit-scrollbar {
  width: 6px;
}

.tooltip-content::-webkit-scrollbar-track {
  background: #1f2937;
  border-radius: 4px;
}

.tooltip-content::-webkit-scrollbar-thumb {
  background-color: #4b5563;
  border-radius: 4px;
}

.property-info-tooltip:hover .tooltip-content {
  visibility: visible;
  opacity: 1;
  /* Show instantly */
  transition: opacity 0.2s ease-in-out, visibility 0s linear 0s;
}

/* Dynamic Positioning Classes managed by JS */
.tooltip-content.position-top {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 0.5rem;
}

/* Bridge the gap specifically for top positioned tooltip */
.tooltip-content.position-top::after {
  content: '';
  position: absolute;
  top: 100%;
  /* Starts at the bottom of the tooltip */
  left: 0;
  right: 0;
  height: 1rem;
  /* Covers the 0.5rem margin + safety buffer */
  background: transparent;
}

.tooltip-content.align-left {
  left: auto;
  right: 0;
  transform: none;
}

.tooltip-content.align-right {
  right: auto;
  left: 0;
  transform: none;
}

.tooltip-content.align-center {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.tooltip-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  /* Align text to top */
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #374151;
  min-height: 24px;
}

.tooltip-item-full {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-start;
  border-bottom: 1px solid #374151;
  padding-bottom: 0.5rem;
}

.tooltip-item:nth-last-child(-n+2) {
  border-bottom: none;
}

.tooltip-label {
  color: #9ca3af;
  margin-right: 0.5rem;
  font-weight: 500;
  white-space: nowrap;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.tooltip-value {
  text-align: right;
  word-break: break-word;
  font-weight: 600;
  font-size: 0.8rem;
  max-width: 100%;
  /* Allow full width of cell */
}

.tooltip-item-full .tooltip-value {
  text-align: left;
  max-width: 100%;
}

.card-content {
  position: relative;
}

/* Advanced Filters & Chips */
.search-group {
  flex: 2 !important;
}

.active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.4rem 0.75rem;
  border-radius: 2rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid #bae6fd;
  transition: all 0.2s;
}

.filter-chip:hover {
  background: #bae6fd;
}

.chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #7dd3fc;
  color: #0369a1;
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.chip-remove:hover {
  background: #38bdf8;
  color: white;
}

.btn-ghost.btn-sm {
  color: #64748b;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

.btn-ghost.btn-sm:hover {
  color: #1e293b;
  text-decoration: underline;
}

/* Mandatory and ML Badges in Attributes Grid */
.badge-required {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #92400e;
  background-color: #fef3c7;
  padding: 0.12rem 0.6rem;
  border-radius: 1rem;
  margin-left: 0.5rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border: 1px solid #fde68a;
  line-height: normal;
}

.badge-ml {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #4338ca;
  background-color: #e0e7ff;
  padding: 0.12rem 0.5rem;
  border-radius: 0.5rem;
  margin-left: 0.4rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border: 1px solid #c7d2fe;
  line-height: normal;
}