/* =========================================================================
   BOT-Math - Studio Informatique Pro — Stylesheet Principale
   ========================================================================= */

:root {
    --or:       #d4af37;
    --noir:     #110f19;
    --blanc:    #ffffff;
    --gris:     #cbd5e1;
    --sarcelle: #508289;
    --vert:     #059669;
    --rouge:    #dc2626;
    --fond:     #110f19;
    --card-bg:  #1e1b2e;
    --accent:   #3b82f6;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--noir);
    color: var(--gris);
    overflow: hidden;
}

[v-cloak] {
    display: none !important;
}

/* ── LAYOUT PRINCIPAL ── */
.app-container {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── HEADER ── */
.lab-header {
    background-color: var(--noir);
    border-bottom: 2px solid var(--or);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    z-index: 1000;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.discipline-selector {
    background-color: var(--card-bg);
    color: white;
    border: 1px solid var(--sarcelle);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.discipline-selector:focus {
    border-color: var(--or);
}

.separateur-vertical {
    width: 1px;
    height: 30px;
    background-color: rgba(255, 255, 255, 0.15);
    margin: 0 5px;
}

/* ── BOUTONS ET ACTIONS ── */
.btn-action {
    background-color: transparent;
    border: 1px solid var(--sarcelle);
    color: var(--gris);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease-in-out;
}

.btn-action:hover {
    background-color: var(--sarcelle);
    color: white;
}

.btn-square {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
}

.btn-fermer {
    background-color: transparent;
    border: none;
    color: var(--rouge);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.btn-fermer:hover {
    transform: scale(1.1);
}

/* ── CORPS DE L'APPLICATION ── */
.app-body {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* ── PANNEAU LATÉRAL (OUTILS / CONFIGURATION) ── */
.sidebar {
    width: 320px;
    background-color: var(--card-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 15px;
    gap: 15px;
    z-index: 10;
}

.sidebar-title {
    color: var(--or);
    font-size: 1.1rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── ZONE DE TRAVAIL (CANVAS) ── */
.workspace-canvas {
    flex: 1;
    position: relative;
    background-color: #151324;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── PANNEAUX FLOTTANTS ── */
.var-panel-floating {
    position: fixed;
    background-color: var(--card-bg);
    border: 1px solid var(--sarcelle);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.var-panel-header {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 10px 15px;
    font-weight: bold;
    color: var(--or);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.var-panel-content {
    padding: 15px;
    overflow-y: auto;
}

/* ── COMPOSANTS MATÉRIEL DRAG/DROP ── */
.hardware-bank {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.hardware-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    cursor: grab;
    transition: all 0.2s;
}

.hardware-card:hover {
    border-color: var(--or);
    background: rgba(212, 175, 55, 0.05);
    transform: translateY(-2px);
}

.hardware-card img, .hardware-card i {
    font-size: 2rem;
    color: var(--or);
    margin-bottom: 8px;
    display: block;
}

.hardware-target {
    border: 2px dashed var(--sarcelle);
    border-radius: 8px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.hardware-target.drag-over {
    border-color: var(--vert);
    background: rgba(5, 150, 105, 0.1);
}

.hardware-target.matched {
    border-style: solid;
    border-color: var(--vert);
    background: rgba(5, 150, 105, 0.05);
}

/* ── MODALS (BIBLIOTHEQUE & DETAILS) ── */
.modal-svg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(17, 15, 25, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-svg-container {
    background-color: var(--card-bg);
    border: 2px solid var(--sarcelle);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow: hidden;
}

.modal-svg-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-svg-header h2 {
    margin: 0;
    color: var(--or);
    font-size: 1.3rem;
}

.modal-svg-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.modal-svg-sidebar {
    width: 200px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.btn-cat-svg {
    background: transparent;
    border: 1px solid transparent;
    color: var(--gris);
    padding: 8px 12px;
    text-align: left;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-cat-svg:hover, .btn-cat-svg.active {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--sarcelle);
    color: white;
}

.modal-svg-grid-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* ── BLOCKS DE CODE ALGOS ── */
.code-block {
    background: #110f19;
    border: 1px solid var(--sarcelle);
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 0.85rem;
    font-family: monospace;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: grab;
    user-select: none;
    transition: border-color 0.2s;
}

.code-block:hover {
    border-color: var(--or);
}

.code-workspace {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    min-height: 250px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── NETWORK NODES & LINKS ── */
.network-node {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--sarcelle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    z-index: 20;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.network-node:hover, .network-node.selected {
    border-color: var(--or);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
}

.network-node i {
    font-size: 1.8rem;
    color: var(--or);
}

/* ── WEB STUDIO PREVIEW ── */
.web-editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 2px solid var(--or);
}

.web-preview-pane {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.web-textarea {
    flex: 1;
    background: #110f19;
    color: #a7f3d0;
    border: none;
    font-family: 'Fira Code', Consolas, monospace;
    font-size: 0.95rem;
    padding: 15px;
    resize: none;
    outline: none;
}

/* =========================================================================
   AJOUTS — mise en forme des éléments introduits par la refonte du module
   ========================================================================= */

/* ── En-tête : reste utilisable sur un écran étroit ── */
.titre-studio {
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--or);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.header-right {
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    white-space: nowrap;
    scrollbar-width: thin;
    scrollbar-color: var(--or) transparent;
    padding-bottom: 2px;
}
.header-right::-webkit-scrollbar { height: 5px; }
.header-right::-webkit-scrollbar-track { background: transparent; }
.header-right::-webkit-scrollbar-thumb { background: var(--or); border-radius: 3px; }

.champ-entete {
    background: var(--noir);
    color: white;
    border: 1px solid var(--sarcelle);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.85rem;
    min-width: 150px;
}
.champ-entete:focus { outline: none; border-color: var(--or); }
.champ-court { width: 110px; min-width: 90px; }

.btn-valider  { background-color: var(--vert);     color: #fff; border-color: var(--vert); }
.btn-sauver   { background-color: var(--or);       color: var(--noir); border-color: var(--or); }
.btn-biblio   { background-color: var(--sarcelle); color: #fff; }
.btn-droits   { background-color: #8b5cf6; color: #fff; border-color: #8b5cf6; }
.btn-langue   { background: transparent; border-color: var(--or); color: var(--or); }
.btn-reset    { margin-top: auto; background-color: var(--rouge); color: #fff; border-color: var(--rouge); justify-content: center; }
.btn-simuler  { background-color: var(--vert); color: #fff; border-color: var(--vert); }
.btn-action:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Panneau latéral ── */
.pile-boutons { display: flex; flex-direction: column; gap: 8px; }
.ligne-boutons { display: flex; gap: 6px; margin-top: 5px; }
.ligne-boutons .btn-action { flex: 1; justify-content: center; }
.btn-bloc { text-align: left; justify-content: flex-start; font-size: 0.85rem; }
.mini-label { font-size: 0.78rem; color: #94a3b8; }
.champ-select {
    width: 100%;
    background: var(--noir);
    color: white;
    border: 1px solid var(--sarcelle);
    padding: 6px;
    border-radius: 4px;
}
.hardware-card.deja-pose { opacity: 0.35; cursor: not-allowed; }
.hardware-card strong { font-size: 0.8rem; display: block; }

/* ── Ateliers ── */
.atelier { width: 100%; height: 100%; box-sizing: border-box; position: relative; }

.bandeau-consigne {
    background: rgba(0, 0, 0, 0.4);
    padding: 14px 18px;
    border-radius: 8px;
    border-left: 4px solid var(--or);
}
.bandeau-consigne h2 { margin: 0; color: #fff; font-size: 1.15rem; }
.bandeau-consigne p { margin: 5px 0 0; font-size: 0.85rem; color: #94a3b8; }
.bandeau-consigne.flottant {
    position: absolute;
    top: 15px; left: 15px; right: 15px;
    z-index: 30;
    pointer-events: none;
}

.atelier-materiel { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.carte-mere {
    flex: 1;
    background: #0f172a;
    border: 2px solid var(--sarcelle);
    border-radius: 12px;
    /* Grille souple : les zones se réorganisent selon la largeur disponible
       au lieu de rester bloquées à une seule colonne sur un écran moyen. */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
    align-content: start;
    padding: 20px;
    overflow-y: auto;
}
.hardware-target { width: auto; }
.zone-icone { font-size: 1.7rem; margin-bottom: 5px; color: rgba(255, 255, 255, 0.25); }
.zone-label { font-size: 0.8rem; color: #94a3b8; font-weight: bold; }
.zone-pieces { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 8px; }

.piece-posee {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(30, 27, 46, 0.95);
    border: 2px solid;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.78rem;
    color: #fff;
}
.piece-posee.juste { border-color: var(--vert); }
.piece-posee.faux  { border-color: var(--rouge); }
.piece-posee i { font-size: 1.1rem; }
.piece-posee.juste i { color: var(--vert); }
.piece-posee.faux  i { color: var(--rouge); }
.piece-posee span { flex: 1; text-align: start; }

.btn-retirer {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}
.btn-retirer:hover { color: var(--rouge); background: rgba(220, 38, 38, 0.1); }

/* ── Réseau ── */
.atelier-reseau { overflow: hidden; }
.calque-cables {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
}
.paquet { filter: drop-shadow(0 0 6px var(--or)); }
.node-nom {
    position: absolute;
    bottom: -26px; left: -50%; right: -50%;
    text-align: center;
    font-size: 0.72rem;
    font-weight: bold;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 5px;
    border-radius: 3px;
    white-space: nowrap;
}
.btn-supprimer-node {
    position: absolute;
    top: -5px; right: -5px;
    background: var(--rouge);
    border: none;
    border-radius: 50%;
    width: 20px; height: 20px;
    color: #fff;
    font-size: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Algorithmique ── */
/* Les deux colonnes se replient d'elles-mêmes quand la place manque :
   pas de largeur de bascule arbitraire à deviner. */
.atelier-code {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    padding: 20px;
    gap: 20px;
    overflow-y: auto;
}
.colonne-algo {
    flex: 1 1 340px;
    min-width: min(300px, 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.colonne-algo .code-workspace { flex: 1; overflow-y: auto; overflow-x: hidden; }
.colonne-toile {
    flex: 0 1 320px;
    min-width: min(300px, 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.colonne-toile h3 { margin: 0; color: var(--sarcelle); }

.toile-dessin {
    width: 300px; height: 300px;
    background: #1e1b2e;
    border: 2px solid var(--sarcelle);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.calque-traces { width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
.robot {
    position: absolute;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: var(--or);
    color: var(--noir);
    border-radius: 50%;
    transition: left 0.25s, top 0.25s, transform 0.25s;
}
.note-toile { font-size: 0.78rem; color: #94a3b8; margin: 0; }

.numero-ligne {
    color: #64748b;
    font-size: 0.75rem;
    min-width: 18px;
    text-align: end;
}
.corps-bloc { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0 8px; overflow-wrap: anywhere; }
.actions-bloc { display: flex; gap: 3px; flex-shrink: 0; }
.btn-mini {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--gris);
    border-radius: 4px;
    width: 24px; height: 24px;
    font-size: 0.7rem;
    cursor: pointer;
}
.btn-mini:hover:not(:disabled) { border-color: var(--or); color: var(--or); }
.btn-mini:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-mini-danger:hover:not(:disabled) { border-color: var(--rouge); color: var(--rouge); }

.zone-vide {
    text-align: center;
    color: #94a3b8;
    margin: auto;
    font-style: italic;
    padding: 20px;
}

/* ── Web ── */
.atelier-web { display: flex; }
.barre-pane {
    background: #1e1b2e;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--or);
    font-weight: bold;
}
.barre-pane.barre-claire {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom: 1px solid #cbd5e1;
}
.web-preview-frame { flex: 1; border: none; width: 100%; background: #fff; }

/* ── Messages ── */
.zone-messages {
    position: fixed;
    top: 74px; right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(380px, 90vw);
}
[dir="rtl"] .zone-messages { right: auto; left: 16px; }

.message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--card-bg);
    border-left: 4px solid var(--sarcelle);
    border-radius: 6px;
    padding: 11px 14px;
    color: #e2e8f0;
    font-size: 0.86rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    animation: message-entree 0.18s ease-out;
}
.message-success { border-left-color: var(--vert); }
.message-error   { border-left-color: var(--rouge); }
.message-info    { border-left-color: var(--sarcelle); }
.message-success i { color: var(--vert); }
.message-error i   { color: var(--rouge); }
.message-info i    { color: var(--sarcelle); }
[dir="rtl"] .message { border-left: none; border-right: 4px solid var(--sarcelle); }

@keyframes message-entree {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Indicateur de confort ── */
.indicateur-perf {
    position: fixed;
    bottom: 15px; right: 15px;
    z-index: 6500;
    background: rgba(17, 15, 25, 0.88);
    border: 1px solid var(--sarcelle);
    color: #cbd5e1;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.74rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}
.indicateur-perf i { color: var(--or); }
[dir="rtl"] .indicateur-perf { right: auto; left: 15px; }

/* ── Fenêtres ── */
.modal-etroit { max-width: 520px; }
.modal-corps { padding: 20px; overflow-y: auto; }
.modal-pied {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    justify-content: flex-end;
}

.score-cercle {
    margin: 0 auto 14px;
    width: 110px; height: 110px;
    border-radius: 50%;
    border: 4px solid var(--sarcelle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
}
.score-cercle.parfait { border-color: var(--vert); color: var(--vert); }
.score-phrase { text-align: center; color: #e2e8f0; margin: 0 0 16px; }
.liste-revoir { background: rgba(0, 0, 0, 0.25); border-radius: 6px; padding: 12px 16px; }
.liste-revoir strong { color: var(--or); }
.liste-revoir ul { margin: 8px 0 0; padding-inline-start: 20px; }
.liste-revoir li { margin-bottom: 5px; font-size: 0.86rem; }
.tout-bon { text-align: center; color: var(--vert); font-weight: bold; }

.intro-droits { color: #94a3b8; font-size: 0.86rem; margin: 0 0 14px; }
.ligne-droit {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: #e2e8f0;
}
.ligne-droit:hover { background: rgba(255, 255, 255, 0.04); }
.ligne-droit input { width: 17px; height: 17px; accent-color: var(--or); cursor: pointer; }
.ligne-droit i { color: var(--or); width: 20px; text-align: center; }
.separateur-modal { border: none; border-top: 1px solid rgba(255, 255, 255, 0.12); margin: 12px 0; }

.carte-projet {
    background: #1e1b2e;
    border: 1px solid var(--sarcelle);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}
.vignette-projet {
    width: 52px; height: 52px;
    object-fit: contain;
    background: #110f19;
    border-radius: 4px;
    flex-shrink: 0;
}
.vignette-vide {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sarcelle);
}
.infos-projet { flex: 1; min-width: 0; }
.infos-projet strong { color: #fff; font-size: 0.98rem; display: block; }
.meta-projet { color: #94a3b8; font-size: 0.78rem; margin-top: 3px; }
.actions-projet { display: flex; gap: 8px; flex-shrink: 0; }
.btn-ouvrir { background: var(--vert); color: #fff; border-color: var(--vert); }
.btn-supprimer { border-color: var(--rouge); color: var(--rouge); }
.btn-supprimer:hover { background: var(--rouge); color: #fff; }

/* ── Écrans étroits ── */
@media (max-width: 900px) {
    .titre-texte { display: none; }
    .sidebar { width: 240px; padding: 12px; }
    .colonne-toile { width: 100%; }
}

@media (max-width: 640px) {
    .app-body { flex-direction: column; }
    .sidebar { width: auto; max-height: 42vh; border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
    .panneaux-web { flex-direction: column; }
    .web-editor-pane { border-right: none; border-bottom: 2px solid var(--or); min-height: 200px; }
    .champ-entete { min-width: 120px; }
    .indicateur-perf { display: none; }
}

/* L'atelier web garde sa consigne en bandeau, comme les trois autres. */
.atelier-web { flex-direction: column; }
.atelier-web .bandeau-web {
    border-radius: 0;
    border-left: none;
    border-bottom: 2px solid var(--or);
    padding: 10px 18px;
    flex-shrink: 0;
}
.atelier-web .bandeau-web h2 { font-size: 1rem; }
.atelier-web .bandeau-web p { font-size: 0.78rem; }
.panneaux-web { flex: 1; display: flex; min-height: 0; }

/* Bouton d'envoi vers l'éditeur de leçon (visible seulement quand le studio
   a été ouvert depuis « Créer un savoir »). */
.btn-injecter {
    background-color: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
    white-space: nowrap;
}
.btn-injecter:hover { background-color: #6d28d9; border-color: #6d28d9; color: #fff; }
@media (max-width: 1100px) { .texte-injecter { display: none; } }
