/* ==========================================================================
   AUTYAMI - Layout & Responsive Architecture (Cosy, Mobile First & Strict Bounds)
   ========================================================================== */

/* Reset Global & Anti-Bugs */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

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

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

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-space);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Fond Ambiance Cosy */
.app-atmosphere {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  background: 
    radial-gradient(circle at 15% 20%, rgba(245, 158, 11, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 85% 80%, rgba(116, 156, 117, 0.09) 0%, transparent 45%),
    linear-gradient(180deg, var(--bg-space) 0%, var(--bg-primary) 100%);
}

#stars-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.85;
}

.app-root {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* ==========================================================================
   Header Bar (Bulle Supérieure)
   ========================================================================== */
.main-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.brand-icon-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  overflow: hidden;
  box-shadow: var(--shadow-glow);
  border: 2px solid var(--wood-warm);
  transition: transform var(--transition-fast);
}

.brand-icon-wrapper:hover {
  transform: scale(1.06) rotate(3deg);
}

.brand-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, var(--warm-beige) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--warm-beige);
  font-weight: 400;
  letter-spacing: 0.3px;
  opacity: 0.9;
}

/* Recherche Douce */
.search-container {
  flex: 1;
  max-width: 420px;
  margin: 0 1.5rem;
  position: relative;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-full);
  padding: 0.45rem 1rem;
  transition: var(--transition-fast);
}

.search-input-wrapper:focus-within {
  border-color: var(--wood-warm);
  box-shadow: 0 0 14px var(--amber-glow);
}

.search-icon {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-right: 0.6rem;
}

.search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* Contrôles Header */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.sensory-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
}

.sensory-pill-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--wood-warm);
  transform: translateY(-1px);
}

.social-battery-indicator {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.battery-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  flex-shrink: 0;
}

.battery-dot.level-green { background: #10b981; box-shadow: 0 0 8px #10b981; }
.battery-dot.level-yellow { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.battery-dot.level-red { background: #f43f5e; box-shadow: 0 0 8px #f43f5e; }
.battery-dot.level-purple { background: #a855f7; box-shadow: 0 0 8px #a855f7; }

.user-menu-btn {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.user-avatar-header {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--wood-warm);
}

/* ==========================================================================
   Layout Principal 3 Colonnes
   ========================================================================== */
.main-container {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 340px;
  gap: 1.5rem;
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem 1.25rem;
  width: 100%;
  min-width: 0;
}

/* Mode Salon Sensoriel Pleine Largeur */
.main-container.full-sanctuary-mode {
  grid-template-columns: 260px minmax(0, 1fr);
}

.main-container.full-sanctuary-mode .sidebar-right {
  display: none;
}

.sidebar-left {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  min-width: 0;
}

.nav-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-sm);
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  transform: translateX(3px);
}

.nav-link.active {
  color: var(--oat-cream);
  background: rgba(171, 122, 78, 0.25);
  border-left: 3px solid var(--wood-warm);
  font-weight: 600;
}

.nav-icon {
  font-size: 1.25rem;
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.content-center {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.sidebar-right {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  min-width: 0;
}

/* ==========================================================================
   Dock Mobile Cosy (Barre de Navigation Basse sur Smartphone)
   ========================================================================== */
.mobile-bottom-dock {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  background: rgba(26, 20, 15, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-soft);
  padding: 0.4rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom, 12px)) 0.5rem;
  z-index: 990;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.7);
  box-sizing: border-box;
  touch-action: manipulation;
}

.mobile-dock-list {
  display: flex;
  justify-content: space-around;
  align-items: center;
  list-style: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

.mobile-dock-list li {
  flex: 1;
  display: flex;
  justify-content: center;
}

.mobile-dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  width: 100%;
}

.mobile-dock-btn span.dock-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.mobile-dock-btn span.dock-label {
  font-size: 0.72rem;
  line-height: 1;
}

.mobile-dock-btn:hover,
.mobile-dock-btn.active {
  color: var(--warm-beige) !important;
  background: rgba(171, 122, 78, 0.2) !important;
}

.mobile-dock-btn.active span.dock-icon {
  transform: scale(1.15);
}

/* Responsive Media Queries Fluides & Anti-Déformation */
@media (max-width: 1320px) {
  .main-container {
    grid-template-columns: 240px minmax(0, 1fr) !important;
    gap: 1.15rem;
    padding: 1.25rem 1rem 4rem 1rem;
  }
  .sidebar-right {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 100% !important;
    padding: 0.85rem 0.65rem calc(7.5rem + env(safe-area-inset-bottom, 25px)) 0.65rem !important;
    gap: 1.15rem;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .content-center {
    overflow: visible !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  .view-panel {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    padding-bottom: 2.5rem;
  }
  .sidebar-left, .sidebar-right {
    display: none !important;
  }
  .mobile-bottom-dock {
    display: block !important;
  }
}

@media (max-width: 640px) {
  .search-container {
    display: none;
  }
  .main-header {
    padding: 0.5rem 0.65rem;
    gap: 0.35rem;
  }
  .brand-section {
    gap: 0.45rem;
  }
  .brand-icon-wrapper {
    width: 34px;
    height: 34px;
  }
  .brand-title {
    font-size: 1.18rem;
  }
  .brand-subtitle {
    display: none;
  }
  .header-actions {
    gap: 0.25rem;
  }
  .header-actions .sensory-pill-btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
    gap: 0.2rem;
    min-height: 36px;
    touch-action: manipulation;
  }
  #btn-header-theme span,
  #header-battery-text,
  #header-notif-label,
  #btn-header-logout span {
    display: none !important;
  }
  .user-avatar-header {
    width: 32px;
    height: 32px;
  }
  .btn-publish,
  .sensory-pill-btn,
  .reaction-btn,
  .comment-toggle-btn,
  .friend-action-btn {
    touch-action: manipulation;
  }
}
