/* ============================================================
   AI Simulation Trainer — shared CSS
   Loaded globally via _layout.html. Activated only on pages
   that render the _ai-simulator fragment + define
   window.aiSimulatorScenarios. See SCENARIOS_GUIDE.md.
   ============================================================ */

.aist-root {
  --aist-primary: #5a7d9a;
  --aist-primary-dark: #3d5a73;
  --aist-primary-light: #e8eef4;
  --aist-accent: #6b9a82;
  --aist-accent-dark: #4a7a62;
  --aist-accent-light: #e8f1ec;
  --aist-warm: #b8875a;
  --aist-warm-light: #f6ecdc;
  --aist-info: #4a90b8;
  --aist-info-light: #e6f1f7;
  --aist-success: #2E7D32;
  --aist-success-light: #e8f5e9;
  --aist-warning: #ed8936;
  --aist-warning-light: #fdf0e2;
  --aist-danger: #D32F2F;
  --aist-danger-light: #fdecea;
  --aist-text: #1a202c;
  --aist-text-muted: #4a5568;
  --aist-text-soft: #718096;
  --aist-border: #e2e8f0;
  --aist-shadow-sm: 0 1px 3px rgba(15,30,45,.06), 0 1px 2px rgba(15,30,45,.04);
  --aist-shadow-md: 0 4px 12px rgba(15,30,45,.08), 0 2px 4px rgba(15,30,45,.05);
  --aist-shadow-lg: 0 12px 32px rgba(15,30,45,.10), 0 4px 8px rgba(15,30,45,.06);
  --aist-radius: 10px;
  --aist-radius-lg: 16px;

  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid var(--aist-border);
  border-radius: var(--aist-radius-lg);
  padding: 0;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--aist-text);
  line-height: 1.5;
}
.aist-root *, .aist-root *::before, .aist-root *::after { box-sizing: border-box; }
.aist-root button { font-family: inherit; }

