/**
 * VRCC Split-View Layout (VRBO-inspired)
 *
 * Responsive split-screen layout with properties on left, map on right.
 * Includes mobile toggle, full-width map expansion, and card-marker sync.
 *
 * @package VRCC\OwnerRezSync\PublicFacing
 * @since 3.18.2
 * @version 2.0.0
 */

/* ==========================================
   CSS VARIABLES
   ========================================== */
:root {
  /* Split-view specific colors */
  --vrcc-split-bg: #f7f7f7;
  --vrcc-card-bg: #ffffff;
  --vrcc-card-border: #dddddd;
  --vrcc-card-hover-border: #FF385C;
  --vrcc-text-primary: #222222;
  --vrcc-text-secondary: #717171;
  --vrcc-toggle-active-bg: #ffffff;
  --vrcc-toggle-inactive-bg: #f7f7f7;

  /* Layout dimensions */
  --vrcc-header-height: 80px;
  --vrcc-mobile-toggle-height: 60px;
  --vrcc-split-transition: all 0.3s ease;
}

/* ==========================================
   MOBILE VIEW TOGGLE (< 1024px)
   ========================================== */
.vrcc-mobile-toggle-buttons {
  display: none; /* Hidden on desktop */
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--vrcc-card-bg);
  border-bottom: 1px solid var(--vrcc-card-border);
  padding: 12px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.vrcc-mobile-toggle-bar {
  display: flex;
  gap: 8px;
  max-width: 400px;
  margin: 0 auto;
  background: var(--vrcc-toggle-inactive-bg);
  border-radius: 24px;
  padding: 4px;
}

.vrcc-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--vrcc-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.vrcc-toggle-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  flex-shrink: 0;
}

.vrcc-toggle-btn.active {
  background: var(--vrcc-toggle-active-bg);
  color: var(--vrcc-text-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.vrcc-toggle-btn:hover:not(.active) {
  color: var(--vrcc-text-primary);
}

.vrcc-toggle-btn:focus-visible {
  outline: 2px solid var(--vrcc-card-hover-border);
  outline-offset: 2px;
}

/* ==========================================
   SPLIT VIEW CONTAINER
   ========================================== */
.vrcc-split-view-container {
  display: flex;
  min-height: calc(100vh - var(--vrcc-header-height));
  position: relative;
}

/* ==========================================
   LISTINGS PANEL (Left Side)
   ========================================== */
.vrcc-listings-panel {
  flex: 1 1 50%;
  max-width: 50%;
  padding: 24px;
  overflow-y: auto;
  height: calc(100vh - var(--vrcc-header-height));
  transition: var(--vrcc-split-transition);
  background: var(--vrcc-split-bg);
  scroll-behavior: smooth;
}

/* Full-width map state (20/80 split) */
.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-listings-panel {
  flex: 1 1 20%;
  max-width: 20%;
}

/* Results grid */
.vrcc-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  max-width: 1200px;
}

/* Full-width map mode: single column layout */
.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-results-grid {
  grid-template-columns: 1fr;
  gap: 12px;
}

/* Results header */
.vrcc-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.vrcc-results-count {
  font-size: 16px;
  font-weight: 600;
  color: var(--vrcc-text-primary);
  margin: 0;
}

.vrcc-results-location {
  font-weight: 400;
  color: var(--vrcc-text-secondary);
}

.vrcc-results-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ==========================================
   PROPERTY CARDS (Enhanced Hover States)
   ========================================== */
.vrcc-property-card {
  background: var(--vrcc-card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  cursor: pointer;
  border: 2px solid transparent;
}

.vrcc-property-card:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

/* Card-map hover sync (triggered by marker hover) */
.vrcc-property-card.vrcc-card-map-hover {
  border-color: var(--vrcc-card-hover-border);
  box-shadow: 0 6px 20px rgba(255, 56, 92, 0.2);
  transform: translateY(-2px);
}

.vrcc-card-image-wrapper {
  width: 100%;
  position: relative;
  background: #f0f0f0;
}

.vrcc-card-image-carousel {
  width: 100%;
  aspect-ratio: 4 / 3;
}

.vrcc-card-image-carousel img,
.vrcc-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vrcc-card-content {
  padding: 16px;
}

.vrcc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.vrcc-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--vrcc-text-primary);
  line-height: 1.3;
  flex: 1;
  margin: 0;
}

