/**
 * Style.css - Layout de Base
 * ===========================
 * Structure principale de l'application EAA-IA-Chat
 * Layout Sidebar + Main Content avec Flexbox
 */

/* ===========================================
   1. BASE STYLES
   Configuration globale du document
   =========================================== */

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  display: flex;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* ===========================================
   2. LAYOUT PRINCIPAL
   Structure Sidebar + Main
   =========================================== */

/* Sidebar - Navigation latérale fixe */
.sidebar {
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: var(--z-fixed);
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: calc(100vh - var(--space-8));
  background-color: var(--sidebar-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
}

/* Logo et branding */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.sidebar-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--sidebar-text);
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: var(--space-4);
}

.nav-section-title {
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  color: var(--sidebar-text-muted);
  text-decoration: none;
  transition: var(--transition-fast);
}

.nav-item:hover {
  color: var(--sidebar-text);
  background-color: var(--sidebar-item-hover);
}

.nav-item.active {
  color: var(--sidebar-text);
  background-color: var(--sidebar-item-active);
  border-right: 3px solid var(--color-primary);
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.nav-item:hover .nav-item-icon,
.nav-item.active .nav-item-icon {
  opacity: 1;
}

/* Footer sidebar */
.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--sidebar-border);
}

/* Icônes et boutons sidebar (style clair sur fond sombre) */
.sidebar .btn-ghost,
.sidebar .btn-icon {
  color: var(--sidebar-text-muted);
}

.sidebar .btn-ghost:hover,
.sidebar .btn-icon:hover {
  color: var(--sidebar-text);
  background-color: var(--sidebar-item-hover);
}

.sidebar .theme-toggle {
  color: var(--sidebar-text-muted);
}

.sidebar .theme-toggle:hover {
  color: var(--sidebar-text);
}

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

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  color: var(--sidebar-text);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--sidebar-text-muted);
}

/* ===========================================
   3. MAIN CONTENT
   Zone de contenu principale
   =========================================== */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: calc(var(--sidebar-width) + var(--space-8));
  margin-top: var(--space-4);
  margin-right: var(--space-4);
  margin-bottom: var(--space-4);
  height: calc(100vh - var(--space-8));
  padding: 0;
  background-color: var(--color-surface);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

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

/* Header de page */
.page-header {
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.page-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
}

/* ===========================================
   4. GRID SYSTEM
   Grilles flexibles pour layouts
   =========================================== */

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Responsive grid */
@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 { grid-template-columns: 1fr; }
}

/* ===========================================
   5. FLEXBOX UTILITIES
   Classes utilitaires flex
   =========================================== */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ===========================================
   6. SPACING UTILITIES
   Marges et paddings
   =========================================== */

/* Margins */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* Paddings */
.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

/* ===========================================
   7. TEXT UTILITIES
   Styles de texte
   =========================================== */

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }

.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-muted { color: var(--color-text-muted); }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===========================================
   8. VISIBILITY UTILITIES
   Affichage et masquage
   =========================================== */

.hidden { display: none !important; }
.invisible { visibility: hidden; }
.visible { visibility: visible; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===========================================
   9. RESPONSIVE
   Adaptations mobiles
   =========================================== */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-base);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
    padding: var(--space-3);
  }

  /* Bouton menu mobile */
  .mobile-menu-toggle {
    display: flex;
    position: fixed;
    top: var(--space-4);
    left: var(--space-4);
    z-index: var(--z-fixed);
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .main-content {
    padding: var(--space-4);
    padding-top: calc(var(--space-4) + 60px); /* Espace pour le bouton menu */
  }
}

@media (min-width: 769px) {
  .mobile-menu-toggle {
    display: none;
  }
}

/* ===========================================
   10. SCROLLBAR CUSTOM
   Barre de défilement stylisée
   =========================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-hover);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-hover) var(--color-bg);
}

/* ===========================================
   11. SIDEBAR FOOTER SIMPLIFIÉ - Style ChatGPT
   =========================================== */

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer .sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-footer .sidebar-user-avatar {
  width: 32px;
  height: 32px;
  font-size: var(--text-sm);
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
}

.sidebar-footer .sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--sidebar-text);
}

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

.sidebar-actions .btn-icon {
  width: 32px;
  height: 32px;
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-actions .btn-icon:hover {
  color: rgba(255, 255, 255, 0.95);
  background-color: var(--sidebar-item-hover);
}
