/* --- GLOBAL RESET FOR SIDEBAR PARITY --- */
#ui-sidebar,
#ui-sidebar *,
.site-header.map-header,
.controls-bar {
  box-sizing: border-box !important;
}

/* --- CORE LAYOUT (Matching map.css) --- */
#main-layout {
  display: flex;
  flex-direction: row;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

#ui-sidebar {
  display: flex;
  flex-direction: column;
  width: 350px;
  height: 100%;
  flex-shrink: 0;
  z-index: 2000;
  background: var(--deep-midnight);
  box-shadow: 4px 0 15px rgb(0 0 0 / 30%);
  border-right: 1px solid var(--golden-hour);
  overflow-y: auto;
  padding: 20px;
  gap: 20px;
}

#grid-container {
  flex: 1;
  height: 100%;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  background: radial-gradient(circle at center, #f8f9fa 0%, #e9ecef 100%);
  padding: 40px;
  box-sizing: border-box;
}

/* --- BRANDED HEADER (Identical to map.css) --- */
.site-header.map-header {
  padding: 25px !important;
  margin: 0 !important;
  height: auto !important;
  flex-shrink: 0;
  background: var(--bright-sky);
  border: 1px solid var(--golden-hour) !important;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 20%);
  text-align: center;
  position: relative;
}

.header-branding-img {
  max-width: 180px;
  height: auto;
  margin-bottom: 5px;
}

.map-theme-toggle {
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 1.5em;
  color: var(--electric-grape);
  z-index: 10;
  background: none;
  border: none;
  cursor: pointer;
}

/* --- CONTROLS BAR (Identical to map.css) --- */
.controls-bar {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  background: var(--bright-sky);
  border: 1px solid var(--golden-hour);
  border-radius: 12px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.neon-label-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--deep-midnight);
  text-transform: uppercase;
}

/* --- SUB-FILTERS --- */
.sub-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-left: 15px;
  border-left: 2px solid var(--electric-grape);
  transition: all 0.3s ease;
}

.sub-filters.hidden {
  display: none !important;
}

.sub-label span {
  font-size: 0.75rem;
  opacity: 0.9;
}

.sub-checkbox {
  transform: scale(0.85);
  transform-origin: right center;
}

/* --- DARK MODE OVERRIDES (Matching map.css) --- */
body.dark-mode #grid-container {
  background: radial-gradient(circle at center, #1b2032 0%, #0f0f19 100%);
}

body.dark-mode .site-header.map-header,
body.dark-mode .controls-bar {
  background-color: var(--deep-midnight) !important;
  border: 1px solid var(--golden-hour) !important;
}

body.dark-mode .neon-label-wrap {
  color: var(--bright-sky);
}

body.dark-mode .card-back {
  background: #1b2032;
  color: #fff;
}

body.dark-mode .hotel-card.flipped .card-back {
  box-shadow: 0 30px 60px rgb(0, 0, 0, 0.9);
}

/* --- NEON CHECKBOXES --- */
.neon-checkbox {
  appearance: none;
  width: 44px;
  height: 22px;
  background: rgb(0, 0, 0, 0.1);
  border-radius: 20px;
  position: relative;
  border: 1px solid var(--electric-grape);
  transition: 0.3s;
}

.neon-checkbox:checked {
  background: var(--electric-grape);
  box-shadow: 0 0 10px var(--electric-grape);
}

.neon-checkbox::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--golden-hour);
  border-radius: 50%;
  top: 2px;
  left: 3px;
  transition: 0.3s;
}

.neon-checkbox:checked::before {
  left: 23px;
}

/* --- CONSTELLATION GRID --- */
#hotel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 30px;
  perspective: 1200px;
}

.hotel-card {
  height: 450px;
  cursor: pointer;
  position: relative;
  transition:
    opacity 0.5s ease,
    transform 0.5s ease,
    filter 0.5s ease;
  transform-style: preserve-3d;
  z-index: 1;
}

.hotel-card.flipped {
  z-index: 9999 !important;
  transform: translateZ(50px) !important;
}

#hotel-grid.has-flipped .hotel-card:not(.flipped) {
  opacity: 0.2 !important;
  filter: grayscale(1) blur(2px) !important;
  transform: scale(0.95) translateZ(-10px) !important;
  z-index: 0 !important;
  pointer-events: none !important;
}

.hotel-card.dimmed {
  opacity: 0.15;
  filter: grayscale(0.8);
}

.hotel-card.qualifying {
  transform: scale(1.05);
  z-index: 5;
}

.hotel-card.qualifying .card-front {
  border: 2px solid var(--golden-hour);
  box-shadow: 0 0 30px var(--golden-hour);
}

.card-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

/* --- DIRECTIONAL EXPANSION LOGIC --- */
.hotel-card.flipped .card-inner {
  transform: rotateY(180deg);
  top: -50px;
  left: -20px;
  width: calc(100% + 40px);
  height: calc(100% + 100px);
}