.vrcc-card-title a {
  color: inherit;
  text-decoration: none;
}

.vrcc-card-title a:hover {
  text-decoration: underline;
}

.vrcc-card-subtitle,
.vrcc-card-details {
  font-size: 14px;
  color: var(--vrcc-text-secondary);
  margin-bottom: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.vrcc-card-specs {
  font-size: 14px;
  color: var(--vrcc-text-secondary);
  margin-bottom: 12px;
}

.vrcc-card-pricing,
.vrcc-card-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.vrcc-price-amount {
  font-size: 16px;
  font-weight: 600;
  color: var(--vrcc-text-primary);
}

.vrcc-price-descriptor,
.vrcc-card-price-label {
  font-size: 14px;
  font-weight: 400;
  color: var(--vrcc-text-secondary);
}

/* Full-width map mode: Compact horizontal card layout */
.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-property-card {
  flex-direction: row;
  border-radius: 8px;
  min-height: 100px;
}

.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-card-image-wrapper {
  width: 100px;
  flex-shrink: 0;
}

.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-card-image-carousel {
  aspect-ratio: 1 / 1;
  height: 100px;
}

.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-card-content {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-card-title {
  font-size: 13px;
  line-height: 1.3;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-card-subtitle,
.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-card-details {
  font-size: 11px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-card-specs {
  display: none;
}

.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-price-amount {
  font-size: 14px;
}

.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-price-descriptor {
  font-size: 11px;
}

/* ==========================================
   MAP PANEL (Right Side)
   ========================================== */
.vrcc-map-panel {
  flex: 1 1 50%;
  max-width: 50%;
  position: sticky;
  top: var(--vrcc-header-height);
  height: calc(100vh - var(--vrcc-header-height));
  transition: var(--vrcc-split-transition);
  background: #e8e8e8;
}

/* Full-width map state (20/80 split) */
.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-map-panel {
  flex: 1 1 80%;
  max-width: 80%;
}

#vrcc-map-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.vrcc-google-map {
  width: 100%;
  height: 100%;
  position: relative;
}

/* ==========================================
   FULL-WIDTH TOGGLE BUTTON (Desktop)
   ========================================== */
.vrcc-fullwidth-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--vrcc-card-bg);
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.vrcc-fullwidth-toggle:hover {
  background: #f7f7f7;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: scale(1.05);
}

.vrcc-fullwidth-toggle:active {
  transform: scale(0.95);
}

.vrcc-fullwidth-toggle:focus-visible {
  outline: 2px solid var(--vrcc-card-hover-border);
  outline-offset: 2px;
}

.vrcc-fullwidth-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--vrcc-text-primary);
  stroke-width: 2;
  transition: transform 0.3s ease;
}

/* Rotate icon when expanded */
.vrcc-split-view-container.vrcc-map-fullwidth .vrcc-fullwidth-toggle svg {
  transform: rotate(180deg);
}

/* ==========================================
   LOADING STATES
   ========================================== */
.vrcc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--vrcc-text-secondary);
  text-align: center;
}

.vrcc-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f0f0f0;
  border-top-color: var(--vrcc-card-hover-border);
  border-radius: 50%;
  animation: vrcc-spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes vrcc-spin {
  to {
    transform: rotate(360deg);
  }
}

.vrcc-map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  background: rgba(255, 255, 255, 0.9);
  padding: 20px;
  border-radius: 8px;
}

/* ==========================================
   EMPTY STATE
   ========================================== */
.vrcc-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--vrcc-text-secondary);
}

.vrcc-empty-icon {
  margin: 0 auto 20px;
  opacity: 0.5;
}

.vrcc-empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--vrcc-text-primary);
  margin-bottom: 8px;
}

