/**
 * Aubui — page layout Social
 * Structure seulement (feed, garage, fiche). Pas de nouveaux boutons.
 * Dépend de tokens + base + button + card + nav + accent + utilities.
 */

/* —— Shell —— */
.aub-social {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--aub-bg);
  color: var(--aub-fg);
}

.aub-social-main {
  flex: 1;
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--aub-space-5);
}

.aub-social-main--narrow {
  max-width: 42rem;
}

/* Barre recherche sous navbar globale */
.aub-social-searchbar {
  display: flex;
  justify-content: center;
  padding: var(--aub-space-2) var(--aub-space-4);
  border-bottom: 1px solid var(--aub-border);
  background: var(--aub-bg);
}
.aub-social-searchbar .aub-social-search {
  width: 100%;
  max-width: 28rem;
  flex: none;
}


/* —— Nav recherche —— */
.aub-social-search {
  position: relative;
  flex: 1;
  max-width: 28rem;
  min-width: 10rem;
}

.aub-social-search .aub-input {
  width: 100%;
}

.aub-social-search__results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--aub-bg-elevated);
  border: 1px solid var(--aub-border);
  border-radius: var(--aub-radius);
  max-height: 16rem;
  overflow-y: auto;
  display: none;
  box-shadow: var(--aub-shadow);
}

.aub-social-search__results.is-open {
  display: block;
}

.aub-social-search__item {
  display: block;
  padding: var(--aub-space-3) var(--aub-space-4);
  border-bottom: 1px solid var(--aub-border);
  color: var(--aub-fg);
  text-decoration: none;
  font-size: var(--aub-text-sm);
}

.aub-social-search__item:last-child {
  border-bottom: 0;
}

.aub-social-search__item:hover {
  background: var(--aub-bg-muted);
}

.aub-social-search__item strong {
  color: var(--aub-accent);
}

.aub-social-search__empty {
  padding: var(--aub-space-4);
  text-align: center;
  color: var(--aub-fg-muted);
  font-size: var(--aub-text-sm);
}

/* —— Feed grid —— */
.aub-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: var(--aub-space-4);
}

.aub-feed__empty,
.aub-feed__loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--aub-space-10) var(--aub-space-4);
  color: var(--aub-fg-muted);
  font-size: var(--aub-text-sm);
}

/* —— Media card (voiture / post feed) —— */
.aub-media-card {
  display: flex;
  flex-direction: column;
  background: var(--aub-bg-elevated);
  border: 1px solid var(--aub-border);
  border-radius: var(--aub-radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--aub-transition), box-shadow var(--aub-transition);
  min-height: 100%;
}

.aub-media-card:hover {
  border-color: var(--aub-accent);
  box-shadow: var(--aub-shadow-sm);
}

.aub-media-card__media {
  aspect-ratio: 16 / 10;
  background: var(--aub-bg-muted) center / cover no-repeat;
  border-bottom: 1px solid var(--aub-border);
}

.aub-media-card__body {
  padding: var(--aub-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--aub-space-2);
  flex: 1;
}

.aub-media-card__title {
  font-size: var(--aub-text-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.aub-media-card__meta {
  font-size: var(--aub-text-sm);
  color: var(--aub-fg-muted);
}

.aub-media-card__desc {
  font-size: var(--aub-text-xs);
  color: var(--aub-fg-subtle);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* —— Garage grid —— */
.aub-garage {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: var(--aub-space-4);
}

.aub-garage__add {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 10rem;
  border: 2px dashed var(--aub-border);
  border-radius: var(--aub-radius-lg);
  color: var(--aub-fg-muted);
  font-size: 2rem;
  font-weight: 300;
  cursor: pointer;
  background: transparent;
  transition: border-color var(--aub-transition), color var(--aub-transition);
}

.aub-garage__add:hover {
  border-color: var(--aub-accent);
  color: var(--aub-accent);
}

/* —— Specs list (fiche) —— */
.aub-specs {
  list-style: none;
  padding: 0;
  margin: 0;
}

.aub-specs li {
  display: flex;
  justify-content: space-between;
  gap: var(--aub-space-3);
  padding: var(--aub-space-2) 0;
  border-bottom: 1px solid var(--aub-border);
  font-size: var(--aub-text-sm);
}

.aub-specs li:last-child {
  border-bottom: 0;
}

.aub-specs strong {
  color: var(--aub-fg-muted);
  font-weight: 500;
}

/* —— Profile header —— */
.aub-profile-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--aub-space-4);
  margin-bottom: var(--aub-space-6);
}

.aub-profile-head__name {
  font-size: var(--aub-text-2xl);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.aub-profile-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--aub-space-2);
}

