/* ============================================
   Buyer Space Layout Components
   ============================================
   Shared components for buyer space pages:
   - Agent Header (compact & extended variants)
   - Bottom Navigation Bar (mobile-first)
   - Theme Customization (logo & colors)
   ============================================ */

/* ============================================
   THEME CUSTOMIZATION
   ============================================ */

.buyer-space-logo {
  padding: 1rem 1.5rem;
  text-align: center;
  background: var(--sp-color-white);
  border-bottom: 1px solid var(--sp-color-grey-100);
}

.buyer-space-logo img {
  max-height: 60px;
  max-width: 200px;
  object-fit: contain;
}

/* ============================================
   BUYER AGENT HEADER
   ============================================ */

body {
  box-sizing: border-box;
}

.buyer-agent-header {
  background: transparent;
  padding: 1.5rem 1.5rem 1rem;
  padding-bottom: 0;
}

.buyer-agent-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.buyer-page-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--sp-color-text-primary);
  margin: 0;
  line-height: 1;
  letter-spacing: -0.02em;
}

.buyer-agent-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.buyer-agent-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--sp-color-grey-100);
  border: 2px solid var(--sp-color-white);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.buyer-agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.buyer-agent-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sp-color-primary-light);
  color: var(--sp-color-primary);
  font-size: 1rem;
}

.buyer-agent-details {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.buyer-agent-label {
  font-size: 0.6875rem;
  color: var(--sp-color-text-secondary);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.buyer-agent-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sp-color-text-primary);
  line-height: 1.2;
}

.buyer-agent-network {
  font-size: 0.75rem;
  color: var(--sp-color-text-secondary);
  font-weight: 400;
}

