/* Fichier : voicebook.css (Design Medassiste v3.0) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --vb-bg-color: #F4F7FF;
    --vb-panel-bg: #FFFFFF;
    --vb-primary-blue: #4A80FF;
    --vb-light-blue: #E9EFFF;
    --vb-text-dark: #1E293B;
    --vb-text-light: #64748B;
    --vb-border-color: #E2E8F0;
    --vb-completed-color: #22C55E; /* Vert pour 'completed' */
}

#voicebook-container {
    font-family: 'Inter', sans-serif;
    background-color: var(--vb-bg-color);
    padding: 24px;
    border-radius: 20px;
    max-width: 900px;
    margin: 2rem auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.07);
}

.voicebook-container-wrapper {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* --- Barre d'étapes --- */
.voicebook-steps-container {
    background: var(--vb-panel-bg);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--vb-border-color);
}
.voicebook-steps-container h2 {
    text-align: center;
    font-size: 18px;
    color: var(--vb-text-dark);
    margin-top: 0;
    margin-bottom: 24px;
}
.steps-timeline {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
}
.steps-timeline::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 5%;
    right: 5%;
    height: 2px;
    background-color: var(--vb-border-color);
    z-index: 1;
}
.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    position: relative;
    z-index: 2;
    background: var(--vb-panel-bg);
    padding: 0 10px;
    width: 16%;
}
.step-item p {
    margin: 0;
    font-size: 12px;
    color: var(--vb-text-light);
    font-weight: 500;
}
.step-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--vb-panel-bg);
    border: 2px solid var(--vb-border-color);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.step-icon.active {
    background-color: var(--vb-primary-blue);
    border-color: var(--vb-primary-blue);
    transform: scale(1.1);
}
.step-icon.active::before { /* Icône pour 'active' */
    content: '🎤';
    color: white;
    font-size: 18px;
}
.step-icon.completed {
    background-color: var(--vb-completed-color);
    border-color: var(--vb-completed-color);
}
.step-icon.completed::before { /* Icône pour 'completed' */
    content: '✔';
    color: white;
    font-size: 18px;
    font-weight: bold;
}


/* --- Barre de progression --- */
.voicebook-progress-container {
    background: var(--vb-panel-bg);
    padding: 16px 24px;
    border-radius: 16px;
    border: 1px solid var(--vb-border-color);
    display: flex;
    align-items: center;
    gap: 16px;
}
.voicebook-progress-container h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--vb-text-dark);
    flex-shrink: 0;
}
.progress-bar-wrapper {
    flex-grow: 1;
    height: 8px;
    background-color: var(--vb-light-blue);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    width: 0%;
    background-color: var(--vb-primary-blue);
    border-radius: 4px;
    transition: width 0.5s ease;
}
#voicebook-progress-percent {
    font-size: 14px;
    font-weight: 600;
    color: var(--vb-primary-blue);
    min-width: 40px;
    text-align: right;
}

/* --- Panneau Principal --- */
.voicebook-main-panel {
    background-color: var(--vb-primary-blue);
    border-radius: 16px;
    padding: 40px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}
.voicebook-wrapper {
    width: 100%;
}
.voicebook-wrapper .voicebook-state { display: none; }
.voicebook-wrapper.state-idle .voicebook-state#voicebook-idle-state,
.voicebook-wrapper.state-listening .voicebook-state#voicebook-listening-state,
.voicebook-wrapper.state-processing .voicebook-state#voicebook-processing-state,
.voicebook-wrapper.state-questioning .voicebook-state#voicebook-questioning-state,
.voicebook-wrapper.state-results .voicebook-state#voicebook-results-state,
.voicebook-wrapper.state-error .voicebook-state#voicebook-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.voicebook-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}
.voicebook-subtitle {
    font-size: 16px;
    opacity: 0.8;
    margin: 0;
}
.voicebook-mic-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background-color: var(--vb-panel-bg);
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.voicebook-mic-button::before {
    content: '🎤';
    font-size: 32px;
    color: var(--vb-primary-blue);
}
.voicebook-mic-button:hover {
    transform: scale(1.1);
}