/* —— Settings rows —— */
.aub-settings-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--aub-space-4);
  padding: var(--aub-space-3) 0;
  border-bottom: 1px solid var(--aub-border);
  font-size: var(--aub-text-sm);
}

.aub-settings-row:last-child {
  border-bottom: 0;
}

.aub-settings-row__label {
  color: var(--aub-fg-muted);
  flex-shrink: 0;
}

.aub-settings-row__value {
  text-align: right;
  word-break: break-word;
}


/* —— Chat (mobile-first, IG / Snap-like) —— */

/* Viewport lock on chat pages */
html:has(.aub-chat-layout),
body:has(.aub-chat-layout) {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  margin: 0;
}
body.aub-social:has(.aub-chat-layout) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100dvh;
  overflow: hidden;
}

/* Hide global search on mobile when in a conversation */
@media (max-width: 720px) {
  body:has(.aub-chat-layout.has-peer) .aub-social-searchbar {
    display: none;
  }
}

body:has(.aub-chat-layout) .aub-social-searchbar {
  flex-shrink: 0;
}

body:has(.aub-chat-layout) .aub-social-main {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 40rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.aub-chat-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  width: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
  background: var(--aub-bg);
}

/* —— Thread list —— */
.aub-chat-list {
  border-right: 1px solid var(--aub-border);
  background: var(--aub-bg);
  overflow-y: auto;
  min-height: 0;
  height: 100%;
  -webkit-overflow-scrolling: touch;
}
.aub-chat-list__head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--aub-border);
  background: var(--aub-bg);
}
.aub-chat-list__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.aub-chat-list__empty {
  margin: 0;
  padding: 1.5rem 1rem;
  color: var(--aub-fg-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
}
.aub-chat-threads {
  list-style: none;
  margin: 0;
  padding: 0;
}
.aub-chat-thread {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--aub-border);
  position: relative;
  min-height: 4rem;
}
.aub-chat-thread:hover,
.aub-chat-thread.is-active {
  background: var(--aub-bg-muted);
}
.aub-chat-thread__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.aub-chat-thread__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.aub-chat-thread__name {
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.aub-chat-thread__time {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--aub-fg-muted);
}
.aub-chat-thread__preview {
  font-size: 0.8rem;
  color: var(--aub-fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.aub-chat-badge {
  flex-shrink: 0;
  background: var(--aub-accent, #3b82f6);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.35rem;
}

/* Avatars lettres */
.aub-chat-avatar {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--aub-accent, #3b82f6);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}
.aub-chat-avatar--sm {
  width: 2rem;
  height: 2rem;
  font-size: 0.85rem;
}

/* —— Conversation pane —— */
.aub-chat-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--aub-bg);
}
.aub-chat-pane__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--aub-border);
  background: var(--aub-bg);
  min-height: 3.25rem;
}
.aub-chat-back {
  display: none;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  text-decoration: none;
  color: var(--aub-fg);
  font-size: 1.25rem;
  line-height: 1;
}
.aub-chat-back:hover {
  background: var(--aub-bg-muted);
}
.aub-chat-peer {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  font-weight: 600;
}
.aub-chat-peer__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.aub-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.aub-chat-bubble {
  max-width: min(78%, 22rem);
  align-self: flex-start;
  background: var(--aub-bg-elevated, var(--aub-bg-muted));
  border: 1px solid var(--aub-border);
  border-radius: 1.15rem 1.15rem 1.15rem 0.35rem;
  padding: 0.5rem 0.75rem 0.35rem;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
.aub-chat-bubble.is-mine {
  align-self: flex-end;
  background: var(--aub-accent, #3b82f6);
  color: #fff;
  border-color: transparent;
  border-radius: 1.15rem 1.15rem 0.35rem 1.15rem;
}
.aub-chat-bubble p {
  margin: 0;
  font-size: 0.925rem;
  line-height: 1.35;
  word-break: break-word;
}
.aub-chat-bubble time {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.65rem;
  opacity: 0.7;
  text-align: right;
}
.aub-chat-bubble.is-mine time {
  color: rgba(255, 255, 255, 0.85);
}
.aub-chat-img-link {
  display: block;
}
.aub-chat-img {
  max-width: min(70vw, 240px);
  max-height: 240px;
  width: auto;
  height: auto;
  border-radius: 0.85rem;
  display: block;
  margin-bottom: 0.25rem;
  object-fit: cover;
}
.aub-chat-audio {
  display: block;
  max-width: min(70vw, 240px);
  margin-bottom: 0.25rem;
}

.aub-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 2rem 1.25rem;
  text-align: center;
}
.aub-chat-empty__icon {
  font-size: 2rem;
  margin-bottom: 0.35rem;
  opacity: 0.85;
}
.aub-chat-empty p {
  margin: 0;
}

/* —— Composer (barre type messagerie mobile) —— */
.aub-chat-compose-wrap {
  flex-shrink: 0;
  padding: 0.45rem 0.6rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--aub-border);
  background: var(--aub-bg);
}
.aub-chat-file-label {
  margin: 0 0 0.35rem;
  padding: 0 0.35rem;
  font-size: 0.75rem;
  color: var(--aub-fg-muted);
}
.aub-chat-compose {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--aub-bg-muted);
  border: 1px solid var(--aub-border);
  border-radius: 999px;
  padding: 0.25rem 0.3rem 0.25rem 0.45rem;
}
.aub-chat-compose__tools {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
}
.aub-chat-tool {
  width: 2.1rem;
  height: 2.1rem;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  color: inherit;
  padding: 0;
  user-select: none;
}
.aub-chat-tool:hover {
  background: var(--aub-bg-elevated, rgba(255, 255, 255, 0.06));
}
.aub-chat-tool.is-recording {
  color: #ef4444;
  animation: aub-pulse 1s ease infinite;
}
.aub-chat-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--aub-fg);
  font-size: 0.95rem;
  padding: 0.45rem 0.35rem;
  outline: none;
}
.aub-chat-input::placeholder {
  color: var(--aub-fg-muted);
}
.aub-chat-send {
  flex-shrink: 0;
  width: 2.15rem;
  height: 2.15rem;
  border: none;
  border-radius: 50%;
  background: var(--aub-accent, #3b82f6);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.aub-chat-send:hover {
  filter: brightness(1.08);
}
.aub-chat-send:active {
  transform: scale(0.96);
}

@keyframes aub-pulse {
  50% { opacity: 0.55; }
}

/* —— Mobile: plein écran conversation —— */
@media (max-width: 720px) {
  .aub-chat-layout {
    grid-template-columns: 1fr;
  }
  .aub-chat-layout.has-peer .aub-chat-list {
    display: none;
  }
  .aub-chat-layout:not(.has-peer) .aub-chat-pane {
    display: none;
  }
  .aub-chat-back {
    display: inline-flex;
  }
  body:has(.aub-chat-layout) .aub-social-main {
    max-width: 100%;
  }
}

/* Desktop polish */
@media (min-width: 721px) {
  body:has(.aub-chat-layout) .aub-social-main {
    max-width: 52rem;
    padding: 0.5rem 0.75rem !important;
  }
  .aub-chat-layout {
    border: 1px solid var(--aub-border);
    border-radius: var(--aub-radius-lg, 12px);
    background: var(--aub-bg-elevated, var(--aub-bg));
    overflow: hidden;
  }
  .aub-chat-back {
    display: none;
  }
}

/* Profile stats (conservé) */
.aub-profile-stats {
  display: flex;
  gap: var(--aub-space-4, 1rem);
  margin-top: var(--aub-space-2, 0.5rem);
  font-size: var(--aub-text-sm, 0.875rem);
  color: var(--aub-fg-muted);
}
.aub-profile-stats strong {
  color: var(--aub-fg);
}
