/* === LOADER INITIAL === */

.loader-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--bg-primary);
  z-index: 9999;
  transition: opacity var(--transition-slow);
}

.loader-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-logo {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
}

/* === STRUCTURE PRINCIPALE === */

#app-view {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* === SIDEBAR (desktop) === */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition), box-shadow var(--transition);
}

.sidebar-header {
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background: var(--accent-subtle);
  color: var(--accent-light);
}

.nav-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* Bouton toggle thème dans la sidebar */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  width: 100%;
  text-align: left;
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Affiche la bonne icône selon le thème courant */
[data-theme='dark']  .theme-icon-dark  { display: none; }
[data-theme='light'] .theme-icon-light { display: none; }

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.profile-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-name {
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: left;
  transition: color var(--transition-fast);
}

.logout-btn:hover {
  color: var(--error);
}

/* Overlay pour fermer la sidebar sur mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* === MAIN WRAPPER === */

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* === HEADER (visible sur mobile, discret sur desktop) === */

.app-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.header-menu-btn {
  color: var(--text-secondary);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
  min-width: 44px;
  min-height: 44px;
}

.header-menu-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.header-title {
  font-size: var(--text-lg);
  font-weight: 700;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* === PAGES MODULES === */

.app-main {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
}

.module-page {
  display: none;
  animation: fadeIn var(--transition) ease;
}

.module-page.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
  font-weight: 400;
}

.coming-soon-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  max-width: 480px;
  margin: var(--space-8) auto 0;
  box-shadow: var(--shadow-sm);
}

.coming-soon-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: var(--space-5);
}

.coming-soon-card h2 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
}

.coming-soon-card p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.8;
}

/* === BOTTOM NAV (mobile) === */

.bottom-nav {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-1);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  flex: 1;
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* === AVATAR === */

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: white;
  font-size: var(--text-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: var(--text-xs);
}

/* === RESPONSIVE MOBILE === */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-wrapper {
    margin-left: 0;
    padding-bottom: var(--bottom-nav-height);
  }

  .header-menu-btn {
    display: flex;
  }

  .bottom-nav {
    display: flex;
  }

  .app-main {
    padding: var(--space-4);
  }

  .page-header h1 {
    font-size: var(--text-2xl);
  }

  .coming-soon-card {
    padding: var(--space-8) var(--space-5);
  }
}
