/* ==========================================================
   MathMaroc — lesson-tools.css
   Stable phase 1.2 (bac blanc + exam pro)
   ========================================================== */

/* ===== Base layout ===== */
.mm-lesson-wrap{
  max-width:1100px;
  margin:0 auto;
  padding:16px 12px 90px;
}

.mm-lesson-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  flex-wrap:wrap;
  margin:10px 0 14px;
  position:relative;
  z-index:1;
}

.mm-lesson-head-left{
  min-width:280px;
  flex:1 1 420px;
}

.mm-lesson-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  position:relative;
  z-index:20;
}

.mm-lesson-title{
  margin:0;
  font-size:1.6rem;
  font-weight:950;
  color:#0f172a;
}

.mm-lesson-meta{
  margin-top:6px;
  color:#6b7280;
  font-weight:850;
}

/* ===== Buttons ===== */
.mm-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:44px;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid #e5e7eb;
  background:#fff;
  color:#111827;
  font-weight:950;
  cursor:pointer;
  text-decoration:none;
  transition:background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
  box-shadow:0 2px 8px rgba(15,23,42,.04);
}

.mm-btn:hover{
  background:#f8fafc;
  border-color:#cbd5e1;
  transform:translateY(-1px);
}

.mm-btn.primary{
  background:#111827;
  color:#fff;
  border-color:#111827;
}

.mm-btn.primary:hover{
  background:#1f2937;
  border-color:#1f2937;
}

.mm-btn.ghost{
  background:#f8fafc;
}

.mm-btn:disabled,
.mm-btn.is-disabled{
  opacity:.6;
  cursor:not-allowed;
  transform:none;
}

#mmStartExamBtn,
#mmStartBacBtn{
  position:relative;
  z-index:50;
  pointer-events:auto;
}

/* ===== Content ===== */
.mm-content{
  padding:18px;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:16px;
  box-shadow:0 10px 35px rgba(16,24,40,.06);
  position:relative;
  z-index:1;
}

.mm-content h2,
.mm-content h3{
  margin-top:18px;
}

.mm-content pre{
  padding:12px;
  border-radius:12px;
  background:#0b1220;
  color:#e5e7eb;
  overflow:auto;
}

.mm-empty-note{
  padding:14px;
  border:1px dashed #cbd5e1;
  border-radius:12px;
  color:#475569;
  background:#f8fafc;
  font-weight:800;
}

/* ===== Inputs ===== */
.mm-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:10px;
}

.mm-in,
.mm-ta{
  width:100%;
  padding:11px 12px;
  border-radius:12px;
  border:1px solid #d1d5db;
  outline:none;
  background:#fff;
  color:#111827;
  font-weight:800;
  box-sizing:border-box;
}

.mm-mini{
  width:auto;
  min-width:110px;
  flex:1 1 110px;
}

.mm-in:focus,
.mm-ta:focus{
  border-color:#2563eb;
  box-shadow:0 0 0 3px rgba(37,99,235,.12);
}

.mm-ta{
  min-height:140px;
  resize:vertical;
}

/* ===== Result boxes ===== */
.mm-result-box{
  margin-top:12px;
  padding:12px 14px;
  background:#f8fafc;
  border:1px solid #e5e7eb;
  border-radius:12px;
  font-weight:800;
  line-height:1.7;
  white-space:pre-wrap;
  box-sizing:border-box;
}

/* ===== Hints / badges ===== */
.mm-hint{
  margin-top:12px;
  padding:10px 12px;
  background:#f8fafc;
  border:1px solid #e5e7eb;
  border-radius:12px;
  color:#475569;
  font-weight:700;
  line-height:1.6;
}

.mm-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:28px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid #dbeafe;
  background:#eff6ff;
  color:#1d4ed8;
  font-weight:900;
  font-size:.85rem;
}

/* ===== Actions ===== */
.mm-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  margin-top:12px;
}

/* ===== Cards ===== */
.mm-subcard{
  margin-top:14px;
  padding:14px;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  box-shadow:0 6px 20px rgba(15,23,42,.04);
}

