/* =========================================
   CoHome SG — Room Detail Page
   ========================================= */

html, body { overflow-x: hidden; max-width: 100vw; }

/* ── Loading ── */
.room-detail-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  color: var(--text-muted);
}
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--light-grey);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Gallery ── */
.room-gallery {
  position: relative;
  height: clamp(280px, 50vw, 520px);
  overflow: hidden;
  background: var(--white);
  margin-top: 70px;
}

@media (min-width: 769px) {
  .room-gallery {
    height: clamp(220px, 35vw, 380px);
  }
}

.gallery-slider {
  display: flex;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

/* Desktop: 3 images per slide */
.gallery-slide {
  flex: 0 0 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.gallery-slide.gallery-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
}
.gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  background: var(--light-grey);
}

/* Mobile: single image view */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  .room-detail-body, .room-detail-layout, .room-detail-left, .room-detail-right { max-width: 100vw; overflow-x: hidden; }
  .room-detail-body { padding-left: 12px; padding-right: 12px; }
  
  .room-gallery {
    height: auto;
    overflow: visible;
  }
  .gallery-slider {
    height: clamp(220px, 60vw, 360px);
  }
  .gallery-slide {
    display: block;
  }
  .gallery-slide.gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .gallery-slide img {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .gallery-thumbs {
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    display: flex;
    margin-top: 12px;
    padding: 0 12px 12px;
    justify-content: center;
    flex-wrap: wrap;
  }
  .gallery-thumb {
    width: 48px;
    height: 34px;
  }
  
  .amenities-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  
  .detail-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .detail-item {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    min-width: 0;
    text-align: center;
  }
  .detail-item .material-icons { font-size: 1.2rem; width: auto; }
  .detail-item-label { font-size: 0.65rem; }
  .detail-item-value {
    font-size: 0.75rem;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  
  .detail-card { padding: 16px; }
  .detail-card-title { font-size: 1.15rem; }
  .amenity-item span:not(.material-icons) {
    font-size: 0.72rem;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .amenity-item {
    padding: 12px 8px;
    min-width: 0;
  }
  
  .rent-row { font-size: 0.85rem; padding: 10px 0; }
  .rent-row.total { padding: 12px; }
  .rent-row.total .rent-row-value { font-size: 1rem; }
  
  .booking-card { padding: 20px; }
  .booking-room-name { font-size: 1.25rem; }
  .booking-price { font-size: 1.8rem; }
  
  .mobile-sticky-bar { display: flex !important; }
  .room-detail-body { padding-bottom: 100px; }
  
  .booking-card .btn-whatsapp,
  .booking-card .btn-outline {
    display: none;
  }
}

/* Gallery container wrapper */
.room-gallery-container {
  background: var(--white);
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(26, 26, 46, 0.75);
  border: none;
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  transition: var(--transition);
}
.gallery-nav:hover {
  background: var(--accent);
  color: var(--primary);
}
.gallery-nav.prev { left: 4px; }
.gallery-nav.next { right: 4px; }

@media (min-width: 769px) {
  .gallery-nav {
    width: 48px;
    height: 48px;
  }
  .gallery-nav.prev { left: 8px; }
  .gallery-nav.next { right: 8px; }
}

.gallery-thumbs {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 4;
}
.gallery-thumb {
  width: 54px;
  height: 38px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.3);
  transition: var(--transition);
}
.gallery-thumb.active { border-color: var(--accent); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

.gallery-counter {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(26,26,46,0.7);
  color: var(--white);
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: var(--border-radius-pill);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  z-index: 4;
}

/* ── Body Layout ── */
.room-detail-body {
  padding-top: 40px;
  padding-bottom: 80px;
}

.room-detail-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.room-detail-breadcrumb a { color: var(--accent); }
.room-detail-breadcrumb span { color: var(--text-muted); }
.room-detail-breadcrumb .material-icons { font-size: 1rem; color: var(--mid-grey); }

.room-detail-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 32px;
  align-items: start;
}

/* ── Detail Cards ── */
.detail-card {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--light-grey);
  margin-bottom: 24px;
}
.detail-card:last-child { margin-bottom: 0; }

.detail-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--light-grey);
}
.detail-card-title .material-icons { color: var(--accent); font-size: 1.5rem; }

