/* StudyMate Interactive Learning Modules — shared styles
 * =====================================================
 *
 * Card shell + module shell + small UI primitives used across engines.
 * Designed to feel premium next to the existing AI chat bubble: rounded
 * corners, soft shadows, dark instrument surfaces, controlled width that
 * never overflows the chat container.
 */

.smint-card {
  --smint-bg: #ffffff;
  --smint-bg-elev: #f7f9fd;
  --smint-border: rgba(15, 23, 42, 0.08);
  --smint-text: #0f172a;
  --smint-text-soft: #475569;
  --smint-accent: #4f46e5;
  --smint-accent-soft: #eef2ff;
  --smint-success: #16a34a;
  --smint-warn: #f59e0b;
  --smint-error: #dc2626;
  --smint-display-bg: #0b1322;
  --smint-display-text: #4ade80;
  --smint-radius: 14px;
  --smint-shadow: 0 12px 28px -18px rgba(15, 23, 42, 0.35),
                  0 2px 6px -3px rgba(15, 23, 42, 0.15);

  margin-top: 12px;
  background: var(--smint-bg);
  color: var(--smint-text);
  border: 1px solid var(--smint-border);
  border-radius: var(--smint-radius);
  box-shadow: var(--smint-shadow);
  padding: 14px 16px;
  font-family: inherit;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.message.ai .smint-card {
  /* Slight inset so the card lives "inside" the AI bubble area */
  margin-left: 0;
  margin-right: 0;
}

.smint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.smint-header-l {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.smint-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--smint-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.smint-subject {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--smint-accent-soft);
  color: var(--smint-accent);
  text-transform: uppercase;
  flex-shrink: 0;
}
.smint-subject-physics  { background: #ede9fe; color: #6d28d9; }
.smint-subject-math     { background: #dbeafe; color: #1d4ed8; }
.smint-subject-chemistry{ background: #dcfce7; color: #15803d; }
.smint-subject-biology  { background: #fee2e2; color: #b91c1c; }

.smint-desc {
  font-size: 13px;
  color: var(--smint-text-soft);
  margin-bottom: 10px;
  line-height: 1.45;
}

.smint-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: var(--smint-accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 120ms ease, background 120ms ease;
  box-shadow: 0 6px 14px -8px rgba(79, 70, 229, 0.7);
}
.smint-open-btn:hover { background: #4338ca; transform: translateY(-1px); }
.smint-open-btn:active { transform: translateY(0); }
.smint-open-btn:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }

.smint-open-icon {
  font-size: 10px;
  line-height: 1;
}

.smint-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.smint-reset-btn,
.smint-collapse-btn {
  background: transparent;
  border: 1px solid var(--smint-border);
  color: var(--smint-text-soft);
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.smint-reset-btn:hover,
.smint-collapse-btn:hover {
  background: var(--smint-bg-elev);
  color: var(--smint-text);
  border-color: rgba(15, 23, 42, 0.18);
}

.smint-host {
  margin-top: 12px;
  background: var(--smint-bg-elev);
  border: 1px solid var(--smint-border);
  border-radius: 12px;
  padding: 14px;
  display: none;
  min-height: 60px;
  position: relative;
  overflow: auto;
}
.smint-card.smint-expanded .smint-host {
  display: block;
}
.smint-card.smint-collapsed .smint-host {
  display: none;
}

.smint-loading,
.smint-error {
  font-size: 13px;
  color: var(--smint-text-soft);
  padding: 14px 4px;
}
.smint-error {
  color: var(--smint-error);
}

/* ---------------------------------------------------------------------------
 * Re-usable module primitives — engines compose these instead of styling
 * from scratch.
 * ---------------------------------------------------------------------------
 */

.smint-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.smint-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.smint-label {
  font-size: 12px;
  color: var(--smint-text-soft);
  font-weight: 500;
}

.smint-pill-group {
  display: inline-flex;
  border: 1px solid var(--smint-border);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}
.smint-pill-group button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--smint-text-soft);
  cursor: pointer;
}
.smint-pill-group button.is-active {
  background: var(--smint-accent);
  color: #ffffff;
}

.smint-chip-btn {
  border: 1px solid var(--smint-border);
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--smint-text);
}
.smint-chip-btn:hover { background: var(--smint-bg-elev); }
.smint-chip-btn.is-active {
  background: var(--smint-accent);
  color: #fff;
  border-color: var(--smint-accent);
}

.smint-input,
.smint-select {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 9px;
  border: 1px solid var(--smint-border);
  border-radius: 8px;
  background: #fff;
  color: var(--smint-text);
  min-width: 0;
}
.smint-input:focus,
.smint-select:focus {
  outline: 2px solid #c7d2fe;
  outline-offset: 0;
  border-color: var(--smint-accent);
}

.smint-num {
  width: 80px;
}

.smint-button {
  border: 1px solid var(--smint-border);
  background: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--smint-text);
  cursor: pointer;
}
.smint-button:hover { background: var(--smint-bg-elev); }
.smint-button.is-primary {
  background: var(--smint-accent);
  border-color: var(--smint-accent);
  color: #fff;
}
.smint-button.is-primary:hover { background: #4338ca; }
.smint-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.smint-slider {
  width: 100%;
  accent-color: var(--smint-accent);
}

.smint-display {
  background: var(--smint-display-bg);
  color: var(--smint-display-text);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04),
              inset 0 12px 24px -16px rgba(255, 255, 255, 0.08);
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.35);
}

.smint-feedback {
  margin-top: 10px;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.4;
  display: none;
}
.smint-feedback.is-visible { display: block; }
.smint-feedback.is-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.smint-feedback.is-error {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.smint-feedback.is-info {
  background: #dbeafe;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
}
.smint-feedback.is-warn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* ---------------------------------------------------------------------------
 * Specific engine touches that benefit from being centralised here.
 * ---------------------------------------------------------------------------
 */

/* Graphing — fit function-plot SVG nicely into the host */
.smint-graph-host {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--smint-border);
  padding: 6px;
  overflow: hidden;
}
.smint-graph-host svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* Multimeter / Circuit — Konva canvas wrapper */
.smint-konva-host {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--smint-border);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  overflow: hidden;
}

