/* ============================================================
   🎨 EduquIA – Annuaire IA de ressources
   ============================================================ */

/* =============== */
/* Thème & global  */
/* =============== */
.eduqia-dir {
  --c1: #2831DC;
  --c2: #09A9F8;
  --bd: #e6ecff;
  --txt: #333;
  --muted: #6b7280;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color: var(--txt);
}
.eduqia-dir * { box-sizing: border-box; }

.eduqia-dir-title {
  font-size: 22px;
  margin: 0 0 16px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
}

/* ========================= */
/* Formulaire principal      */
/* ========================= */
.eduqia-dir form#eduqia-dir-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 20px auto;
  max-width: 500px;
  text-align: center;
}

.eduqia-dir .form-group {
  width: 100%;
  max-width: 400px;
  margin: 10px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.form-group-hidden { display: none !important; }

.eduqia-dir .styled-select,
.eduqia-dir input[type="text"],
.eduqia-dir .mwai-form-submit {
  width: 100%;
  max-width: 400px;
  padding: 13px;
  border-radius: 12px;
  font-size: 16px;
  text-align: center;
}

.eduqia-dir .styled-select,
.eduqia-dir input[type="text"] {
  background: #f8f8f8;
  border: 1px solid #ccc;
}

.eduqia-dir .styled-select:focus,
.eduqia-dir input[type="text"]:focus {
  outline: none;
  border-color: var(--c1);
  box-shadow: 0 0 0 3px rgba(40,49,220,.12);
}

.eduqia-dir .mwai-form-submit {
  background: linear-gradient(45deg, var(--c1), var(--c2));
  color: #fff;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform .2s, opacity .2s;
}
.eduqia-dir .mwai-form-submit:hover { transform: scale(1.05); }
.eduqia-dir .mwai-form-submit:disabled {
  opacity: .6;
  cursor: not-allowed;
  filter: grayscale(.2);
}

/* ========================= */
/* Sélecteur de mode         */
/* ========================= */
.eduqia-dir .mode-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 12px auto 18px;
  max-width: 420px;
}

/* Style de base harmonisé avec les boutons IA */
.eduqia-dir .mode-btn {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  cursor: pointer;
  border: none;
  background: linear-gradient(90deg, #2831DC, #09A9F8);
  color: #fff;
  transition: all 0.25s ease;
  box-shadow: 0 2px 6px rgba(40, 49, 220, 0.2);
}

/* Survol et clic */
.eduqia-dir .mode-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 10px rgba(40, 49, 220, 0.25);
  opacity: 0.95;
}

.eduqia-dir .mode-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 4px rgba(40, 49, 220, 0.2);
}

/* Bouton actif */
.eduqia-dir .mode-btn.active {
  background: #fff;
  color: #2831DC;
  border: 2px solid #2831DC;
  box-shadow: 0 0 0 3px rgba(40,49,220,.12);
}

/* Texte explicatif */
.eduqia-dir .mode-explainer {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
  max-width: 420px;
}

/* ✅ Bouton "Recherche approfondie" – Premium */
.eduqia-dir .mode-btn[data-mode="deep"] {
  cursor: pointer !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Supprime le halo blanc / focus */
.eduqia-dir .mode-btn:focus,
.eduqia-dir .mode-btn:active {
  outline: none !important;
  box-shadow: none !important;
}

/* Bouton verrouillé (non-premium) */
.eduqia-dir .mode-btn.locked {
  cursor: not-allowed !important;
  opacity: 0.5 !important;
  pointer-events: none !important;
  filter: grayscale(0.2);
}


/* ============== */
/* Loader global  */
/* ============== */

.custom-loader span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--c1), var(--c2));
  animation: bounce 1.5s infinite ease-in-out;
}
.custom-loader span:nth-child(2) { animation-delay: .2s; }
.custom-loader span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 1; }
  40% { transform: translateY(-10px); opacity: .9; }
}

/* ================= */
/* Grille résultats  */
/* ================= */
#eduqia-dir-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 10px;
}
@media (max-width: 900px) {
  #eduqia-dir-results { grid-template-columns: 1fr; }
}

.eduqia-card {
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transition: transform .2s, box-shadow .2s;
}
.eduqia-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

.eduqia-card .card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.eduqia-card .fav { width: 20px; height: 20px; border-radius: 4px; }
.eduqia-card .title {
  font-weight: 800;
  color: var(--c1);
  text-decoration: none;
}
.eduqia-card .title:hover { text-decoration: underline; }
.eduqia-card .host {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
}
.eduqia-card .snippet {
  color: #444;
  font-size: 14px;
  margin: 8px 0 10px;
  line-height: 1.5;
}