.hotel-card.flipped.edge-left .card-inner {
  left: 20px;
}

.hotel-card.flipped.edge-right .card-inner {
  left: -60px;
}

.hotel-card.flipped.edge-top .card-inner {
  top: 20px;
}

.hotel-card.flipped.edge-bottom .card-inner {
  top: -120px;
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgb(225, 166, 60, 30%);
  box-sizing: border-box;
}

.card-front {
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hotel-name-overlay {
  background: rgb(255, 255, 255, 90%);
  padding: 20px;
  backdrop-filter: blur(10px);
  color: var(--deep-midnight);
  font-family: Montserrat, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 1.25rem;
  text-align: center;
  border-top: 1px solid var(--golden-hour);
}

body.dark-mode .hotel-name-overlay {
  background: rgb(0, 0, 0, 80%);
  color: #fff;
}

.card-back {
  background: var(--bright-sky);
  transform: rotateY(180deg);
  padding: 25px;
  display: flex;
  flex-direction: column;
  color: var(--deep-midnight);
  border: 2px solid var(--golden-hour);
  box-shadow: 0 4px 15px rgb(0, 0, 0, 10%);
  transition: box-shadow 0.6s ease;
  overflow-y: auto;
}

.card-back-title {
  color: var(--golden-hour);
  margin: 0 0 20px 0;
  text-align: center;
  font-family: Montserrat, sans-serif;
  text-transform: uppercase;
  font-size: 1.6rem;
  letter-spacing: 2px;
}

.card-back-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.section-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.section-icon {
  color: var(--golden-hour);
  font-size: 1.1rem;
  margin-top: 3px;
  width: 20px;
  text-align: center;
}

.section-text strong {
  display: block;
  color: var(--golden-hour);
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.section-text p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
  opacity: 0.9;
}

.highs-lows-box {
  margin-top: auto;
  padding: 15px;
  border: 1px solid var(--golden-hour);
  border-radius: 8px;
  background: rgb(0, 0, 0, 5%);
}

body.dark-mode .highs-lows-box {
  background: rgb(255, 255, 255, 3%);
}

.hl-title {
  font-weight: 700;
  color: var(--golden-hour);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.hl-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.8rem;
}

.hl-list li {
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hl-list.highs li i {
  color: #4caf50;
}

.hl-list.lows li i {
  color: #f44336;
}

.hl-list.lows {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgb(225, 166, 60, 20%);
}

.card-back::-webkit-scrollbar {
  width: 6px;
}
.card-back::-webkit-scrollbar-thumb {
  background-color: var(--golden-hour);
  border-radius: 10px;
}

.hotel-card.flipped .card-back {
  box-shadow: 0 30px 60px rgb(0, 0, 0, 50%);
}

/* --- RESPONSIVE OVERRIDES --- */
@media (width <= 1024px) {
  html,
  body,
  #main-layout {
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    position: relative !important;
    overscroll-behavior: auto !important;
  }

  #main-layout {
    flex-direction: column;
  }

  #ui-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--golden-hour);
    padding: 15px;
    overflow: visible;
  }

  #grid-container {
    width: 100%;
    flex: none !important;
    display: block !important;
    padding: 20px 20px 250px;
    height: auto;
    overflow: visible;
  }

  .site-header.map-header {
    padding: 15px !important;
  }

  .header-branding-img {
    max-height: 40px;
    width: auto;
  }

  .site-subtitle {
    display: block;
    font-size: 0.75rem !important;
    margin-top: 2px !important;
  }

  .controls-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
  }

  .controls-header {
    grid-column: span 2;
  }
}

@media (width <= 600px) {
  .controls-bar {
    grid-template-columns: 1fr;
  }

  .controls-header {
    grid-column: span 1;
  }

  #hotel-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
  }

  .hotel-card {
    height: 240px;
  }

  .hotel-card.flipped .card-inner {
    top: -60px;
    left: -30px;
    width: calc(100% + 60px);
    height: calc(100% + 120px);
  }

  .hotel-card.flipped.edge-left .card-inner {
    left: -10px;
  }
  .hotel-card.flipped.edge-right .card-inner {
    left: -50px;
  }

  .hotel-card.flipped.edge-top .card-inner {
    top: 25px;
  }
  .hotel-card.flipped.edge-bottom .card-inner {
    top: -145px;
  }

  .hotel-card.qualifying {
    transform: scale(1.02);
  }

  .hotel-card.qualifying .card-front {
    box-shadow: 0 0 15px var(--golden-hour);
  }

  .hotel-name-overlay {
    padding: 10px;
    font-size: 0.9rem;
  }

  .card-back {
    padding: 15px;
    font-size: 0.85rem;
  }

  .card-back-title {
    font-size: 1.1rem;
    margin-bottom: 10px;
  }

  .section-text strong {
    font-size: 0.75rem;
  }

  .section-text p {
    font-size: 0.75rem;
  }
}
