/**
 * Default Template Styles
 * Issue #115 - Property Site Booking Template
 * Based on sandbox-v2
 */

/* =============================================
   CSS RESET & BASE
   ============================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background: #f9fafb;
  color: #111827;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

img {
  max-width: 100%;
  height: auto;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: 1.2;
}

p {
  margin: 0;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* =============================================
   PROPERTY HEADER
   ============================================= */
.property-header {
  position: relative;
  background-image: linear-gradient(135deg, #15803d 0%, #166534 100%);
  background-size: cover;
  background-position: center;
  padding: 60px 20px;
  text-align: center;
  color: #fff;
}

.property-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.6) 100%);
}

.property-header > * {
  position: relative;
  z-index: 1;
}

.property-logo {
  width: 100px;
  height: 100px;
  margin: 0 auto 16px;
}

.property-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.property-name {
  font-size: 2.25rem;
  font-weight: 700;
  margin: 0 0 12px 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.property-tagline {
  color: rgba(255,255,255,0.9);
  font-size: 1.1rem;
  margin: 0 0 12px 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.property-contact {
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* =============================================
   WIZARD PROGRESS STEPPER
   ============================================= */
.progress-container {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 20px 0;
}

.progress-steps {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  max-width: 600px;
  margin: 0 auto;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
}

.progress-step:disabled {
  cursor: default;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  border: 2px solid #d1d5db;
  background: transparent;
  color: #9ca3af;
  transition: all 0.2s;
}

.progress-step.active .step-number {
  background: #15803d;
  border-color: #15803d;
  color: #fff;
}

.progress-step.completed .step-number {
  background: #15803d;
  border-color: #15803d;
  color: #fff;
}

.step-label {
  font-size: 14px;
  color: #9ca3af;
  font-weight: 500;
}

.progress-step.active .step-label {
  color: #15803d;
  font-weight: 600;
}

.progress-step.completed .step-label {
  color: #6b7280;
}

.progress-connector {
  width: 50px;
  height: 1px;
  background: #d1d5db;
}

.progress-connector.completed {
  background: #15803d;
}

/* =============================================
   MAIN LAYOUT
   ============================================= */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* =============================================
   SEARCH/FILTER SECTION
   ============================================= */
.search-section {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 24px;
  /* Extra bottom padding: rig filter-hint is position:absolute under the input */
  padding-bottom: 36px;
  margin-bottom: 24px;
  overflow: visible;
}

.search-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  /*
   * Bottom-align each filter-group so labels sit above a shared input row.
   * Do NOT use baseline here: a bare Search button and the date picker have
   * different baselines and the button drifts.
   */
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: flex-end;
  position: relative;
}

/*
 * Intake-driven search fields are injected into this host. Without
 * display:contents the host becomes one flex item and nested filter-groups
 * no longer share flex-end with Dates / Guests / Rig Length.
 */
.filter-intake-search {
  display: contents;
}

.filter-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  line-height: 1.2;
  /* Reserve one label line so groups without visible labels (Search) match */
  min-height: 1.2em;
}

/* Invisible label spacer so Search Sites sits on the same control row */
.filter-label-spacer {
  visibility: hidden;
  user-select: none;
  pointer-events: none;
}

.filter-select,
.filter-input {
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  min-width: 140px;
  background: #fff;
  box-sizing: border-box;
  min-height: 42px;
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: #15803d;
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.1);
}

/*
 * Rig-length helper text used to sit in normal flow under the input. With
 * align-items:flex-end that made the group taller and floated the input up
 * relative to Guests / pets. Keep it visible but out of flex sizing.
 */
.filter-hint {
  position: absolute;
  left: 0;
  top: calc(100% + 2px);
  font-size: 0.75rem;
  line-height: 1.2;
  color: #666;
  white-space: nowrap;
  pointer-events: none;
}

.filter-hint[hidden],
.filter-hint[style*="display: none"],
.filter-hint[style*="display:none"] {
  display: none !important;
}

.search-btn {
  background: #15803d;
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
  min-height: 42px;
  box-sizing: border-box;
  cursor: pointer;
  width: 100%;
}

.search-btn:hover {
  background: #166534;
}

/* =============================================
   RESULTS SECTION
   ============================================= */
.results-section {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
}

.results-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.results-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Map card — interactive <property-map> (Issue #85) */
.map-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 16px;
}

.map-card h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
}

.map-card property-map {
  display: block;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
}

/* Legacy static image fallback (older deployed sites) */
.map-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
}

/* Property info */
.info-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 16px;
}

.info-card h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
}

.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 14px;
  color: #4b5563;
}

.info-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.info-list li::before {
  content: '\2713';
  color: #15803d;
  font-weight: bold;
}

/* Results header — title row + optional banner; toggle never crushed */
.results-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 16px 20px;
}

.results-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.results-header-text {
  min-width: 0;
  flex: 1 1 auto;
}

.results-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.results-subtitle {
  display: inline-block;
  background: #f0fdf4;
  color: #166534;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  margin-top: 4px;
}

.whole-property-banner {
  flex: 0 1 100%;
  order: 3;
}

/* View toggle — List | Calendar | Map */
.view-toggle {
  display: inline-flex;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  margin-left: auto;
}

.view-toggle button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  transition: all 0.15s;
  white-space: nowrap;
}

.view-toggle button:not(:last-child) {
  border-right: 1px solid #d1d5db;
}

.view-toggle button:hover:not(.active) {
  background: #f9fafb;
}