.vrcc-empty-message {
  font-size: 14px;
  color: var(--vrcc-text-secondary);
}

/* ==========================================
   SEARCH THIS AREA BUTTON
   ========================================== */
.vrcc-search-area-btn {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--vrcc-card-bg);
  border: 1px solid var(--vrcc-card-border);
  border-radius: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  font-weight: 600;
  color: var(--vrcc-text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.vrcc-search-area-btn:hover {
  background: var(--vrcc-text-primary);
  color: var(--vrcc-card-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.vrcc-search-area-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   ========================================== */

/* Tablet: 768px - 1023px */
@media screen and (max-width: 1023px) and (min-width: 768px) {
  .vrcc-listings-panel {
    padding: 16px;
  }

  .vrcc-results-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }

  .vrcc-results-header {
    margin-bottom: 16px;
  }
}

/* Mobile: < 1024px */
@media screen and (max-width: 1023px) {
  .vrcc-mobile-toggle-buttons {
    display: block;
  }

  .vrcc-split-view-container {
    flex-direction: column;
    min-height: auto;
  }

  .vrcc-listings-panel,
  .vrcc-map-panel {
    flex: 1 1 100%;
    max-width: 100%;
    position: relative;
    top: 0;
    height: auto;
  }

  /* Hide listings when map view active */
  .vrcc-split-view-container[data-active-view="map"] .vrcc-listings-panel {
    display: none;
  }

  /* Hide map when list view active */
  .vrcc-split-view-container[data-active-view="list"] .vrcc-map-panel {
    display: none;
  }

  /* Map takes full viewport when active (search header hidden via JS) */
  .vrcc-split-view-container[data-active-view="map"] .vrcc-map-panel {
    display: block;
    height: calc(100vh - var(--vrcc-mobile-toggle-height));
    min-height: calc(100vh - var(--vrcc-mobile-toggle-height));
    position: fixed;
    top: var(--vrcc-mobile-toggle-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
  }

  /* Ensure map container fills panel on mobile */
  .vrcc-split-view-container[data-active-view="map"] #vrcc-map-container {
    height: 100% !important;
    min-height: 100%;
    border-radius: 0;
  }

  .vrcc-listings-panel {
    padding: 16px;
    height: auto;
    overflow-y: visible;
  }

  .vrcc-results-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Hide full-width toggle on mobile */
  .vrcc-fullwidth-toggle {
    display: none;
  }

  /* Full-width map state has no effect on mobile */
  .vrcc-split-view-container.vrcc-map-fullwidth .vrcc-listings-panel,
  .vrcc-split-view-container.vrcc-map-fullwidth .vrcc-map-panel {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .vrcc-results-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Small mobile: < 480px */
@media screen and (max-width: 479px) {
  .vrcc-toggle-btn {
    font-size: 12px;
    padding: 8px 12px;
    gap: 4px;
  }

  .vrcc-toggle-btn svg {
    width: 14px;
    height: 14px;
  }

  .vrcc-card-content {
    padding: 12px;
  }

  .vrcc-card-title {
    font-size: 14px;
  }

  .vrcc-card-subtitle,
  .vrcc-card-details,
  .vrcc-card-specs,
  .vrcc-price-descriptor,
  .vrcc-card-price-label {
    font-size: 12px;
  }

  .vrcc-listings-panel {
    padding: 12px;
  }

  .vrcc-results-header {
    margin-bottom: 12px;
  }
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */
.hidden {
  display: none !important;
}

.fade-in {
  animation: vrcc-fade-in 0.3s ease;
}

@keyframes vrcc-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================
   PRINT STYLES
   ========================================== */
@media print {
  .vrcc-mobile-toggle-buttons,
  .vrcc-fullwidth-toggle,
  .vrcc-map-panel,
  .vrcc-search-area-btn {
    display: none !important;
  }

  .vrcc-listings-panel {
    max-width: 100% !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  .vrcc-results-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .vrcc-property-card {
    page-break-inside: avoid;
  }
}
