/* =========================================================
   SP SQL — Styles (CLEAN)
   - Playground (éditeur + résultats)
   - Flashcards (grille + cartes)
   - Modale flashcards (reset typographique anti-Elementor)
   ========================================================= */

/* ------------------------------
   1) Playground
------------------------------ */

.spsql-root{
  --spsql-editor-height: 240px;

  border: 1px solid rgba(0,0,0,.12);
  border-radius: 16px;
  padding: 16px;
  margin: 14px 0;
  background: #fff;
}

/* Toolbar / Select */
.spsql-toolbar{
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
  text-align: center; /* fallback */
}

.spsql-scenario-row{
  border: 1px solid rgba(59,130,246,.20);
  background: rgba(59,130,246,.06);
  border-radius: 16px;
  padding: 12px 14px;
}

.spsql-scenario-label{
  font-weight: 800;
  margin: 0 0 8px;
  white-space: nowrap;
}

.spsql-scenario-select{
  width: 100%;
  max-width: none;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(59,130,246,.35);
  background: #fff;
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(15,23,42,.06);
}

.spsql-scenario-select:focus{
  outline: none;
  box-shadow: 0 0 0 4px rgba(59,130,246,.16);
}

/* Boutons */
.spsql-actions-row{
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  text-align: center;
}

/* anti-Elementor wrappers */
.spsql-actions-row p,
.spsql-actions-row .elementor-button-wrapper,
.spsql-actions-row .wp-block-button{
  display: contents !important;
  margin: 0 !important;
}

.spsql-btn{
  appearance: none;
  -webkit-appearance: none;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: auto !important;          /* anti-thème bandeau */
  max-width: none !important;
  flex: 0 0 auto !important;

  border: 0;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  color: #fff !important;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;

  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: .2px;
  line-height: 1;

  box-shadow: 0 12px 26px rgba(15,23,42,.10);
  text-decoration: none !important;
}

.spsql-btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 18px 38px rgba(15,23,42,.16);
  filter: saturate(1.05);
}

.spsql-status{
  font-size: 13px;
  opacity: .85;
  text-align: right;
}

/* Layout (2 colonnes desktop, 1 colonne mobile) */
.spsql-layout{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}

@media (max-width: 980px){
  .spsql-layout{ grid-template-columns: 1fr; }
}

/* Panneau schéma */
.spsql-side{
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 16px;
  padding: 14px;
  background: rgba(0,0,0,.02);

  display: flex;
  flex-direction: column;
  min-height: var(--spsql-editor-height);
}

.spsql-side__title{
  font-weight: 900;
  margin-bottom: 6px;
}

.spsql-scenario-name{
  font-size: 13px;
  opacity: .8;
  margin-bottom: 10px;
}

.spsql-schema{
  flex: 1 1 auto;
  overflow: auto;
  font-size: 13px;
  line-height: 1.35;
}

.spsql-schema code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12.5px;
}

.spsql-side__hint{
  margin-top: 12px;
  font-size: 12.5px;
  opacity: .8;
}

/* Editor */
.spsql-editor{
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 16px;
  overflow: hidden;

  height: var(--spsql-editor-height) !important;
  min-height: var(--spsql-editor-height) !important;
}

.spsql-editor .monaco-editor,
.spsql-editor .monaco-editor .overflow-guard{
  height: 100% !important;
}

/* Résultats / Erreurs */
.spsql-output-wrap,
.spsql-error-wrap{
  grid-column: 1 / -1; /* pleine largeur sous la grille */
  border-radius: 16px;
  overflow: hidden;
}

.spsql-output-wrap{
  border: 1px solid rgba(0,0,0,.12);
  margin-top: 0;
}

.spsql-output-title{
  position: sticky;
  top: 0;
  z-index: 2;

  padding: 10px 12px;
  font-weight: 900;

  background: linear-gradient(180deg, rgba(59,130,246,.10), rgba(59,130,246,.04));
  border-bottom: 1px solid rgba(59,130,246,.18);
}

