/* =========================
   VARIABLES & GLOBAL
   ========================= */
:root {
  --primary: #3b82f6;
  --primary-light: #93c5fd;
  --primary-dark: #1d4ed8;
  --background: #f8fafc;
  --surface: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s ease-in-out;
}

html,
body {
  height: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-y: auto; /* ✅ on réactive le scroll vertical */
  overflow-x: hidden; /* on évite juste le scroll horizontal */
}

/* =========================
   LAYOUT GLOBAL
   ========================= */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  min-height: 100vh; /* ✅ au lieu de height: 100vh */
  display: flex;
  flex-direction: column;
}

/* =========================
   HEADER
   ========================= */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.gfp-logo {
  height: 40px;
  margin-right: 0.9rem;
  border-radius: 6px;
  object-fit: contain;
}

.logo-container h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.logo-container .subtitle {
  font-size: 1rem;
  font-weight: 500;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  display: inline-block;
}

.tagline {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 600px;
}

/* Boutons de langue */
.language-switcher {
  display: inline-flex;
  padding: 0.25rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
  min-width: 48px;
  text-align: center;
}

.lang-btn:hover {
  background: #f1f5f9;
}

.lang-btn.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* =========================
   MAIN : CHAT + SIDEBAR
   ========================= */
.main-content {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.9fr);
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* =========================
   CHAT CONTAINER
   ========================= */
.chat-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0.5rem 0.5rem 1rem 0;
}

/* Scrollbar personnalisée */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* =========================
   MESSAGES
   ========================= */
.message {
  max-width: 90%;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.6;
  position: relative;
  transition: var(--transition);
  animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-message {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  position: relative;
}

.ai-message::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 0;
  width: 8px;
  height: 16px;
  background: var(--primary);
  border-radius: 8px 0 0 8px;
}

.user-message {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: var(--radius-md) 0 var(--radius-md) var(--radius-md);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
  margin-left: auto;
}

.message-sender {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-message .message-sender {
  color: var(--primary);
}

.user-message .message-sender {
  color: rgba(255, 255, 255, 0.8);
}

.message-content {
  word-break: break-word;
}

.message-content p {
  margin-bottom: 0.5rem;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* =========================
   INDICATEUR DE FRAPPE
   ========================= */
.typing-indicator {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0.5rem 0 0.5rem 1rem;
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.typing-indicator.visible {
  display: flex;
}

.typing-dots {
  display: flex;
  gap: 0.25rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--primary-light);
  border-radius: 50%;
  animation: typingAnimation 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingAnimation {
  0%,
  80%,
  100% {
    transform: scale(0.6);
  }
  40% {
    transform: scale(1);
  }
}

/* =========================
   BARRE DE SAISIE
   ========================= */
.message-input-container {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.input-group {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  position: relative;
}

#user-input {
  flex: 1;
  resize: none;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  padding: 0.9rem 1rem;
  min-height: 3.25rem;
  max-height: 15rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  transition: var(--transition);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#user-input::-webkit-scrollbar {
  display: none;
}

#user-input::placeholder {
  color: #94a3b8;
}

#user-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  outline: none;
}

/* Boutons */
.button-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.btn {
  border-radius: var(--radius-md);
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn.secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: #e2e8f0;
}

.btn.primary {
  background: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn.primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.btn svg {
  width: 1.1em;
  height: 1.1em;
}

/* =========================
   SIDEBAR
   ========================= */
.sidebar {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.info-panel h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-panel h3::before {
  content: "";
  display: block;
  width: 6px;
  height: 1.5rem;
  background: var(--primary);
  border-radius: 3px;
}

.info-panel p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* Suggestions */
.suggestions h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.suggestions h4::before {
  content: "💡";
  font-size: 1.1em;
}

.suggestion-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.suggestion-item {
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.suggestion-item:hover {
  background: #f1f5f9;
  border-color: var(--primary-light);
  transform: translateX(4px);
}

/* Status */
.status-indicator {
  margin-top: auto;
  padding-top: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #15803d;
  border-top: 1px solid var(--border);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  position: relative;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* =========================
   MODE SOMBRE (auto)
   ========================= */
@media (prefers-color-scheme: dark) {
  :root {
    --background: #0f172a;
    --surface: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2),
      0 2px 4px -1px rgba(0, 0, 0, 0.1);
  }

  .ai-message {
    background: #1e293b;
    border-color: #334155;
  }

  .suggestion-item {
    background: #1e293b;
    border-color: #334155;
  }

  .suggestion-item:hover {
    background: #1e3a8a;
  }

  .btn.secondary {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
  }

  .btn.secondary:hover {
    background: #3b82f6;
    color: white;
  }

  #user-input {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
  }

  #user-input::placeholder {
    color: #64748b;
  }
}

/* =========================
   LOGIN SCREEN
   ========================= */
/* =============================
   PAGE DE CONNEXION
============================= */

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: linear-gradient(135deg, #0a0f1c, #162033);
}

.auth-card {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  padding: 2.5rem 3rem;
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 217, 255, 0.2);
  border: 1px solid rgba(0, 217, 255, 0.25);
  animation: fadeIn 0.7s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-header {
  text-align: center;
  margin-bottom: 1.4rem;
}

.auth-logo {
  width: 130px; /* Taille plus grande */
  height: auto;
  display: block;
  margin: 0 auto 15px; /* Centré + espace sous le logo */
  opacity: 0.95; /* Option : léger adoucissement */
}

.auth-title {
  font-size: 2rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.3rem;
  letter-spacing: 0.5px;
}

.auth-subtitle {
  font-size: 0.95rem;
  color: #8fc3ff;
  font-weight: 400;
}

/* FORMULAIRE */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-label {
  color: #d8e7f7;
  font-size: 0.9rem;
  font-weight: 500;
}

.auth-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  transition: all 0.25s ease;
}

.auth-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.auth-input:focus {
  outline: none;
  border-color: #00d9ff;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 8px rgba(0, 217, 255, 0.4);
}

/* BOUTON LOGIN */
.auth-button {
  width: 100%;
  padding: 0.85rem;
  margin-top: 0.5rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #00d9ff, #00a3cc);
  color: #101820;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.auth-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0, 217, 255, 0.4);
}

.auth-button:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ERREUR */
.auth-error {
  color: #ff7676;
  font-size: 0.9rem;
  text-align: center;
  margin-top: 0.5rem;
}

/* FOOTER */
.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: #b3c7da;
}

.auth-footnote {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* MOBILE */
@media (max-width: 480px) {
  .auth-card {
    padding: 2rem 1.5rem;
  }

  .auth-title {
    font-size: 1.6rem;
  }
}

.btn-logout {
  margin-left: 1rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: transparent;
  color: #e5e7eb;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-logout i {
  font-size: 0.9rem;
}

.btn-logout:hover {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(248, 113, 113, 0.8);
  color: #fecaca;
}

.hidden {
  display: none !important;
}