/* --- Animation Loader --- */
.loader {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Panneau de résultats --- */
.voicebook-state#voicebook-results-state {
    background-color: transparent;
    color: white;
    width: 100%;
}
.voicebook-results-title {
    font-size: 18px;
    margin-bottom: 16px;
}
.voicebook-results-list {
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 16px;
}
.doctor-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.doctor-info h4, .doctor-info p { margin: 0; }
.doctor-info h4 { font-size: 16px; margin-bottom: 4px; }
.doctor-info p { font-size: 14px; opacity: 0.8; }
.consultation-code {
    width: 100%;
    box-sizing: border-box;
    background: rgba(0,0,0,0.1);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}
.no-results { color: white; opacity: 0.8; }
.contact-btn {
    background-color: white;
    color: var(--vb-primary-blue);
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}
.contact-btn:hover { background-color: var(--vb-light-blue); }
.voicebook-new-search, .voicebook-retry-btn {
    background-color: transparent;
    border: 1px solid white;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
}
.voicebook-new-search:hover, .voicebook-retry-btn:hover {
    background-color: white;
    color: var(--vb-primary-blue);
}

/* --- Panneau d'erreur --- */
.voicebook-state#voicebook-error-state .voicebook-title {
    color: #FFDDC4;
}
#voicebook-error-message {
    opacity: 0.9;
    font-size: 14px;
    max-width: 80%;
}
/* Styles pour améliorer l'affichage du texte en arabe */
.voicebook-wrapper.state-idle .voicebook-title {
    font-weight: bold;
    font-size: 30px;
}

.voicebook-wrapper.state-idle .voicebook-subtitle {
    font-size: 24px;
    opacity: 1.1;
}
/* Styles pour les vignettes carrées des médecins (importés de medecins-dynamic) */
.med-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin: 12px 0;
}

.med-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    text-align: left; /* Assure l'alignement à gauche */
}

.med-card h4 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
}

.med-card .meta {
    color: #374151;
    font-size: 13px;
    margin: 4px 0;
}

.med-card .meta span {
    display: inline-block;
    margin-right: 8px;
}

.med-card .field {
    font-size: 13px;
    color: #4b5563;
    margin: 8px 0; /* Un peu plus d'espace */
    display: flex; /* Pour un meilleur alignement de l'icône */
    align-items: center;
}

.med-card .field .icon {
    margin-right: 8px;
}

.med-card .field a {
    text-decoration: none;
    color: #1d4ed8;
}

/* * ===================================================================
 * === MODIFICATIONS POUR LES ICÔNES GIF ANIMÉES                     ===
 * ===================================================================
*/

/* --- 1. Remplacer l'icône par un GIF pendant la lecture audio (état "starting") --- */
.voicebook-mic-button.is-starting {
    background-color: transparent; 
    box-shadow: none; 
    background-image: url('../images/listening.gif');
    background-size: cover; 
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid var(--vb-border-color); 
    cursor: default;
}
.voicebook-mic-button.is-starting::before {
    content: ''; 
}

/* --- 2. Remplacer l'icône par un GIF pendant l'enregistrement (état "listening") --- */
.voicebook-mic-button.is-recording {
    background-color: transparent; /* On enlève la couleur rouge de fond */
    box-shadow: 0 0 0 4px rgba(229, 62, 62, 0.4); /* On garde l'animation de "glow" rouge */
    background-image: url('../images/oreille.gif');
    background-size: contain; /* On utilise "contain" pour que l'oreille soit entièrement visible */
    background-position: center;
    background-repeat: no-repeat;
}
.voicebook-wrapper.state-listening .voicebook-mic-button::before {
    content: ''; /* On vide le contenu "■" du pseudo-élément */
}
/* ===================================================================
 * ======================= FIN DES MODIFICATIONS =====================
 * ===================================================================
*/


/*
 * Règles de visibilité pour les différents états de l'interface.
*/
.voicebook-state {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.voicebook-wrapper.state-idle #voicebook-idle-state,
.voicebook-wrapper.state-listening #voicebook-listening-state,
.voicebook-wrapper.state-processing #voicebook-processing-state,
.voicebook-wrapper.state-results #voicebook-results-state,
.voicebook-wrapper.state-error #voicebook-error-state {
    display: flex;
}

.voicebook-wrapper.state-starting #voicebook-starting-state {
    display: flex;
}
/* NOUVEAU DESIGN POUR LES CARTES MÉDECINS */

.med-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.med-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden; 
    display: flex;
    flex-direction: column;
    border-top: 4px solid #4f46e5; 
}

