/* circuit-study.css — shared styles for the admin-only Estudio sidebar tab. */

#study-panel {
  background: rgba(15, 17, 23, 0.98);
}

#study-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.study-panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  color: #d9dde5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.study-summary {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: #eef1f6;
  overflow-wrap: anywhere;
}

.study-summary-title {
  font-size: 14px;
  line-height: 1.25;
  font-weight: 720;
  color: #fff;
}

.study-summary-meta {
  margin-top: 3px;
  color: #b8c0cc;
}

.study-summary-hint {
  margin-top: 5px;
  color: #8bc7ff;
  font-size: 11px;
}

.study-summary[data-mode="pin"] {
  border-color: rgba(112, 187, 255, .38);
  background: rgba(48, 126, 210, .12);
}

.study-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.study-level-select {
  width: 100%;
  min-height: 30px;
  box-sizing: border-box;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.045);
  border-radius: 6px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #d9dde5;
}

.study-level-select span {
  color: #8d96a5;
  font-weight: 650;
}

.study-level-select select {
  min-width: 150px;
  margin-left: auto;
  border: 0;
  outline: 0;
  border-radius: 5px;
  background: rgba(8, 10, 16, .78);
  color: #eef1f6;
  font: 12px/1 inherit;
  padding: 5px 8px;
}

.study-level-select select:focus {
  box-shadow: 0 0 0 1px rgba(112, 187, 255, .55);
}

.study-preflight {
  min-height: 18px;
  font-size: 11px;
  line-height: 1.35;
  color: #a8acb5;
  overflow-wrap: anywhere;
}

.study-preflight:empty {
  display: none;
}

.study-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.study-actions button {
  min-height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  color: #d9dde5;
  font: 12px/1 inherit;
  cursor: pointer;
  padding: 0 10px;
}

.study-actions button:hover:not(:disabled) {
  background: rgba(255,255,255,.14);
  color: #fff;
}

.study-actions button:disabled {
  opacity: .45;
  cursor: default;
}

.study-run {
  border-color: rgba(211,32,39,.45) !important;
  background: rgba(211,32,39,.18) !important;
  color: #ffb6b9 !important;
}

.study-status {
  min-height: 18px;
  font-size: 12px;
  line-height: 1.35;
  color: #9da5b4;
  overflow-wrap: anywhere;
}