.view-toggle button.active {
  background: #15803d;
  color: #fff;
}

/* Expanded map view (Issue #85) */
.map-view-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 16px 20px 20px;
}

.map-view-hint {
  margin: 0 0 12px;
  font-size: 14px;
  color: #6b7280;
}

.map-view-container property-map {
  display: block;
  width: 100%;
  min-height: 420px;
}

/* When Map tab is active: full-width main, hide left sidebar thumbnail map */
.results-section.map-view-active {
  grid-template-columns: 1fr;
}

.results-section.map-view-active .results-sidebar {
  display: none;
}

/* =============================================
   UNIT CARDS
   ============================================= */
.units-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.unit-card {
  display: flex;
  gap: 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 16px;
  transition: box-shadow 0.2s;
}

.unit-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.unit-image-wrapper {
  width: 140px;
  height: 105px;
  border-radius: 8px;
  background: var(--unit-image-placeholder-bg,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='1.5'%3E%3Cpath d='M3 21h18M5 21V7l7-4 7 4v14M9 21v-6h6v6'/%3E%3C/svg%3E") center center no-repeat,
    linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%)
  );
  flex-shrink: 0;
  overflow: hidden;
}

.unit-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


.unit-info {
  flex: 1;
  min-width: 0;
}

.unit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.unit-name {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.unit-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-available {
  background: #dcfce7;
  color: #166534;
}

.badge-unavailable {
  background: #fee2e2;
  color: #991b1b;
}

.badge-loading {
  background: #f3f4f6;
  color: #4b5563;
}

.badge-premium {
  background: #fef3c7;
  color: #92400e;
}

.badge-accessible {
  background: #dbeafe;
  color: #1e40af;
}

.unit-type {
  color: #6b7280;
  font-size: 14px;
  margin-bottom: 8px;
}

.unit-amenities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: #4b5563;
}

.amenity-tag {
  background: #f3f4f6;
  padding: 4px 10px;
  border-radius: 6px;
}

.unit-price {
  text-align: right;
  flex-shrink: 0;
}

.price-amount {
  font-size: 28px;
  font-weight: 700;
  color: #15803d;
}

.price-label {
  font-size: 12px;
  color: #6b7280;
}

.unit-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-view,
.btn-select {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
}

.btn-view {
  background: #f3f4f6;
  color: #374151;
}

.btn-view:hover {
  background: #e5e7eb;
}

.btn-select {
  background: #15803d;
  color: #fff;
}

.btn-select:hover {
  background: #166534;
}

/* Grid view container */
.grid-view-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
}

/* =============================================
   BOOK SECTION
   ============================================= */
.book-section {
  max-width: 900px;
  margin: 0 auto;
}

/* =============================================
   FOOTER
   ============================================= */
.site-footer {
  background: #111827;
  color: #fff;
  margin-top: 48px;
  padding: 48px 24px 24px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px;
}

.footer-section h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: #fff;
}

.footer-section p {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.footer-bottom {
  max-width: 1200px;
  margin: 32px auto 0;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
}

/* =============================================
   URI ROUTER STYLING
   ============================================= */
uri-router {
  display: block;
}

uri-router > *:not([slot="content"]) {
  display: none;
}

/* =============================================
   COMPONENT OVERRIDES
   ============================================= */

/* Date range picker - match form input styling */
date-range-picker {
  /* Field styling to match .filter-input/.filter-select */
  --drp-field-border: #d1d5db;
  --drp-field-border-hover: #15803d;
  --drp-field-radius: 8px;
  --drp-field-padding: 8px 12px;

  /* Match theme colors */
  --drp-primary: #15803d;
  --drp-primary-text: #fff;
  --drp-range-bg: #dcfce7;
  --drp-range-preview-bg: #f0fdf4;
  --drp-selecting-bg: #dcfce7;

  /* Text colors to match other inputs */
  --drp-text-color: #111827;
  --drp-text-muted: #6b7280;
  --drp-text-placeholder: #9ca3af;
}

/* Focus styling for date picker (via focus-within on field) */
date-range-picker:focus-within {
  --drp-field-border: #15803d;
}


/* Guest units grid sizing */
guest-units-grid {
  display: block;
  height: 500px;
}

/* Hide elements that should be hidden */
[hidden] {
  display: none !important;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .results-section {
    grid-template-columns: 1fr;
  }

  .results-sidebar {
    flex-direction: row;
    overflow-x: auto;
  }

  .map-card,
  .info-card {
    min-width: 280px;
    flex-shrink: 0;
  }

  .search-grid {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 600px) {
  .property-name {
    font-size: 1.75rem;
  }

  .property-header {
    padding: 40px 16px;
  }

  .main-content {
    padding: 16px;
  }

  .unit-card {
    flex-direction: column;
  }

  .unit-image-wrapper {
    width: 100%;
    height: 180px;
  }

  .unit-header {
    flex-direction: column;
  }

  .unit-price {
    text-align: left;
    margin-top: 12px;
  }

  /* Mobile: Stack step label below number */
  .progress-step {
    flex-direction: column;
    text-align: center;
    gap: 4px;
  }

  .progress-step .step-label {
    font-size: 11px;
    max-width: 80px;
  }

  .results-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  /* Mobile: Prevent booking form overflow */
  .book-section {
    max-width: 100%;
    overflow-x: hidden;
  }

  guest-booking-form {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Mobile: Date range picker - single month */
  date-range-picker {
    --drp-months: 1;
  }
}