.mm-subcard h4{
  margin:0 0 10px;
  color:#0f172a;
  font-weight:900;
}

/* ===== Tables ===== */
.mm-table-scroll{
  margin-top:12px;
  overflow:auto;
  border-radius:12px;
  border:1px solid #e5e7eb;
}

.mm-table{
  width:100%;
  min-width:560px;
  border-collapse:collapse;
  background:#fff;
}

.mm-table th,
.mm-table td{
  padding:10px 12px;
  border-bottom:1px solid #eef2f7;
  font-weight:800;
  color:#111827;
  text-align:left;
}

/* ===== Variation ===== */
.mm-var-school{
  margin-top:12px;
  overflow:auto;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:12px;
}

.mm-var-school table{
  width:100%;
  min-width:640px;
  border-collapse:collapse;
}

.mm-var-school th,
.mm-var-school td{
  border:1px solid #e5e7eb;
  padding:12px 10px;
  text-align:center;
  font-weight:900;
  color:#0f172a;
}

.mm-var-sign-pos{ color:#166534; background:#ecfdf5; }
.mm-var-sign-neg{ color:#991b1b; background:#fef2f2; }
.mm-var-sign-zero{ color:#1d4ed8; background:#eff6ff; }
.mm-var-arrow{ font-size:1.2rem; }

/* ===== Auto blocks ===== */
.mm-auto-block{
  margin:16px 0;
  padding:14px;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  box-shadow:0 8px 24px rgba(15,23,42,.06);
}

.mm-auto-title{
  margin-bottom:10px;
  font-weight:900;
  color:#0f172a;
}

/* ===== Canvas ===== */
.mm-canvas-wrap{
  margin-top:14px;
  padding:12px;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:16px;
  box-shadow:0 8px 24px rgba(15,23,42,.05);
}

.mm-canvas-top{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin-bottom:10px;
  font-weight:900;
  color:#0f172a;
}

#mmCanvas,
#mmGGCanvas,
#mmProbaCanvas,
.mm-auto-graph-canvas{
  width:100%;
  max-width:100%;
  display:block;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:12px;
}

.mm-auto-graph-block{
  max-width:760px;
  margin:14px auto;
}

/* ===== Tools modal ===== */
.mm-tools-backdrop{
  position:fixed;
  inset:0;
  z-index:9998;
  background:rgba(15,23,42,.48);
  backdrop-filter:blur(4px);
  display:none;
  padding:16px;
  box-sizing:border-box;
}

.mm-tools-backdrop.open{
  display:block;
}

.mm-tools{
  width:min(1180px, 100%);
  height:min(88vh, 920px);
  margin:0 auto;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:22px;
  box-shadow:0 28px 80px rgba(15,23,42,.24);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.mm-tools-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:14px 16px;
  border-bottom:1px solid #e5e7eb;
  background:#f8fafc;
}

.mm-tools-head-left{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
}

.mm-tools-x{
  width:42px;
  height:42px;
  border:none;
  border-radius:12px;
  background:#111827;
  color:#fff;
  font-size:18px;
  font-weight:900;
  cursor:pointer;
}

.mm-tools-body{
  flex:1;
  min-height:0;
  display:grid;
  grid-template-columns:280px 1fr;
}

.mm-tools-left{
  padding:14px;
  background:#f8fafc;
  border-right:1px solid #e5e7eb;
  overflow:auto;
}

.mm-tools-right{
  padding:16px;
  overflow:auto;
  background:#fff;
}

.mm-tool-btn{
  width:100%;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:12px 14px;
  margin-bottom:10px;
  border-radius:14px;
  border:1px solid #e5e7eb;
  background:#fff;
  color:#111827;
  font-weight:900;
  cursor:pointer;
  transition:.15s ease;
}

.mm-tool-btn:hover{
  background:#f8fafc;
  border-color:#cbd5e1;
}

.mm-tool-btn.active{
  background:#111827;
  color:#fff;
  border-color:#111827;
  box-shadow:0 10px 24px rgba(17,24,39,.18);
}

.mm-panel{
  display:block;
}

.mm-panel-title{
  margin:0 0 10px;
  color:#0f172a;
  font-size:1.15rem;
  font-weight:950;
}

/* ===== Bac blanc ===== */
.mm-bac-header{
  display:block;
  width:100%;
  max-width:1100px;
  margin:0 auto 14px;
  position:relative;
  z-index:30;
}

.mm-bac-header:empty{
  display:none;
}

.mm-bac-header .mm-result-box{
  display:block;
  width:100%;
  margin:0 0 12px;
  background:linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border:1px solid #dbeafe;
  border-radius:16px;
  padding:14px 16px;
  line-height:1.7;
  font-weight:800;
  color:#0f172a;
  box-sizing:border-box;
  box-shadow:0 10px 30px rgba(37,99,235,.08);
}

#mmBacHeader{
  min-height:1px;
  visibility:visible;
  opacity:1;
}

.mm-bac-parts-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:12px;
  margin-top:2px;
}

/* ===== Exam active mode ===== */
body.mm-exam-active{
  user-select:none;
}

body.mm-exam-active .mm-tools-backdrop{
  display:none !important;
}

body.mm-exam-active #mmOpenTools,
body.mm-exam-active #mmFocusBtn{
  opacity:.55;
  pointer-events:none;
}