.study-status[data-kind="busy"] { color: #e8a44a; }
.study-status[data-kind="ok"] { color: #7dd38a; }
.study-status[data-kind="warn"] { color: #e8a44a; }
.study-status[data-kind="error"] { color: #f87171; }

.study-status:empty {
  display: none;
}

.study-chat {
  flex: 1;
  min-height: 300px;
  border: 1px solid rgba(112, 187, 255, .24);
  background: rgba(8, 10, 16, .58);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.study-stage {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 34px;
  padding: 0 8px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  background: rgba(18, 29, 43, .94);
  color: #cfe6ff;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 650;
}

.study-stage [data-study-stage-text] {
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.study-stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(148, 163, 184, .75);
}

.study-stage[data-kind="active"] .study-stage-dot {
  background: #70bbff;
  box-shadow: 0 0 0 0 rgba(112, 187, 255, .55);
  animation: studyPulse 1.15s ease-out infinite;
}

.study-stage[data-kind="done"] .study-stage-dot {
  background: #7dd38a;
}

.study-stage[data-kind="warn"] .study-stage-dot {
  background: #e8a44a;
}

.study-stage[data-kind="error"] {
  color: #fca5a5;
}

.study-stage[data-kind="error"] .study-stage-dot {
  background: #f87171;
}

.study-stage button {
  min-height: 24px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  color: #d9dde5;
  font: 11px/1 inherit;
  cursor: pointer;
  padding: 0 8px;
}

.study-stage button:hover:not(:disabled) {
  background: rgba(255,255,255,.14);
  color: #fff;
}

.study-stage button:disabled {
  opacity: .45;
  cursor: default;
}

.study-chat-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.study-chat-message {
  max-width: 100%;
  color: #e6e7ea;
  font: 12px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-wrap: anywhere;
}

.study-chat-message p {
  margin: 0 0 10px;
}

.study-chat-message p:last-child,
.study-chat-message ul:last-child,
.study-chat-message ol:last-child {
  margin-bottom: 0;
}

.study-chat-message h3,
.study-chat-message h4,
.study-chat-message h5,
.study-chat-message h6 {
  margin: 14px 0 7px;
  color: #f2f6fb;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0;
}

.study-chat-message h3:first-child,
.study-chat-message h4:first-child {
  margin-top: 0;
}

.study-chat-message ul,
.study-chat-message ol {
  margin: 0 0 10px 18px;
  padding: 0;
}

.study-chat-message li {
  margin: 4px 0;
}

.study-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 10px 0 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  background: rgba(255,255,255,.025);
}

.study-chat-message table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.35;
}

.study-chat-message th,
.study-chat-message td {
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding: 6px 8px;
  vertical-align: top;
  text-align: left;
}

.study-chat-message th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(24,29,38,.96);
  color: #f2f6fb;
  font-weight: 700;
}

.study-chat-message tr:last-child td {
  border-bottom: 0;
}

.study-chat-message strong {
  color: #fff;
  font-weight: 720;
}

.study-chat-message a {
  color: #8bc7ff;
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 199, 255, .45);
}

.study-chat-message a:hover {
  color: #cfe6ff;
  border-bottom-color: #cfe6ff;
}

.study-nav-token {
  display: inline;
  border: 1px solid rgba(139, 199, 255, .32);
  border-radius: 4px;
  background: rgba(45, 116, 185, .13);
  color: #bfe2ff;
  font: inherit;
  font-weight: 650;
  line-height: inherit;
  padding: 0 3px;
  margin: 0 1px;
  cursor: pointer;
  vertical-align: baseline;
}

.study-nav-token:hover {
  background: rgba(45, 116, 185, .26);
  border-color: rgba(139, 199, 255, .58);
  color: #fff;
}

.study-nav-token:focus-visible {
  outline: 1px solid rgba(139, 199, 255, .8);
  outline-offset: 1px;
}

.study-chat-message code {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 4px;
  background: rgba(255,255,255,.07);
  padding: 1px 4px;
  color: #f6d58f;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.study-code-block {
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid rgba(139,199,255,.16);
  border-radius: 6px;
  background: rgba(3, 6, 12, .72);
  color: #e8edf5;
  white-space: pre;
  overflow-wrap: normal;
  tab-size: 2;
  -webkit-overflow-scrolling: touch;
}

.study-code-block code {
  display: block;
  min-width: max-content;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre;
  overflow-wrap: normal;
}

.study-code-diagram {
  border-color: rgba(112,187,255,.24);
  background: rgba(5, 10, 18, .86);
}

.study-chat-message.is-typing::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 1px;
  background: #cfe6ff;
  animation: studyCaret .9s steps(2, start) infinite;
}

.study-chat-message.is-waiting {
  color: #b9c5d6;
}

.study-chat-message.is-waiting::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #70bbff;
  box-shadow: 0 0 0 0 rgba(112, 187, 255, .45);
  animation: studyPulse 1.2s ease-out infinite;
}

.study-muted {
  color: #7d8490;
}

@keyframes studyPulse {
  0% { box-shadow: 0 0 0 0 rgba(112, 187, 255, .52); }
  70% { box-shadow: 0 0 0 7px rgba(112, 187, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(112, 187, 255, 0); }
}

@keyframes studyCaret {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .study-stage[data-kind="active"] .study-stage-dot,
  .study-chat-message.is-waiting::before,
  .study-chat-message.is-typing::after {
    animation: none;
  }
}