/* Optics SVG */
.smint-optics-svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--smint-border);
}

/* Periodic-style atom tiles */
.smint-atom {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(180deg, #6366f1 0%, #4338ca 100%);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  box-shadow: 0 2px 6px -2px rgba(67, 56, 202, 0.5);
}
.smint-atom-H  { background: linear-gradient(180deg, #f87171 0%, #b91c1c 100%); }
.smint-atom-O  { background: linear-gradient(180deg, #60a5fa 0%, #1d4ed8 100%); }
.smint-atom-C  { background: linear-gradient(180deg, #64748b 0%, #334155 100%); }
.smint-atom-Na { background: linear-gradient(180deg, #fbbf24 0%, #b45309 100%); }
.smint-atom-Cl { background: linear-gradient(180deg, #34d399 0%, #047857 100%); }

.smint-atom.is-placed {
  cursor: grab;
}
.smint-atom.is-selected {
  outline: 3px solid #fde047;
  outline-offset: 2px;
}

.smint-workspace {
  position: relative;
  background:
    radial-gradient(circle at 20% 20%, #eef2ff 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, #dbeafe 0%, transparent 50%),
    #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  min-height: 220px;
  overflow: hidden;
  touch-action: none;
}

/* DNA */
.smint-dna {
  display: grid;
  gap: 6px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 15px;
}
.smint-dna-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.smint-dna-cell {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--smint-border);
  background: #fff;
  font-weight: 700;
  color: var(--smint-text);
}
.smint-dna-cell.is-slot {
  background: #f1f5f9;
  border-style: dashed;
  color: #94a3b8;
}
.smint-dna-cell.is-correct {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.smint-dna-cell.is-wrong {
  background: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
}
.smint-dna-base {
  cursor: grab;
}
.smint-dna-base-A { background: #fce7f3; color: #be185d; border-color: #fbcfe8; }
.smint-dna-base-T { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.smint-dna-base-C { background: #cffafe; color: #0e7490; border-color: #a5f3fc; }
.smint-dna-base-G { background: #ecfccb; color: #4d7c0f; border-color: #d9f99d; }

/* Cell diagram */
.smint-cell-svg {
  display: block;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--smint-border);
  background: #fff;
}
.smint-cell-label {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--smint-accent-soft);
  color: var(--smint-accent);
  font-weight: 600;
  font-size: 12px;
  margin: 4px;
  cursor: grab;
  user-select: none;
  border: 1px solid #c7d2fe;
  touch-action: none;
}
.smint-cell-label.is-correct {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
  cursor: default;
}

/* pH scale */
.smint-ph-bar {
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    #b91c1c 0%, #ef4444 14%, #f97316 28%, #fbbf24 42%,
    #84cc16 50%, #22c55e 58%, #06b6d4 72%, #3b82f6 86%, #1e3a8a 100%);
  position: relative;
  margin: 6px 0 14px;
}
.smint-ph-marker {
  position: absolute;
  top: -6px;
  width: 12px;
  height: 40px;
  background: #ffffff;
  border: 2px solid var(--smint-text);
  border-radius: 4px;
  transform: translateX(-50%);
}

/* Reaction balancer */
.smint-reaction {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 15px;
}
.smint-coeff {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.smint-coeff-val {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  font-weight: 700;
  color: var(--smint-accent);
}
.smint-coeff-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--smint-border);
  background: #fff;
  color: var(--smint-text);
  cursor: pointer;
  font-weight: 700;
}
.smint-coeff-btn:hover { background: var(--smint-bg-elev); }
.smint-balance-table {
  margin-top: 10px;
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}
.smint-balance-table th,
.smint-balance-table td {
  padding: 4px 8px;
  text-align: center;
  border: 1px solid var(--smint-border);
}
.smint-balance-table .is-balanced { background: #dcfce7; color: #166534; }
.smint-balance-table .is-unbalanced { background: #fef2f2; color: #b91c1c; }

@media (max-width: 540px) {
  .smint-card { padding: 12px; }
  .smint-title { font-size: 14px; }
  .smint-display { font-size: 18px; padding: 8px 10px; }
}