/* Room Details Grid */
.detail-items { 
  display: grid; 
  grid-template-columns: repeat(2, 1fr);
  gap: 16px; 
}
.detail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  background: var(--off-white);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--light-grey);
  text-align: center;
}
@media (min-width: 769px) {
  .detail-items { grid-template-columns: repeat(3, 1fr); }
}
.detail-item .material-icons {
  color: var(--accent);
  font-size: 1.4rem;
  flex-shrink: 0;
  width: auto;
  text-align: center;
}
.detail-item-label { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-item-value { font-weight: 600; color: var(--primary); font-size: 0.95rem; }
.detail-item > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

/* Amenities Grid */
.amenities-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.amenity-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  background: var(--off-white);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--light-grey);
  text-align: center;
  transition: var(--transition);
}
.amenity-item:hover {
  background: var(--accent-light);
  border-color: rgba(200,169,110,0.4);
}
.amenity-item .material-icons { color: var(--accent); font-size: 1.5rem; }
.amenity-item span:not(.material-icons) { font-size: 0.95rem; color: var(--text-secondary); font-weight: 500; }
.amenity-item.unavailable { opacity: 0.35; }
.amenity-item.unavailable .material-icons { color: var(--text-muted); }

/* Rent Details */
.rent-details { display: flex; flex-direction: column; gap: 14px; }
.rent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--light-grey);
  font-size: 0.95rem;
}
.rent-row:last-child { border-bottom: none; }
.rent-row-label { color: var(--text-muted); }
.rent-row-value { font-weight: 600; color: var(--primary); }
.rent-row.total {
  padding: 16px;
  background: var(--accent-light);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(200,169,110,0.3);
  border-bottom: 1px solid rgba(200,169,110,0.3);
}
.rent-row.total .rent-row-label { font-weight: 700; color: var(--primary); }
.rent-row.total .rent-row-value { font-size: 1.1rem; color: var(--accent-hover); }

/* Map */
.map-wrapper {
  border-radius: var(--border-radius);
  overflow: hidden;
  height: 320px;
  border: 1px solid var(--light-grey);
  margin-bottom: 12px;
  background: var(--light-grey);
}
.map-wrapper iframe { width: 100%; height: 100%; border: none; }
.map-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.map-placeholder .material-icons { font-size: 2.5rem; color: var(--mid-grey); }
.map-address {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Booking Card (sticky) ── */
.room-detail-right {
  position: sticky;
  top: 90px;
}

.booking-card {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  box-shadow: none;
  border: 1px solid var(--light-grey);
}

.booking-room-name {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--primary);
  margin: 12px 0;
  line-height: 1.3;
}

.booking-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.booking-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--off-white);
  border: 1px solid var(--light-grey);
  padding: 5px 12px;
  border-radius: var(--border-radius-pill);
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.booking-tag .material-icons { font-size: 0.9rem; color: var(--accent); }

.booking-price-block {
  padding: 20px;
  background: var(--off-white);
  border-radius: var(--border-radius);
  margin-bottom: 20px;
  border: 1px solid var(--light-grey);
}
.booking-price {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.booking-price span { font-size: 1rem; color: var(--text-muted); font-family: var(--font-body); font-weight: 400; }
.booking-utilities { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }

.booking-divider {
  height: 1px;
  background: var(--light-grey);
  margin: 20px 0;
}

/* ── Body Layout ── */
.booking-fact-label { color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.booking-fact-label .material-icons { font-size: 0.95rem; color: var(--accent); }
.booking-fact-value { font-weight: 600; color: var(--primary); }

.booking-note {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .room-detail-layout { grid-template-columns: 1fr; }
  .room-detail-right { position: static; }
  .booking-card { margin-bottom: 32px; }
  .room-detail-left { order: 2; }
  .room-detail-right { order: 1; }
}

/* Mobile Sticky Bottom Bar */
.mobile-sticky-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: transparent;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: none;
  z-index: 1000;
  gap: 12px;
}

@media (max-width: 768px) {
  .mobile-sticky-bar {
    display: flex;
  }

  .room-gallery {
    height: auto;
    overflow: visible;
  }

  .gallery-slider {
    height: clamp(220px, 60vw, 360px);
  }

  .gallery-thumbs {
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding: 0 12px 12px;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .gallery-thumb {
    width: 48px;
    height: 34px;
    flex: 0 0 auto;
  }
}

.mobile-sticky-bar .btn {
  flex: 1;
  padding: 14px 20px;
  font-size: 1rem;
}

.mobile-sticky-bar .btn-outline {
  background: var(--gold-gradient);
  color: var(--primary);
  border: none;
  box-shadow: 0 4px 20px rgba(200, 169, 110, 0.4);
}

.mobile-sticky-bar .btn-outline:hover {
  background: var(--gold-gradient);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(200, 169, 110, 0.55);
}

@media (max-width: 768px) {
  .amenities-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
