/* Variables pour les thèmes - Couleurs Deezer */
:root {
    --bg-primary: #121216;
    --bg-secondary: #18181D;
    --text-primary: #FFFFFF;
    --text-secondary: #D1D5DB;
    --accent-primary: #EF5466;
    --accent-secondary: #FF6B7A;
    --border-color: rgba(239, 84, 102, 0.3);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --user-message-bg: #EF5466;
    --user-message-text: #FFFFFF; /* Texte blanc pour les messages utilisateur */
    --bot-message-bg: #2D2D35;
    --bot-message-text: #FFFFFF; /* Texte clair pour les messages du bot */
  }

  /* Styles généraux */
  body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
  }

  .font-poppins {
    font-family: 'Poppins', sans-serif;
  }

  /* En-tête */
  header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
  }

  /* Zone de chat */
  #chat-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px var(--shadow-color);
  }

  /* Messages */
  .user-message {
    background-color: var(--user-message-bg);
    color: var(--user-message-text); /* Texte blanc pour meilleure lisibilité */
    border-radius: 1rem 1rem 0 1rem;
    padding: 0.75rem 1rem;
    max-width: 80%;
    margin-left: auto;
    box-shadow: 0 4px 6px var(--shadow-color);
    word-break: break-word;
    font-weight: 500; /* Texte légèrement plus gras */
  }

  .bot-message {
    background-color: var(--bot-message-bg);
    color: var(--bot-message-text); /* Texte clair pour meilleure lisibilité */
    border-radius: 1rem 1rem 1rem 0;
    padding: 0.75rem 1rem;
    max-width: 80%;
    box-shadow: 0 4px 6px var(--shadow-color);
    word-break: break-word;
  }

  .system-message {
    background-color: rgba(59, 130, 246, 0.7); /* Bleu semi-transparent */
    color: white;
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    max-width: 80%;
    margin: 0 auto;
    box-shadow: 0 4px 6px var(--shadow-color);
    word-break: break-word;
    text-align: center;
    font-style: italic;
  }

  /* Animation d'apparition des messages */
  .message-appear {
    animation: fadeIn 0.3s ease-in-out;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Sélecteur de langue moderne */
  .language-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(18, 18, 22, 0.9), rgba(45, 45, 53, 0.9));
    padding: 0.5rem;
    border-radius: 2rem;
    border: 2px solid rgba(239, 84, 102, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
  }

  .lang-btn {
    position: relative;
    background: transparent;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 1.5rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
  }

  .lang-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(239, 84, 102, 0.1), rgba(255, 107, 122, 0.1));
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: 1.5rem;
  }

  .lang-btn:hover::before {
    opacity: 1;
  }

  .lang-btn .flag {
    width: 28px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    filter: grayscale(50%) brightness(0.8);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }

  .lang-btn .flag svg {
    width: 100%;
    height: 100%;
    display: block;
  }

  .lang-btn:hover .flag {
    transform: scale(1.2) rotate(5deg);
    filter: grayscale(0%) brightness(1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  }

  .lang-btn .lang-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
    letter-spacing: 0.05em;
  }

  .lang-btn:hover .lang-code {
    color: rgba(255, 255, 255, 0.9);
  }

  .lang-btn.active {
    border-color: rgba(239, 84, 102, 0.8);
    background: linear-gradient(135deg, rgba(239, 84, 102, 0.2), rgba(255, 107, 122, 0.2));
    box-shadow: 0 0 20px rgba(239, 84, 102, 0.4), inset 0 0 10px rgba(239, 84, 102, 0.1);
    transform: scale(1.05);
  }

  .lang-btn.active .flag {
    filter: grayscale(0%) brightness(1.1);
    transform: scale(1.1);
    animation: flag-bounce 0.6s ease;
    box-shadow: 0 4px 12px rgba(239, 84, 102, 0.4);
  }

  .lang-btn.active .lang-code {
    color: #EF5466;
    font-weight: 700;
  }

  @keyframes flag-bounce {
    0%, 100% { transform: scale(1.1) translateY(0); }
    50% { transform: scale(1.2) translateY(-3px); }
  }

  /* Animation au survol */
  .lang-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 84, 102, 0.3);
  }

  .lang-btn:active {
    transform: translateY(0);
  }

  /* Formulaire de saisie */
  #chat-form {
    margin-top: auto;
  }

  #message-input {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: none;
    outline: none;
  }

  #message-input::placeholder {
    color: var(--text-secondary);
  }

  /* Indicateur de chargement */
  .typing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .typing-indicator span {
    height: 8px;
    width: 8px;
    margin: 0 2px;
    background-color: var(--accent-primary);
    display: block;
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1s infinite;
  }

  .typing-indicator span:nth-child(1) {
    animation-delay: 0s;
  }

  .typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
  }

  .typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
  }

  @keyframes typing {
    0% {
      opacity: 0.4;
      transform: scale(1);
    }
    50% {
      opacity: 1;
      transform: scale(1.2);
    }
    100% {
      opacity: 0.4;
      transform: scale(1);
    }
  }

  /* Boutons */
  .image-button {
    background-color: transparent;
    border: none;
    color: var(--accent-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.3s;
  }

  .image-button:hover {
    color: var(--accent-secondary);
  }

  /* Formatage du texte dans les messages */
  .bot-message pre {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 0.25rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-family: monospace;
    color: #E5E7EB; /* Couleur claire pour le code */
  }

  .bot-message code {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    font-family: monospace;
    color: #E5E7EB; /* Couleur claire pour le code */
  }

  /* Images générées */
  .image-container {
    margin-top: 1rem;
    text-align: center;
  }

  .generated-image {
    max-width: 100%;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px var(--shadow-color);
  }

  /* Animation de chargement pour les images */
  .image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
  }

  .image-loading-text {
    margin-top: 1rem;
    color: var(--text-secondary);
  }

  /* Responsive */
  @media (max-width: 640px) {
    .user-message, .bot-message {
      max-width: 90%;
    }
  }
  .bot-message {
    color: #FFFFFF !important; /* Texte blanc pour les messages du bot */
  }

  /* Styles pour le bouton de copie */
  .copy-container {
    position: relative;
    background-color: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
  }

  .copy-content {
    margin-bottom: 0.5rem;
  }

  .copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(139, 92, 246, 0.7);
    color: white;
    border: none;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s;
  }

  .copy-button:hover {
    background-color: rgba(139, 92, 246, 1);
  }

  .copy-button.copied {
    background-color: #10B981; /* Vert pour indiquer le succès */
  }

  /* Style pour le lien du producteur */
  .producer-link {
    color: #8B5CF6;
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s;
  }

  .producer-link:hover {
    color: #7C3AED;
    text-decoration: underline;
  }

  /* Style pour le bouton de copie de la réponse complète */
  .full-copy-container {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 1; /* Toujours visible */
    z-index: 10;
  }

  .full-copy-button {
    background-color: transparent;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
  }

  .full-copy-button:hover {
    background-color: rgba(139, 92, 246, 1);
  }

  /* Style pour la notification de copie */
  .copy-notification {
    position: absolute;
    top: 0.5rem;
    right: 2.5rem;
    background-color: rgba(16, 185, 129, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    animation: fadeInOut 2s ease;
    white-space: nowrap;
    z-index: 20;
  }

  @keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
  }

  .full-copy-button i {
    font-size: 1rem;
  }

  /* Styles pour le sélecteur de style en accordéon */
  .style-selector {
    margin-top: 1rem;
  }

  .accordion {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
  }

  .accordion-item {
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
  }

  .accordion-item:hover {
    box-shadow: 0 4px 8px rgba(239, 84, 102, 0.2);
  }

  .accordion-header {
    padding: 0.75rem 1rem;
    background-color: rgba(45, 45, 53, 0.7);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
  }

  .accordion-header:hover {
    background-color: rgba(45, 45, 53, 0.9);
  }

  .accordion-content {
    padding: 1rem;
    background-color: rgba(24, 24, 29, 0.7);
    border-top: 1px solid var(--border-color);
  }

  .select-style-btn {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
  }

  .select-style-btn:hover {
    background-color: var(--accent-secondary);
  }

  .select-style-btn i {
    margin-right: 0.5rem;
  }

  /* Animation pour l'ouverture/fermeture de l'accordéon */
  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .accordion-content:not(.hidden) {
    animation: slideDown 0.3s ease-out;
  }

  /* Styles pour le lecteur de musique */
  .music-player-container {
    background-color: rgba(45, 45, 53, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
  }

  .music-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
  }

  .spinner-container {
    margin-bottom: 1rem;
  }

  .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(239, 84, 102, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s linear infinite;
  }

  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  .music-ready {
    display: flex;
    flex-direction: column;
  }

  .music-ready audio {
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    background-color: rgba(0, 0, 0, 0.2);
  }

  .music-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
  }

  .music-error {
    text-align: center;
    padding: 1rem;
    color: #FCA5A5;
  }

  /* Bouton de génération de musique */
  .music-button-container {
    margin-top: 1rem;
    text-align: center;
  }

  .generate-music-button {
    background-color: #8B5CF6;
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
  }

  .generate-music-button:hover {
    background-color: #7C3AED;
  }

  .generate-music-button i {
    margin-right: 0.5rem;
  }

  .download-music-button, .share-music-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
  }

  .download-music-button i, .share-music-button i {
    margin-right: 0.5rem;
  }

  .retry-music-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.5rem;
    transition: background-color 0.3s ease;
  }

  .retry-music-button i {
    margin-right: 0.5rem;
  }