.buyer-agent-phone {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.25rem;
  text-decoration: none;
  color: var(--sp-color-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.buyer-agent-phone:hover {
  opacity: 0.8;
}

.buyer-agent-phone i {
  font-size: 0.75rem;
}

/* Extended variant - same as compact now for consistency */
.buyer-agent-header--extended {
  padding: 1.5rem 1.5rem 1rem;
  background: transparent;
  padding-bottom: 0 !important;
}

.buyer-agent-header--extended .buyer-page-title {
  font-size: 2.1rem;
  font-weight: 800;
}

.buyer-agent-header--extended .buyer-agent-avatar {
  width: 45px;
  height: 45px;
}

/* Back button (used in header when showBackButton is set) */
.buyer-agent-header .back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  background: var(--sp-color-white, white);
  border: none;
  border-radius: 999px;
  color: var(--sp-color-text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.buyer-agent-header .back-button:hover {
  background: var(--sp-color-grey-100, #f0f1f3);
}

.buyer-agent-header .back-button:active {
  transform: scale(0.95);
}

/* ============================================
   BUYER AGENT DISCLAIMER
   ============================================ */

.buyer-disclaimer {
  max-width: 1200px;
  margin: 0.75rem auto 1rem;
  padding: 0 1.5rem;
}

.buyer-disclaimer-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--sp-color-grey-50, #f8f9fa);
  transition: background 0.2s ease;
}

.buyer-disclaimer-toggle:hover {
  background: var(--sp-color-grey-100, #f0f1f3);
}

.buyer-disclaimer-icon {
  color: var(--sp-color-text-secondary);
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.buyer-disclaimer-summary {
  font-size: 0.8125rem;
  color: var(--sp-color-text-secondary);
  font-weight: 500;
  flex: 1;
}

.buyer-disclaimer-chevron {
  font-size: 0.625rem;
  color: var(--sp-color-text-secondary);
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.buyer-disclaimer-toggle.is-open .buyer-disclaimer-chevron {
  transform: rotate(180deg);
}

.buyer-disclaimer-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 0.75rem;
}

.buyer-disclaimer-body.is-open {
  max-height: 300px;
  padding: 0.75rem;
}

.buyer-disclaimer-body p {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--sp-color-text-secondary);
  margin: 0 0 0.5rem;
}

.buyer-disclaimer-body p:last-child {
  margin-bottom: 0;
}

.buyer-disclaimer-cta {
  font-weight: 600;
  color: var(--buyer-primary, var(--sp-color-primary)) !important;
}

/* ============================================
   BUYER SPACE NAVIGATION
   ============================================ */

.buyer-space-nav {
  position: fixed;
  bottom: 0.3rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgb(255 255 255 / 67%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0.75rem;
  gap: 0.375rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  border: 1px solid #00384d1f;
  max-width: 90%;
  width: auto;
}

.buyer-space-nav-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  color: var(--sp-color-text-secondary);
  text-decoration: none;
  transition:
    color 0.25s ease-out,
    background 0.2s ease;
  border-radius: 14px;
  background: transparent;
  position: relative;
  white-space: nowrap;
  line-height: 1;
}

.buyer-space-nav-item:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--sp-color-text-primary);
}

.buyer-space-nav-icon {
  font-size: 1.25rem;
  transition: transform 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.buyer-space-nav-item:hover .buyer-space-nav-icon {
  transform: scale(1.05);
}

.buyer-space-nav-label {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
}

.buyer-space-nav-item--active {
  position: relative;
  color: var(--buyer-primary-text, var(--sp-color-white));
  font-weight: 600;
}

/* Background animé séparément du contenu pour transition fluide */
.buyer-space-nav-item--active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--buyer-primary, var(--sp-color-primary));
  border-radius: 14px;
  z-index: -1;
  view-transition-name: active-buyer-nav-item;
}

.buyer-space-nav-item--active .buyer-space-nav-label {
  font-weight: 600;
}

.buyer-space-nav-item--active:hover {
  color: var(--buyer-primary-text, var(--sp-color-white));
  background: transparent;
}

/* ============================================
   LAYOUT ADJUSTMENTS FOR PAGES
   ============================================ */

/* Add padding to body when navigation is present */
body:has(.buyer-space-nav) {
  padding-bottom: 70px;
}

/* Ensure main content doesn't overlap with navigation */
.buyer-review-container,
.buyer-history-container,
.search-update-container {
  min-height: calc(100vh - 80px);
  padding-bottom: 2rem;
}

/* Desktop: no special adjustment needed with sticky top nav */
@media (min-width: 768px) {
  .buyer-review-container,
  .buyer-history-container,
  .search-update-container {
    min-height: auto;
    padding-bottom: 2rem;
  }
}

/* ============================================
   RESPONSIVE - DESKTOP
   ============================================ */

@media (min-width: 768px) {
  /* Desktop: Sticky top navigation */
  .buyer-agent-header--extended .buyer-page-title {
    font-size: 3.5rem;
    font-weight: 800;
  }

  .buyer-space-nav {
    position: fixed;
    top: 0;
    bottom: auto;
    left: 0;
    right: 0;
    transform: none;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    max-width: 100%;
    width: 100%;
    justify-content: center;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 1000;
  }

  .buyer-space-nav-item {
    padding: 0.75rem 1.25rem;
    gap: 0.75rem;
  }

  .buyer-space-nav-icon {
    font-size: 1.25rem;
  }

  .buyer-space-nav-label {
    font-size: 0.9375rem;
  }

  /* Add top padding to prevent content being hidden behind fixed nav */
  body:has(.buyer-space-nav) {
    padding-top: 70px;
    padding-bottom: 0;
  }

  .buyer-agent-header {
    padding: 1.5rem 2rem;
    padding-bottom: 0;
  }

  .buyer-agent-header--extended {
    padding: 2rem 2rem;
    padding-bottom: 0;
  }

  .buyer-agent-header--extended .buyer-agent-avatar {
    width: 72px;
    height: 72px;
  }
}

@media (min-width: 1024px) {
  .buyer-space-nav {
    padding: 0.875rem 1.5rem;
    gap: 0.75rem;
  }

  .buyer-space-nav-item {
    padding: 0.875rem 1.5rem;
    gap: 0.875rem;
  }

  .buyer-space-nav-icon {
    font-size: 1.375rem;
  }

  .buyer-space-nav-label {
    font-size: 1rem;
  }

  /* Adjust top padding for larger nav on bigger screens */
  body:has(.buyer-space-nav) {
    padding-top: 70px;
  }

  .buyer-agent-header-content {
    gap: 1.5rem;
    max-width: 1000px;
  }

  .buyer-disclaimer {
    max-width: 1000px;
    padding: 0 2rem;
  }
}

/* ============================================
   VIEW TRANSITIONS API
   ============================================ */

/* Exclure la navigation et le header de toute transition */
.buyer-space-nav,
.buyer-agent-header {
  view-transition-name: none;
}

/* Simple fade sur le contenu uniquement */
::view-transition-old(root) {
  animation: simple-fade-out 0.2s ease;
}

::view-transition-new(root) {
  animation: simple-fade-in 0.2s ease;
}

@keyframes simple-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes simple-fade-in {
  from {
    opacity: 0;
  }
}