/* Banner */
.aist-banner {
  background: linear-gradient(135deg, #3d5a73 0%, #5a7d9a 50%, #6b9a82 100%);
  color: #fff;
  padding: 20px 24px;
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}
.aist-banner i.aist-bot {
  font-size: 32px; background: rgba(255,255,255,.2);
  width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center; flex-shrink: 0;
}
.aist-banner .aist-ttl { font-size: 1.25rem; font-weight: 800; font-family: 'Nunito', sans-serif; margin: 0; }
.aist-banner .aist-sub { font-size: 13px; opacity: .92; margin-top: 2px; }
.aist-banner .aist-live-dot {
  width: 8px; height: 8px; background: #4ade80; border-radius: 50%;
  display: inline-block; margin-right: 6px;
  box-shadow: 0 0 0 0 rgba(74,222,128,.6); animation: aistPulse 1.6s infinite;
}
@keyframes aistPulse {
  0% { box-shadow: 0 0 0 0 rgba(74,222,128,.6); }
  70% { box-shadow: 0 0 0 10px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

/* Scenario picker */
.aist-picker {
  padding: 22px 24px 6px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.aist-picker.single { grid-template-columns: 1fr; }
.aist-picker.triple { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 720px) {
  .aist-picker,
  .aist-picker.triple { grid-template-columns: 1fr; }
}
.aist-card {
  border: 2px solid var(--aist-border);
  border-radius: var(--aist-radius);
  padding: 16px;
  cursor: pointer;
  background: #fff;
  transition: all .18s;
  display: flex; align-items: center; gap: 14px;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.aist-card:hover {
  border-color: var(--aist-primary);
  transform: translateY(-2px);
  box-shadow: var(--aist-shadow-md);
}
.aist-card.active {
  border-color: var(--aist-primary);
  background: var(--aist-primary-light);
}
.aist-card-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 22px;
  background: var(--aist-primary-light); color: var(--aist-primary-dark);
}
.aist-card.accent .aist-card-icon { background: var(--aist-accent-light); color: var(--aist-accent-dark); }
.aist-card.danger .aist-card-icon { background: var(--aist-danger-light); color: var(--aist-danger); }
.aist-card.warm   .aist-card-icon { background: var(--aist-warm-light);   color: var(--aist-warm); }
.aist-card.info   .aist-card-icon { background: var(--aist-info-light);   color: var(--aist-info); }
.aist-card .aist-card-ttl { font-weight: 700; color: var(--aist-text); margin: 0; font-size: 15px; }
.aist-card .aist-card-sub { font-size: 12.5px; color: var(--aist-text-soft); margin-top: 2px; }

/* Stage */
.aist-stage {
  display: grid; grid-template-columns: 300px 1fr; gap: 24px;
  padding: 22px 24px 24px;
  align-items: flex-start;
}
@media (max-width: 820px) { .aist-stage { grid-template-columns: 1fr; } }

/* Phone */
.aist-phone-wrap { display: flex; justify-content: center; }
.aist-phone {
  background: #1a202c;
  border-radius: 32px;
  padding: 14px 10px 18px;
  box-shadow: var(--aist-shadow-lg);
  width: 280px;
}
.aist-notch {
  width: 90px; height: 6px; background: #3a4555; border-radius: 4px;
  margin: 0 auto 12px;
}
.aist-screen {
  background: #f8fafc;
  border-radius: 18px;
  overflow: hidden;
  min-height: 480px;
  display: flex; flex-direction: column;
  position: relative;
}
.aist-statusbar {
  display: flex; justify-content: space-between;
  padding: 8px 16px; font-size: 12px; font-weight: 600;
  color: var(--aist-text); background: #f1f5f9;
}
.aist-statusbar .right { display: inline-flex; gap: 6px; }
.aist-header {
  background: linear-gradient(135deg, var(--aist-primary), var(--aist-primary-dark));
  color: #fff; padding: 14px 16px 16px;
}
.aist-header.accent { background: linear-gradient(135deg, var(--aist-accent), var(--aist-accent-dark)); }
.aist-header.warm   { background: linear-gradient(135deg, var(--aist-warm),   #8a6240); }
.aist-header.danger { background: linear-gradient(135deg, var(--aist-danger), #9b1c1c); }
.aist-header.info   { background: linear-gradient(135deg, var(--aist-info),   #2c6f93); }
.aist-header .pretitle { font-size: 11px; opacity: .85; letter-spacing: .5px; text-transform: uppercase; }
.aist-header .title { font-size: 18px; font-weight: 800; margin: 2px 0; font-family: 'Nunito', sans-serif; }
.aist-header .sub { font-size: 12.5px; opacity: .92; }
.aist-mini-card {
  background: #fff; margin: 12px; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--aist-border);
  font-size: 13px;
}
.aist-row { display: flex; justify-content: space-between; padding: 4px 0; }
.aist-row .lbl { color: var(--aist-text-soft); font-size: 12px; }
.aist-row .val { color: var(--aist-text); font-weight: 600; font-size: 12.5px; }
.aist-pill {
  font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .3px;
  display: inline-block;
}
.aist-pill.gray  { background: #e2e8f0; color: #475569; }
.aist-pill.green { background: var(--aist-success-light); color: var(--aist-success); }
.aist-pill.warn  { background: var(--aist-warning-light); color: var(--aist-warning); }
.aist-pill.red   { background: var(--aist-danger-light);  color: var(--aist-danger); }
.aist-pill.blue  { background: var(--aist-info-light);    color: var(--aist-info); }
.aist-btn {
  margin: 6px 12px; padding: 11px 12px;
  border-radius: 10px; text-align: center;
  font-size: 13.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: default;
}
.aist-btn.primary  { background: var(--aist-primary);  color: #fff; }
.aist-btn.success  { background: var(--aist-success);  color: #fff; }
.aist-btn.danger   { background: var(--aist-danger);   color: #fff; }
.aist-btn.gray     { background: #e2e8f0;              color: #475569; }
.aist-btn.warm     { background: var(--aist-warm);     color: #fff; }
.aist-btn.info     { background: var(--aist-info);     color: #fff; }
.aist-btn.disabled { background: #cbd5e1;              color: #94a3b8; }
.aist-btn.outline  { background: #fff; color: var(--aist-primary); border: 1.5px solid var(--aist-primary); }
.aist-tabbar {
  display: flex; justify-content: space-around;
  padding: 10px 0; border-top: 1px solid #e2e8f0;
  background: #fff;
}
.aist-tabbar i { color: #94a3b8; font-size: 18px; }
.aist-tabbar i.active { color: var(--aist-primary); }

/* Toast */
.aist-toast {
  position: absolute; left: 12px; right: 12px; top: 60px;
  padding: 12px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  animation: aistToastIn .3s ease-out;
  z-index: 10;
}
@keyframes aistToastIn {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.aist-toast.success { background: var(--aist-success); color: #fff; }
.aist-toast.error   { background: var(--aist-danger);  color: #fff; }
.aist-toast.warn    { background: var(--aist-warning); color: #fff; }
.aist-toast.info    { background: var(--aist-info);    color: #fff; }

/* Modal */
.aist-modal {
  position: absolute; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 11;
  animation: aistToastIn .25s ease-out;
}
.aist-modal-box {
  background: #fff; border-radius: 14px; padding: 16px;
  width: 100%; max-width: 240px; text-align: center;
}
.aist-modal-box i.aist-modal-icon { font-size: 32px; color: var(--aist-primary); display: block; margin-bottom: 8px; }
.aist-modal-box i.aist-modal-icon.success { color: var(--aist-success); }
.aist-modal-box i.aist-modal-icon.danger  { color: var(--aist-danger); }
.aist-modal-box i.aist-modal-icon.warm    { color: var(--aist-warm); }
.aist-modal-box i.aist-modal-icon.warning { color: var(--aist-warning); }
.aist-modal-box .aist-modal-ttl { font-weight: 800; font-size: 15px; margin-bottom: 6px; font-family: 'Nunito', sans-serif; color: var(--aist-text); }
.aist-modal-box .aist-modal-msg { font-size: 12.5px; color: var(--aist-text-muted); margin-bottom: 12px; line-height: 1.45; }
.aist-modal-box .aist-btn-row { display: flex; gap: 8px; }
.aist-modal-box .aist-btn-row .aist-btn { margin: 0; flex: 1; }

/* Spinner / locating */
.aist-spin {
  width: 36px; height: 36px;
  border: 4px solid #e2e8f0; border-top-color: var(--aist-primary);
  border-radius: 50%; animation: aistSpin 1s linear infinite;
  margin: 28px auto 16px;
}
@keyframes aistSpin { to { transform: rotate(360deg); } }
.aist-locating {
  background: var(--aist-info-light); padding: 18px 16px; margin: 12px;
  border-radius: 12px; text-align: center; color: var(--aist-info);
}
.aist-locating .aist-spin { margin-top: 0; }
.aist-locating .aist-loc-ttl { font-weight: 700; font-size: 14px; color: var(--aist-info); }
.aist-locating .aist-loc-sub { font-size: 12px; opacity: .8; margin-top: 3px; }

/* Camera + photo */
.aist-camera {
  margin: 12px; height: 200px;
  background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
  border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #94a3b8; gap: 10px;
  cursor: pointer; position: relative; overflow: hidden;
}
.aist-camera i { font-size: 48px; }
.aist-camera .lbl { font-size: 12px; }
.aist-photo {
  margin: 12px; height: 200px;
  background:
    radial-gradient(circle at 50% 38%, #f6d2b9 26%, transparent 27%),
    radial-gradient(circle at 50% 70%, #3d5a73 30%, transparent 31%),
    linear-gradient(135deg, #c5d3e0 0%, #e2e8f0 100%);
  border-radius: 14px;
  position: relative;
}
.aist-photo::after {
  content: 'CAPTURED'; position: absolute; top: 8px; right: 8px;
  font-size: 9px; font-weight: 700; letter-spacing: .5px;
  background: rgba(0,0,0,.55); color: #fff;
  padding: 3px 7px; border-radius: 4px;
}

/* Upload bar */
.aist-upload {
  height: 4px; background: #e2e8f0; border-radius: 4px;
  margin: 0 12px 8px; overflow: hidden;
}
.aist-upload span {
  display: block; height: 100%; background: linear-gradient(90deg, var(--aist-primary), var(--aist-accent));
  width: 0%; animation: aistUpload 2.4s ease-out forwards;
}
.aist-upload.weak span {
  animation: aistUploadWeak 6s ease-out forwards;
  background: linear-gradient(90deg, var(--aist-warning), #c89039);
}
@keyframes aistUpload     { to { width: 100%; } }
@keyframes aistUploadWeak { 0% { width: 0; } 60% { width: 38%; } 100% { width: 38%; } }

/* Big check (success state) */
.aist-big-check {
  width: 80px; height: 80px; margin: 28px auto 12px;
  border-radius: 50%; background: var(--aist-success-light);
  display: grid; place-items: center;
  animation: aistPopIn .35s cubic-bezier(.4,2,.6,1);
}
.aist-big-check i { font-size: 44px; color: var(--aist-success); }
.aist-big-check.warn  { background: var(--aist-warning-light); }
.aist-big-check.warn i { color: var(--aist-warning); }
.aist-big-check.danger { background: var(--aist-danger-light); }
.aist-big-check.danger i { color: var(--aist-danger); }
@keyframes aistPopIn {
  from { transform: scale(.4); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Empty-state generic body */
.aist-body {
  flex: 1; padding: 20px 16px;
  font-size: 13px; color: var(--aist-text-muted);
}
.aist-body .lead {
  font-weight: 700; color: var(--aist-text); font-size: 14px; margin-bottom: 8px;
}

/* Trainer panel */
.aist-panel {
  background: #fff; border: 1px solid var(--aist-border);
  border-radius: var(--aist-radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 480px;
}
.aist-block { padding: 10px 12px; border-radius: 8px; font-size: 13.5px; }
.aist-block .lbl {
  font-size: 10.5px; font-weight: 800; letter-spacing: .8px;
  text-transform: uppercase; margin-bottom: 4px; opacity: .85;
}
.aist-block .txt { line-height: 1.5; color: var(--aist-text); }
.aist-block.screen     { background: var(--aist-primary-light); color: var(--aist-primary-dark); }
.aist-block.screen .txt { color: var(--aist-primary-dark); font-weight: 700; }
.aist-block.system     { background: var(--aist-info-light);    border-left: 3px solid var(--aist-info); }
.aist-block.system     .lbl { color: var(--aist-info); }
.aist-block.response   { background: var(--aist-accent-light);  border-left: 3px solid var(--aist-accent-dark); }
.aist-block.response   .lbl { color: var(--aist-accent-dark); }
.aist-block.validation { background: #f5f3ff;                   border-left: 3px solid #7c3aed; }
.aist-block.validation .lbl { color: #7c3aed; }
.aist-block.error      { background: var(--aist-danger-light);  border-left: 3px solid var(--aist-danger); }
.aist-block.error      .lbl { color: var(--aist-danger); }
.aist-block.correction { background: var(--aist-warning-light); border-left: 3px solid var(--aist-warning); }
.aist-block.correction .lbl { color: #b56b1e; }
.aist-block.completion { background: var(--aist-success-light); border-left: 3px solid var(--aist-success); }
.aist-block.completion .lbl { color: var(--aist-success); }
.aist-block.info       { background: var(--aist-primary-light); border-left: 3px solid var(--aist-primary); }
.aist-block.info       .lbl { color: var(--aist-primary-dark); }

/* Action buttons */
.aist-actions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: auto;
}
.aist-action {
  padding: 12px 14px; border-radius: 10px;
  font-size: 13.5px; font-weight: 700;
  border: 0; cursor: pointer; text-align: left;
  transition: all .15s;
  display: flex; align-items: center; gap: 10px;
  font-family: inherit;
}
.aist-action i { font-size: 16px; }
.aist-action.primary { background: var(--aist-primary); color: #fff; }
.aist-action.primary:hover { background: var(--aist-primary-dark); }
.aist-action.success { background: var(--aist-success); color: #fff; }
.aist-action.success:hover { filter: brightness(1.08); }
.aist-action.danger  { background: var(--aist-danger);  color: #fff; }
.aist-action.danger:hover { filter: brightness(1.08); }
.aist-action.warm    { background: var(--aist-warm);    color: #fff; }
.aist-action.warm:hover { filter: brightness(1.08); }
.aist-action.info    { background: var(--aist-info);    color: #fff; }
.aist-action.info:hover { filter: brightness(1.08); }
.aist-action.outline { background: #fff; color: var(--aist-text-muted); border: 1.5px solid var(--aist-border); }
.aist-action.outline:hover { border-color: var(--aist-primary); color: var(--aist-primary); background: var(--aist-primary-light); }
.aist-action.wrong   { background: #fff; color: var(--aist-danger); border: 1.5px dashed var(--aist-danger); }
.aist-action.wrong:hover { background: var(--aist-danger-light); }

/* Progress */
.aist-progress-label {
  font-size: 11px; color: var(--aist-text-soft); font-weight: 700; letter-spacing: .5px; margin-top: auto;
}
.aist-progress {
  display: flex; gap: 4px; margin-top: 6px;
}
.aist-progress span {
  flex: 1; height: 5px; border-radius: 3px;
  background: #e2e8f0;
}
.aist-progress span.done   { background: var(--aist-success); }
.aist-progress span.active { background: var(--aist-primary); }

/* Footer */
.aist-footer {
  padding: 14px 24px 20px;
  border-top: 1px solid var(--aist-border);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
  background: #fafbfc;
  font-size: 12.5px; color: var(--aist-text-soft);
}
.aist-footer .badges { display: flex; gap: 8px; flex-wrap: wrap; }
.aist-footer .badge {
  background: #fff; border: 1px solid var(--aist-border);
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: var(--aist-text-muted);
  display: inline-flex; align-items: center; gap: 5px;
}
.aist-footer .badge i { font-size: 12px; color: var(--aist-primary); }
.aist-restart {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3);
  padding: 7px 14px; border-radius: 8px;
  font-weight: 700; font-size: 12.5px;
  cursor: pointer; color: #fff;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
}
.aist-restart:hover { background: rgba(255,255,255,.25); }

/* Print: hide simulator (it's interactive, not useful on paper) */
@media print {
  .aist-root { display: none !important; }
}