/* ===== Responsive ===== */
@media (max-width:980px){
  .mm-tools-body{
    grid-template-columns:1fr;
  }

  .mm-tools-left{
    border-right:none;
    border-bottom:1px solid #e5e7eb;
    max-height:220px;
  }
}

@media (max-width:860px){
  .mm-row{
    flex-direction:column;
  }

  .mm-table{
    min-width:520px;
  }

  .mm-lesson-actions{
    width:100%;
  }
}

@media (max-width:700px){
  .mm-tools-backdrop{
    padding:10px;
  }

  .mm-tools{
    height:min(92vh, 980px);
    border-radius:18px;
  }

  .mm-tools-right,
  .mm-tools-left{
    padding:12px;
  }

  .mm-canvas-wrap{
    padding:10px;
  }
}

@media (max-width:600px){
  .mm-lesson-title{
    font-size:1.35rem;
  }

  .mm-content{
    padding:14px;
  }

  .mm-auto-block{
    padding:12px;
  }

  .mm-btn{
    width:100%;
  }

  .mm-lesson-actions .mm-btn,
  .mm-actions .mm-btn{
    width:100%;
  }

  .mm-mini{
    min-width:100%;
    width:100%;
  }

  #mmExamTimer{
    top:8px !important;
    right:8px !important;
    left:8px;
    width:auto;
    text-align:center;
  }
}
.mm-bac-subject-wrap{
  max-width:1100px;
  margin:0 auto 14px;
}

.mm-bac-block{
  margin-bottom:12px !important;
}

.mm-bac-block-title{
  font-size:1.05rem;
  font-weight:900;
  color:#0f172a;
  margin-bottom:10px;
}

.mm-bac-block-body{
  color:#111827;
  font-weight:700;
  line-height:1.7;
}

.mm-bac-block-body h1,
.mm-bac-block-body h2,
.mm-bac-block-body h3,
.mm-bac-block-body h4{
  margin:10px 0 8px;
  color:#0f172a;
}

.mm-bac-block-body p{
  margin:8px 0;
}

.mm-bac-block-body ul,
.mm-bac-block-body ol{
  margin:8px 0 8px 22px;
}

.mm-bac-block-body table{
  width:100%;
  border-collapse:collapse;
  margin-top:10px;
}

.mm-bac-block-body table th,
.mm-bac-block-body table td{
  border:1px solid #e5e7eb;
  padding:8px 10px;
}
.mm-btn.result{
  background:#16a34a;
  color:#fff;
  border-color:#16a34a;
}
.mm-btn.result:hover{
  background:#15803d;
}