/* --- En-tête de la carte --- */
.card-header {
    display: flex;
    align-items: center;
    padding: 16px;
    background: #f9fafb; 
}

.doctor-avatar {
    font-size: 24px;
    background: #e0e7ff;
    color: #4f46e5;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.doctor-title h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

.doctor-title p {
    margin: 2px 0 0;
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* --- Corps de la carte --- */
.card-body {
    padding: 16px;
    flex-grow: 1; 
}

.card-body .field {
    font-size: 14px;
    color: #374151;
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
}

.card-body .field .icon {
    margin-right: 10px;
    margin-top: 2px;
    color: #4f46e5;
}

.card-body .field a {
    text-decoration: none;
    color: #1d4ed8;
    font-weight: 500;
}

/* --- Pied de page de la carte --- */
.card-footer {
    padding: 16px;
    background: #f9fafb;
    border-top: 1px solid #f3f4f6;
}

.call-button {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: #4f46e5;
    color: #ffffff;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s;
}

.call-button:hover {
    background-color: #4338ca;
}
/* NOUVEAU STYLE POUR LE FORMULAIRE DE RECHERCHE MANUELLE */

.manual-search-container {
    display: flex;
    gap: 12px;
    margin: 24px 0;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

/* Le conteneur pour chaque liste déroulante */
.select-wrapper {
    position: relative;
    display: inline-block;
}

/* La flèche personnalisée pour les listes */
.select-wrapper::after {
    content: '▼';
    font-size: 12px;
    color: #9ca3af;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none; 
}

/* Style de base pour les listes et le bouton */
.manual-search-container select,
.manual-search-container .voicebook-new-search {
    padding: 12px 36px 12px 16px; 
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 16px;
    background-color: #f9fafb;
    min-width: 200px;
    cursor: pointer;
}

/* On cache l'apparence par défaut de la liste */
.manual-search-container select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Style spécifique pour le bouton "Rechercher" */
.manual-search-container #manual-search-btn {
    padding: 12px 24px;
    background-color: #3b82f6; 
    border-color: #3b82f6;
    color: white;
    font-weight: 600;
    transition: background-color 0.2s;
}

.manual-search-container #manual-search-btn:hover {
    background-color: #2563eb;
}
/* NOUVEAU STYLE POUR LE FORMULAIRE DE RECHERCHE MANUELLE */

.manual-search-container {
    display: flex;
    gap: 12px;
    margin: 24px 0;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

/* Le conteneur pour chaque liste déroulante */
.select-wrapper {
    position: relative;
    display: inline-block;
}

/* La flèche personnalisée pour les listes */
.select-wrapper::after {
    content: '▼';
    font-size: 12px;
    color: #9ca3af;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Style de base pour les listes et le bouton */
.manual-search-container select,
.manual-search-container .voicebook-new-search {
    padding: 12px 36px 12px 16px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 16px;
    background-color: #f9fafb;
    min-width: 200px;
    cursor: pointer;
    color: #374151; 
}

/* On cache l'apparence par défaut de la liste */
.manual-search-container select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Style spécifique pour le bouton "Rechercher" */
.manual-search-container #manual-search-btn {
    padding: 12px 24px;
    background-color: #3b82f6; 
    border-color: #3b82f6;
    color: white;
    font-weight: 600;
    transition: background-color 0.2s;
}

.manual-search-container #manual-search-btn:hover {
    background-color: #2563eb;
}
/* --- NOUVEAU : Style pour le carrousel de médecins --- */

.doctors-scroller {
    position: relative;
    width: 100%;
    padding: 0 40px; 
    box-sizing: border-box;
}

.doctors-scroll-content {
    display: flex; 
    overflow-x: auto; 
    scroll-behavior: smooth; 
    gap: 20px;
    padding: 10px 0;
    scrollbar-width: none; 
    -ms-overflow-style: none;  
}

.doctors-scroll-content::-webkit-scrollbar {
    display: none; 
}

#voicebook-doctors-list.med-card-grid {
    display: flex; 
    flex-wrap: nowrap; 
    grid-template-columns: none; 
    gap: 20px;
}

.med-card-grid .med-card {
    flex: 0 0 290px; 
    width: 290px;
}