.spsql-output{
  padding: 10px 12px;
  overflow: auto;
  max-height: 560px;
}

.spsql-table{
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.spsql-table th,
.spsql-table td{
  border: 1px solid rgba(0,0,0,.10);
  padding: 6px 8px;
  vertical-align: top;
}

.spsql-table th{
  background: rgba(0,0,0,.03);
  text-align: left;
  font-weight: 800;
}

.spsql-error-wrap{
  border: 1px solid rgba(255,0,0,.22);
  margin-top: 10px;
}

.spsql-error-title{
  padding: 10px 12px;
  font-weight: 900;
  background: rgba(255,0,0,.06);
  border-bottom: 1px solid rgba(255,0,0,.14);
}

.spsql-error{
  margin: 0;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12.5px;
}


/* ------------------------------
   2) Flashcards (cards + grid)
------------------------------ */

.sp-sql-intro-card,
.sp-sql-usage-card,
.sp-sql-flashcards-card{
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 18px;
  padding: 18px;
  margin: 14px 0;
  box-shadow: 0 10px 30px rgba(0,0,0,.04);
}

.sp-sql-flashcards-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 12px;
}

@media (max-width: 900px){
  .sp-sql-flashcards-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px){
  .sp-sql-flashcards-grid{ grid-template-columns: 1fr; }
}

.sp-sql-flashcard{
  width: 100%;
  text-align: left;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;

  background: linear-gradient(180deg, #ffffff 0%, #f3f7ff 100%);
  border: 1px solid rgba(37,99,235,.18);
  border-radius: 18px;
  padding: 16px 18px;

  color: #0f172a;
  cursor: pointer;

  box-shadow: 0 12px 28px rgba(15,23,42,.06);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.sp-sql-flashcard:hover{
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(15,23,42,.10);
  border-color: rgba(37,99,235,.28);
}

.sp-sql-flashcard:focus{
  outline: none;
  box-shadow: 0 0 0 4px rgba(59,130,246,.16), 0 18px 40px rgba(15,23,42,.10);
}

.sp-sql-flashcard-title{
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.2;
}

.sp-sql-flashcard-hint{
  margin-top: 8px;
  color: rgba(15,23,42,.65);
  font-weight: 600;
  font-size: .92rem;
}

/* Flashcards : carte plus marquée + titres en noir (anti-Elementor) */
.sp-sql-flashcard{
  background: linear-gradient(180deg, #ffffff 0%, #eef5ff 100%);
  border: 1px solid rgba(37,99,235,.22);
  box-shadow: 0 16px 44px rgba(15,23,42,.08);
}

.sp-sql-flashcard:hover{
  box-shadow: 0 22px 56px rgba(15,23,42,.12);
}

/* Titre/texte : forcer le noir (Elementor ne doit pas recolorer) */
.sp-sql-flashcard-title{
  color: #0f172a !important;
  font-weight: 850;
}

.sp-sql-flashcard-hint{
  color: rgba(15,23,42,.62) !important;
}

/* ------------------------------
   3) Modale Flashcards (CLEAN + anti-Elementor)
------------------------------ */

.sp-sql-modal{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 999999;
}

.sp-sql-modal.is-open{ display: block; }

.sp-sql-modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.sp-sql-modal-dialog{
  position: relative;
  max-width: 860px;
  width: calc(100% - 28px);
  margin: 72px auto;
  background: #fff;
  border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: 0 26px 80px rgba(15, 23, 42, 0.25);
  outline: none;
}

.sp-sql-modal-close{ display: none !important; }

.sp-sql-modal-kicker{
  font-size: 13px;
  opacity: .7;
  margin-bottom: 6px;
  letter-spacing: .08em;
}

.sp-sql-modal-title{
  margin: 0 0 18px;
  font-weight: 800;
  line-height: 1.1;
}

/* --- IMPORTANT : RESET TYPOGRAPHIQUE FORT (stop Elementor) --- */
#sp-sql-flash-modal .sp-sql-modal-explain,
#sp-sql-flash-modal .sp-sql-modal-explain *{
  margin: 0;
  padding: 0;
  line-height: 1.42 !important;
}

#sp-sql-flash-modal .sp-sql-modal-explain{
  margin: 6px 2px 12px !important;    /* espace contrôlé */
  color: #334155;
  opacity: .95;
  font-size: 16px;
}

/* Paragraphes compactés */
#sp-sql-flash-modal .sp-sql-modal-explain p{
  margin: 8px 0 !important;
}