/* =============================== */
/* Boutons IA (résumé/séance/...)  */
/* =============================== */
.eduqia-card .ai {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.eduqia-card .ai-btn {
  flex: 1 1 calc(50% - 8px);
  text-align: center;
  padding: 8px 10px;
  border: 1px solid var(--c1);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  color: var(--c1);
  transition: all .2s ease;
}
.eduqia-card .ai-btn:hover {
  background: #f0f4ff;
  color: var(--c1);
}

.eduqia-card .ai-output {
  font-size: 14px;
  color: #222;
  padding: 10px;
  margin-top: 10px;
  width: 100%;
  word-break: break-word;
  background: #fafafa;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}


/* Messages vides / erreurs */
.eduqia-dir-empty,
.eduqia-dir-error {
  color: #444;
  font-size: 14px;
  text-align: center;
  margin-top: 10px;
}

/* ============== */
/* Badges         */
/* ============== */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  margin-left: 8px;
  color: #fff;
  line-height: 1.3;
}
.badge-officiel { background: #2831DC; }
.badge-payant { background: #F97316; }
.badge-blog { background: #10B981; }
.badge-gratuit { background: #16A34A; }
.badge-premium { background: #9333EA; }
.badge-ressource { background: #2563EB; }
.badge-autre { background: #6B7280; }

/* ===================== */
/* Modale Affiner        */
/* ===================== */
.dir-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.dir-modal[hidden] { display: none; }

.dir-modal-inner {
  background: #fff;
  border-radius: 12px;
  max-width: 620px;
  width: 92vw;
  padding: 20px;
  box-shadow: 0 0 20px rgba(0,0,0,.25);
  animation: popupFade .25s ease;
}
.dir-modal-inner h3 { margin: 0 0 8px; }
.dir-modal-inner textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
}
.dir-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}
.dir-modal-actions .primary {
  background: linear-gradient(45deg, var(--c1), var(--c2));
  border: 0;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.dir-modal-actions button {
  background: #ddd;
  border: 0;
  color: #333;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}
@keyframes popupFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================== */
/* Bouton scroll-to-end  */
/* ===================== */
.scroll-btn {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s, visibility .3s, transform .2s;
  background: linear-gradient(45deg, var(--c1), var(--c2));
  color: #fff;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,.1);
}
.scroll-btn:hover {
  transform: translateX(-50%) scale(1.1);
}

/* ============== */
/* Responsiveness */
/* ============== */
@media (max-width: 600px) {
  .eduqia-dir form#eduqia-dir-form,
  .eduqia-dir .form-group,
  .eduqia-dir .styled-select,
  .eduqia-dir input[type="text"],
  .eduqia-dir .mwai-form-submit {
    max-width: 92vw;
  }
}

/* ========== */
/* Impression */
/* ========== */
@media print {
  .scroll-btn, .dir-modal, form#eduqia-dir-form { display: none !important; }
  .eduqia-dir-title {
    color: #000;
    background: none;
    -webkit-background-clip: border-box;
  }
  #eduqia-dir-results { grid-template-columns: 1fr; }
  .eduqia-card { page-break-inside: avoid; }
}

/* === Styles IA améliorés === */
.eduqia-card .ai {
  margin-top: 10px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}

.eduqia-card .ai-btn {
  background: linear-gradient(90deg, #2831DC, #09A9F8);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  margin: 4px;
  cursor: pointer;
  transition: 0.2s ease;
}

.eduqia-card .ai-btn:hover {
  transform: scale(1.03);
}

.ai-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 6px;
}

.ai-toolbar button {
  background: #f1f1f1;
  border: none;
  border-radius: 5px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.9em;
}

.ai-content {
  background: #fafafa;
  padding: 12px;
  border-radius: 8px;
  line-height: 1.5;
  font-size: 0.95em;
  color: #333;
  white-space: pre-line;
}

/* === Loader animé pour génération IA === */
.custom-loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 15px 0;
  gap: 6px;
}

.custom-loader span {
  width: 10px;
  height: 10px;
  background: linear-gradient(90deg, #2831DC, #09A9F8);
  border-radius: 50%;
  animation: bounce 0.8s infinite ease-in-out;
}

.custom-loader span:nth-child(2) {
  animation-delay: 0.2s;
}
.custom-loader span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Assure la visibilité du loader dans la carte */
.eduqia-card .ai-output {
  text-align: center;
  min-height: 60px;
  display: block;
  margin-top: 10px;
}

/* ✅ Cache la bordure bleue tant qu'aucun contenu IA n'est présent */
.eduqia-card .ai-output:empty {
  border-left: none;
  min-height: 0;
  margin-top: 0;
}

.eduqia-card .ai-output[hidden],
.eduqia-card .ai-output:empty {
  display: none;
  border-left: none;
}

.eduqia-card .ai-output {
  opacity: 0;
  transform: translateY(5px);
  transition: opacity .3s ease, transform .3s ease;
}

.eduqia-card .ai-output:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}

/* ✅ Boutons Copier / PDF bleus permanents */
.ai-toolbar button,
.eduqia-card .ai-btn.copy-btn,
.eduqia-card .ai-btn.pdf-btn {
  background: linear-gradient(45deg, #2831DC, #09A9F8);
  color: #fff !important;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.ai-toolbar button:hover,
.eduqia-card .ai-btn.copy-btn:hover,
.eduqia-card .ai-btn.pdf-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 8px rgba(40,49,220,0.3);
}

.ia-analysis-box {
  background: #f9fbff;
  border-left: 4px solid #09A9F8;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 20px;
  animation: fadeIn 0.4s ease-in-out;
}

.ia-analysis-box h3 {
  color: #2831DC;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ia-analysis-box p {
  color: #333;
  font-size: 15px;
  line-height: 1.5;
}

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


