/* ==========================================================================
   T-Text - Styles de l'Assistant Relecture & Correcteur Pédagogique
   ========================================================================== */

/* 1. Bouton dans la barre d'outils */
.btn-assistant-relecture {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%) !important;
  border: 1.5px solid #c4b5fd !important;
  color: #6d28d9 !important;
  border-radius: 8px !important;
  padding: 4px 10px !important;
  font-weight: 800 !important;
  box-shadow: 0 1px 3px rgba(109, 40, 217, 0.1) !important;
  transition: all 0.2s ease !important;
}

.btn-assistant-relecture:hover {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%) !important;
  border-color: #8b5cf6 !important;
  color: #5b21b6 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 3px 8px rgba(109, 40, 217, 0.2) !important;
}

.btn-assistant-relecture.active {
  background: #7c3aed !important;
  color: #ffffff !important;
  border-color: #6d28d9 !important;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.4) !important;
}

.btn-assistant-relecture.active .assistant-label {
  color: #ffffff !important;
}

.assistant-owl-icon {
  font-size: 18px;
  line-height: 1;
}

.assistant-label {
  font-size: 13.5px;
  font-weight: 800;
  color: #6d28d9;
}

/* Badge compteur sur le bouton */
.spell-check-badge {
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 900;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  animation: badgePop 0.3s ease-out;
}

@keyframes badgePop {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* 2. Volet latéral rétractable (Drawer) */
.ttext-spell-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -8px 0 30px rgba(15, 23, 42, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  transform: translateX(105%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  font-family: 'Nunito', 'Segoe UI', Tahoma, sans-serif;
}

.ttext-spell-drawer.open {
  transform: translateX(0);
}

/* Décalage du bureau pour grand écran quand le volet est ouvert */
.ttext-workspace.drawer-open {
  padding-right: 400px;
  transition: padding-right 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* En-tête du volet */
.spell-drawer-header {
  background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 100%);
  color: white;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(109, 40, 217, 0.2);
  flex-shrink: 0;
}

.spell-drawer-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spell-drawer-owl {
  font-size: 32px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.spell-drawer-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.2px;
  color: white;
}

.spell-drawer-subtitle {
  font-size: 12.5px;
  font-weight: 600;
  color: #ede9fe;
  display: block;
  margin-top: 2px;
}

.spell-drawer-close {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.spell-drawer-close:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: rotate(90deg);
}

/* Barre d'outils du volet */
.spell-drawer-toolbar {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.spell-tool-btn {
  background: white;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.spell-tool-btn:hover {
  background: #ede9fe;
  border-color: #a78bfa;
  color: #6d28d9;
}

.spell-toggle-label {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.spell-toggle-label input {
  cursor: pointer;
}

/* Corps déroulant des cartes */
.spell-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f1f5f9;
}

/* Carte individuelle de suggestion */
.spell-card {
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
}

.spell-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #cbd5e1;
}

/* Bordures colorées selon la catégorie */
.spell-card.badge-ponct-card { border-left: 5px solid #3b82f6; }
.spell-card.badge-homophone-card { border-left: 5px solid #f59e0b; }
.spell-card.badge-accord-card { border-left: 5px solid #10b981; }
.spell-card.badge-ortho-card { border-left: 5px solid #8b5cf6; }

.spell-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.spell-card-badge {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-ponct { background: #dbeafe; color: #1e40af; }
.badge-homophone { background: #fef3c7; color: #92400e; }
.badge-accord { background: #d1fae5; color: #065f46; }
.badge-ortho { background: #ede9fe; color: #5b21b6; }

.spell-card-num {
  font-size: 12px;
  font-weight: 800;
  color: #94a3b8;
}

/* Extrait avec mot surligné */
.spell-card-snippet {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13.5px;
  color: #334155;
  line-height: 1.4;
  font-style: italic;
}

.spell-snippet-target {
  background: #fde047;
  color: #991b1b;
  font-weight: 900;
  font-style: normal;
  padding: 1px 4px;
  border-radius: 4px;
}

/* Bulle d'explication pédagogique */
.spell-card-tip {
  font-size: 13px;
  color: #1e293b;
  line-height: 1.5;
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: 8px;
  padding: 9px 12px;
}

.spell-card-tip strong {
  color: #6d28d9;
}

/* Actions de la carte */
.spell-card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.spell-btn-replace {
  width: 100%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
  transition: all 0.15s ease;
}

.spell-btn-replace:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4);
}

/* Bouton de remplacement alternatif (si 2ème option pertinente) */
.spell-btn-replace-alt {
  width: 100%;
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  color: #166534;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.spell-btn-replace-alt:hover {
  background: #dcfce7;
  border-color: #4ade80;
  color: #14532d;
}

/* Indicateur de mode de connexion (En ligne / Hors ligne) */
.spell-mode-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.spell-mode-indicator.mode-online {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.spell-mode-indicator.mode-offline {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.spell-mode-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.mode-online .spell-mode-dot {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulseDot 2s infinite ease-in-out;
}

.mode-offline .spell-mode-dot {
  background: #f59e0b;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.spell-card-sub-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.spell-btn-sub {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #475569;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.spell-btn-sub:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.spell-btn-ignore {
  color: #94a3b8;
}

.spell-btn-ignore:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* Carte de félicitations quand 0 erreur */
.spell-empty-card {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 2px dashed #10b981;
  border-radius: 16px;
  padding: 30px 20px;
  text-align: center;
  color: #065f46;
  margin: auto 0;
}

.spell-empty-owl {
  font-size: 48px;
  margin-bottom: 10px;
  animation: bounceOwl 1.5s infinite alternate;
}

@keyframes bounceOwl {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

.spell-empty-title {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 900;
  color: #047857;
}

.spell-empty-desc {
  font-size: 13.5px;
  line-height: 1.5;
  color: #065f46;
  margin: 0 0 14px 0;
}

.spell-badge-praise {
  display: inline-block;
  background: #059669;
  color: white;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 20px;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
}

/* Carte de bienvenue */
.spell-welcome-card {
  background: white;
  border: 1.5px solid #c4b5fd;
  border-radius: 14px;
  padding: 20px 16px;
  text-align: left;
}

.spell-welcome-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.spell-welcome-card h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 800;
  color: #5b21b6;
}

.spell-welcome-card p {
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
  margin: 0 0 10px 0;
}

.spell-welcome-card ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: #334155;
  line-height: 1.7;
}

/* Pied du volet */
.spell-drawer-footer {
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 12px 16px;
  flex-shrink: 0;
}

.spell-school-tip {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
  text-align: center;
}

/* Pulsation de repérage temporaire sur la feuille */
.ttext-pulse-highlight {
  background: #fef08a !important;
  color: #991b1b !important;
  box-shadow: 0 0 0 4px #facc15, 0 0 12px rgba(234, 179, 8, 0.6) !important;
  border-radius: 3px !important;
  animation: pulseGlow 0.6s 3 alternate ease-in-out;
}

@keyframes pulseGlow {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

/* Version mobile / écran étroit */
@media (max-width: 768px) {
  .ttext-spell-drawer {
    width: 100vw;
    max-width: 100vw;
  }
  .ttext-workspace.drawer-open {
    padding-right: 20px;
  }
}

/* Masquer le tiroir correcteur à l'impression */
@media print {
  #ttext-spell-drawer,
  .ttext-spell-drawer {
    display: none !important;
  }
}