/* Listes compactées */
#sp-sql-flash-modal .sp-sql-modal-explain ul,
#sp-sql-flash-modal .sp-sql-modal-explain ol{
  margin: 8px 0 8px 18px !important;
  padding: 0 !important;
}

#sp-sql-flash-modal .sp-sql-modal-explain li{
  margin: 4px 0 !important;
}

/* Petit bloc “requête type” dans l’explication */
#sp-sql-flash-modal .sp-sql-mini{
  display: inline-block;
  margin: 6px 0 2px !important;
  padding: 6px 10px;
  border-radius: 12px;
  background: #f6f7fb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 650;
  font-size: 13px;
  line-height: 1.25 !important;
}

/* Bloc code exemple */
#sp-sql-flash-modal .sp-sql-modal-code{
  margin-top: 12px !important;
  background: #f4f6fb;
  border-radius: 16px;
  padding: 14px 16px !important;
  overflow: auto;
  font-size: 13px !important;
  line-height: 1.35 !important;
}

#sp-sql-flash-modal .sp-sql-modal-code code{
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 600 !important;
  white-space: pre !important;
}

/* Actions */
.sp-sql-modal-actions{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  margin-top: 16px;
}

.sp-sql-modal-btn{
  appearance: none !important;
  -webkit-appearance: none !important;

  display: inline-flex !important;
  justify-content: center !important;
  align-items: center !important;

  width: auto !important;
  min-width: 150px !important;

  padding: 9px 16px !important;
  border-radius: 999px !important;

  font-weight: 800 !important;
  font-size: 13.5px !important;
  line-height: 1 !important;

  background: #2563eb !important;
  color: #ffffff !important;
  border: 1px solid rgba(37,99,235,.35) !important;

  box-shadow: 0 10px 20px rgba(37,99,235,.14) !important;
  text-decoration: none !important;

  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.sp-sql-modal-btn:hover{
  background: #1d4ed8 !important;
  box-shadow: 0 14px 28px rgba(37,99,235,.18) !important;
  transform: translateY(-1px);
}

.sp-sql-modal-btn:focus{
  outline: none !important;
  box-shadow: 0 0 0 4px rgba(59,130,246,.20), 0 14px 28px rgba(37,99,235,.18) !important;
}

/* Fermer = neutre */
.sp-sql-modal-btn[data-action="close"]{
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border-color: rgba(148,163,184,.35) !important;
  box-shadow: none !important;
  transform: none !important;
}

.sp-sql-modal-btn[data-action="close"]:hover{
  background: #e2e8f0 !important;
}

@media (max-width: 560px){
  .sp-sql-modal-btn{ width: 100% !important; min-width: 0 !important; }
}

/* Runner SQL offscreen (Monaco ne supporte pas display:none) */
.spsql-offscreen{
  position:absolute !important;
  left:-10000px !important;
  top:auto !important;
  width:1200px !important;   /* une largeur "réelle" pour Monaco */
  height:400px !important;
  overflow:hidden !important;
  opacity:0 !important;
  pointer-events:none !important;
}

/* Optionnel : un peu d’air pour le résultat */
.spsql-example-output .spsql-table{
  margin-top: .5rem;
}