/* Style pour les boutons de navigation */
.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background-color: white;
    color: var(--vb-primary-blue);
    border: 1px solid var(--vb-border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-btn:hover {
    background-color: var(--vb-light-blue);
    transform: translateY(-50%) scale(1.1);
}

.scroll-btn.left {
    left: -40px;
}

.scroll-btn.right {
    right: -40px;
}

.scroll-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translateY(-50%) scale(1);
}
/* =========================
   MOBILE FIX (<= 480px)
   ========================= */
@media (max-width: 480px) {
  /* Conteneurs & typographies */
  #voicebook-container { padding: 12px; margin: .75rem auto; border-radius: 12px; }
  .voicebook-main-panel { padding: 18px; min-height: unset; border-radius: 12px; }
  .voicebook-title { font-size: 20px; }
  .voicebook-subtitle { font-size: 14px; }
  .voicebook-results-title { font-size: 16px; margin-bottom: 10px; }

  /* Barre d'étapes & progression : moins volumineux */
  .voicebook-steps-container { padding: 14px; }
  .steps-timeline::before { left: 8%; right: 8%; top: 16px; }
  .step-item { width: auto; padding: 0 4px; }
  .step-icon { width: 28px; height: 28px; }
  .voicebook-progress-container { padding: 10px 12px; gap: 10px; }

  /* Liste résultats plus haute, scrollable */
  .voicebook-results-list { max-height: 62vh; padding-right: 6px; }

  /* Carrousel médecins : 100% swipe, pas de recouvrement */
  .doctors-scroller { padding: 0 12px; }
  .doctors-scroll-content {
    gap: 14px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;   
    touch-action: pan-x;
  }

  #voicebook-doctors-list.med-card-grid { gap: 14px; }
  .med-card-grid .med-card {
    flex: 0 0 calc(100vw - 56px);   
    width: calc(100vw - 56px);
    scroll-snap-align: start;
  }
  .scroll-btn { display: none; }

  /* Formulaire manuel : colonnes -> pile verticale pleine largeur */
  .manual-search-container {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 16px 0;
  }
  .manual-search-container select,
  .manual-search-container .voicebook-new-search,
  .manual-search-container #manual-search-btn {
    min-width: 0;
    width: 100%;
    font-size: 15px;
    padding: 12px 36px 12px 12px;
  }
}
@media (max-width: 480px) {
  .doctors-scroller::before,
  .doctors-scroller::after {
    content: "";
    position: absolute; top: 0; width: 18px; height: 100%;
    pointer-events: none;
  }
  .doctors-scroller::before { left: 0; background: linear-gradient(90deg, rgba(74,128,255,.25), transparent); }
  .doctors-scroller::after  { right: 0; background: linear-gradient(270deg, rgba(74,128,255,.25), transparent); }
}
/* === Flèches du carrousel visibles et en bas (mobile) === */
@media (max-width: 480px) {
  .doctors-scroller {
    position: relative;
    padding: 0 12px 56px; 
  }

  .scroll-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: absolute;
    bottom: 8px;      
    top: auto;
    transform: none;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
    z-index: 5;
  }
  .scroll-btn.left  { left: 12px;  }
  .scroll-btn.right { right: 12px; }

  .med-card-grid .med-card {
    flex: 0 0 calc(100vw - 56px);
    width: calc(100vw - 56px);
    scroll-snap-align: start;
  }
  .doctors-scroll-content {
    gap: 14px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
}
/* === Aligner parfaitement les 2 flèches en bas (mobile) === */
@media (max-width: 480px) {
  .doctors-scroller {
    position: relative;
    padding-bottom: 64px; 
  }

  .doctors-scroller .scroll-btn {
    position: absolute !important;
    bottom: 12px !important;
    top: auto !important;
    transform: none !important;
    width: 44px;
    height: 44px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: 1.5px solid #e3e7ff;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1;
    font-size: 18px;
    z-index: 10;
  }
  .doctors-scroller .scroll-btn.left  { left: 12px;  }
  .doctors-scroller .scroll-btn.right { right: 12px; }

  .doctors-scroller .scroll-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(43,108,255,.25); }
  .doctors-scroller .scroll-btn[disabled] { opacity: .4; pointer-events: none; }

  .doctors-scroller .scroll-btn i,
  .doctors-scroller .scroll-btn svg {
    line-height: 1;
    font-size: 18px;
    pointer-events: none;
  }
}