﻿/*
 * AI Studio layout, panels, controls, and chat topbar.
 * Extracted from public/styles.css lines 2068-2749.
 */

/* =========================
   MULTI-AI PAGE
========================= */

.mai-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.mai-runtime-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  overflow-y: auto;
  padding: 22px;
  background: #191512;
  color: #d8cbb8;
}

.mai-runtime-heading {
  border-bottom: 1px solid rgba(231, 199, 143, 0.14);
  padding-bottom: 14px;
}

.mai-runtime-eyebrow {
  display: block;
  margin-bottom: 8px;
  color: #b47a3a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.mai-runtime-heading h3 {
  margin: 0 0 6px;
  color: #fff2dc;
  font-size: 22px;
}

.mai-runtime-heading p {
  margin: 0;
  color: #a99b88;
  font-size: 13px;
  line-height: 1.45;
}

.mai-runtime-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(231, 199, 143, 0.15);
  border-radius: 16px;
  background: rgba(38, 31, 26, 0.68);
}

.mai-runtime-card-title {
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mai-runtime-card label,
.mai-runtime-row span {
  color: #b9aa96;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mai-runtime-card select {
  min-height: 38px;
  width: 100%;
  border: 1px solid rgba(231, 199, 143, 0.18);
  border-radius: 12px;
  background: rgba(25, 21, 18, 0.9);
  color: #f2debd;
  padding: 8px 10px;
  font-size: 13px;
}

.mai-runtime-card select:focus {
  outline: none;
  border-color: rgba(231, 199, 143, 0.55);
  box-shadow: 0 0 0 3px rgba(231, 199, 143, 0.08);
}

.mai-runtime-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mai-runtime-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.mai-runtime-check input {
  width: 16px;
  height: 16px;
  accent-color: #9a6c27;
}

/* â”€â”€ Global controls bar (Rounds / Mode / Context) â”€â”€ */

.mai-global-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 9px 14px;
}

.mai-ctrl-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.mai-ctrl-group-stacked {
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.mai-ctrl-label-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.mai-ctrl-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4b5563;
  flex-shrink: 0;
}

.mai-ctrl-btns {
  display: flex;
  gap: 4px;
}

.mai-ctrl-divider {
  width: 1px;
  height: 18px;
  background: #1f2937;
  flex-shrink: 0;
}

.mai-ctrl-input {
  width: 52px;
  padding: 4px 7px;
  background: #2a2f38;
  border: 1px solid #374151;
  border-radius: 5px;
  color: #eee;
  font-size: 12px;
  text-align: center;
}

/* â”€â”€ Keep legacy classes (used in settings.js) â”€â”€ */

.mai-bot-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mai-bot-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.mai-color-a { color: #93c5fd; }
.mai-color-b { color: #86efac; }

.mai-bot-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mai-bot-row select {
  background: #2a2f38;
  color: #eee;
  border: 1px solid #374151;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
  width: 175px;
}

.mai-rounds-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mai-rounds-group label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7280;
}

.mai-rounds-group input {
  width: 58px;
  padding: 5px 8px;
  background: #2a2f38;
  border: 1px solid #374151;
  border-radius: 5px;
  color: #eee;
  font-size: 12px;
}

.mai-instruction-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #1f2937;
}

.mai-instruction-row input[type="text"] {
  flex: 1;
  padding: 5px 10px;
  background: #2a2f38;
  border: 1px solid #374151;
  border-radius: 5px;
  color: #eee;
  font-size: 12px;
}

.mai-instruction-row input[type="text"]::placeholder {
  color: #4b5563;
}

/* â”€â”€ Session bar â”€â”€ */

.mai-session-bar {
  flex-shrink: 0;
  padding: 5px 16px;
  font-size: 11px;
  color: #4b5563;
  border-bottom: 1px solid #161a22;
  background: #0a0c10;
  letter-spacing: 0.02em;
}

/* â”€â”€ Chat area â”€â”€ */

.mai-chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

.mai-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: #4b5563;
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
}

.mai-empty strong {
  color: #e2c38d;
  font-size: 15px;
}

.mai-thinking-state {
  gap: 2px;
  color: #b9aa96;
}

.mai-thinking-name {
  color: #e2c38d;
  font-weight: 700;
}

.mai-thinking-dots::after {
  content: "...";
  display: inline-block;
  width: 1.4em;
  overflow: hidden;
  vertical-align: bottom;
  animation: mai-thinking-dots 1.15s steps(4, end) infinite;
}

@keyframes mai-thinking-dots {
  0% { width: 0; }
  100% { width: 1.4em; }
}

/* â”€â”€ Message rows â”€â”€ */

.mai-msg {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  margin-bottom: 10px;
}

.mai-msg-a {
  align-self: flex-start;
}

.mai-msg-b {
  align-self: flex-end;
  align-items: flex-end;
}

.mai-msg-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.025em;
  margin-bottom: 4px;
  padding: 0 4px;
}

.mai-msg-a .mai-msg-label { color: #93c5fd; }
.mai-msg-b .mai-msg-label { color: #86efac; }

/* â”€â”€ Bubbles â”€â”€ */

.mai-bubble {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e5e7eb;
  border-radius: 14px;
}

.mai-bubble-streaming:empty::after {
  content: attr(data-placeholder);
  display: inline-block;
  max-width: 100%;
  border-radius: 999px;
  color: #b9aa96;
  opacity: 0.8;
  animation: typing-pulse 1.2s ease-in-out infinite;
}

.mai-msg-a .mai-bubble {
  background: #152238;
  border-bottom-left-radius: 4px;
}

.mai-msg-b .mai-bubble {
  background: #112419;
  border-bottom-right-radius: 4px;
}

.mai-mode-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: #94a3b8;
}

.mai-mode-btn {
  background: #2a2f38;
  border: 1px solid #374151;
  color: #94a3b8;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.mai-mode-btn.mai-mode-active {
  background: #1e40af;
  border-color: #3b82f6;
  color: #fff;
}

.mai-input-area {
  flex-shrink: 0;
  padding: 10px 16px 10px;
  border-top: 1px solid rgba(148, 116, 65, 0.16);
  background:
    linear-gradient(180deg, rgba(18, 15, 12, 0.92) 0%, rgba(12, 14, 18, 0.98) 100%);
}

.mai-status {
  min-height: 0;
}

.mai-input-row {
  display: flex;
  gap: 6px;
}

.mai-env-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  max-width: 100%;
  margin-top: 7px;
  color: rgba(213, 200, 180, 0.62);
  font-size: 11px;
  line-height: 1.25;
  letter-spacing: 0.01em;
  user-select: none;
}

.mai-env-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;
  border: 1px solid rgba(212, 169, 98, 0.18);
  border-radius: 999px;
  background: rgba(212, 169, 98, 0.06);
  color: rgba(237, 217, 183, 0.75);
  font-weight: 700;
  white-space: nowrap;
}

.mai-env-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mai-env-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(213, 200, 180, 0.38);
  flex: 0 0 auto;
}

.mai-env-indicator:hover {
  color: rgba(235, 220, 195, 0.82);
}

.mai-env-indicator:hover .mai-env-pill {
  border-color: rgba(212, 169, 98, 0.32);
  background: rgba(212, 169, 98, 0.1);
  color: rgba(255, 231, 190, 0.9);
}

/* Alternate environment treatments kept intentionally lightweight:
   swap mai-env-footer for mai-env-pillbar or mai-env-inline in markup if desired. */
.mai-env-pillbar {
  gap: 6px;
}

.mai-env-pillbar .mai-env-text {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.05);
}

.mai-env-pillbar .mai-env-dot {
  display: none;
}

.mai-env-inline {
  margin-top: 5px;
  padding-left: 2px;
}

.mai-env-inline .mai-env-pill {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(237, 217, 183, 0.68);
}

.mai-input-row input[type="text"] {
  flex: 1;
  background: #1a1f28;
  border: 1px solid #374151;
  color: #e2e8f0;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.mai-input-row input[type="text"]:disabled { opacity: 0.4; }

.mai-input-row input[type="text"]::placeholder { color: #4b5563; }

.mai-input-row button {
  background: #1e40af;
  border: none;
  color: #fff;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.mai-input-row button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mai-msg-user { align-self: center; }

.mai-msg-user .mai-msg-label { color: #fbbf24; }

.mai-msg-user .mai-bubble {
  background: #2d2000;
  border-color: #78350f;
}

/* =========================
   CHAT TOPBAR
========================= */

#topbar-gear {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid #374151;
  color: #9ca3af;
  font-size: 14px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin: 0;
  line-height: 1;
  flex-shrink: 0;
}

#topbar-gear:hover {
  color: #e2e8f0;
  border-color: #6b7280;
  background: #161a22;
}

.mai-style-topbar {
  display: none;
}

.chat-style-topbar {
  display: flex;
  align-items: center;
  flex: 1 1 150px;
  min-width: 0;
}

.chat-style-select {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(231, 199, 143, 0.22);
  background: rgba(38, 31, 26, 0.95);
  color: #f2debd;
  font-size: 13px;
  line-height: 1.2;
}

.chat-style-select:focus {
  outline: none;
  border-color: rgba(231, 199, 143, 0.72);
  box-shadow: 0 0 0 3px rgba(231, 199, 143, 0.1);
}

#chat-headerbar.ai-lab-header .chat-style-topbar {
  display: none;
}

#chat-headerbar.ai-lab-header .mai-style-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  flex: 1 1 130px;
  min-width: 0;
}

#chat-headerbar.ai-lab-header #profile {
  flex: 0 0 92px;
  max-width: 110px;
}

#chat-headerbar.ai-lab-header .workspace-switcher {
  flex: 0 0 auto;
}

#chat-headerbar.ai-lab-header .workspace-switcher button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 11px;
}

#chat-headerbar.ai-lab-header .mai-style-select {
  min-width: 0;
  flex: 1 1 0;
  height: 36px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(231, 199, 143, 0.22);
  background: rgba(38, 31, 26, 0.95);
  color: #f2debd;
  font-size: 13px;
  line-height: 1.2;
}

#chat-headerbar.ai-lab-header .mai-style-select:focus {
  outline: none;
  border-color: rgba(231, 199, 143, 0.72);
  box-shadow: 0 0 0 3px rgba(231, 199, 143, 0.1);
}

/* Orchestration preset selector — second row of the AI Studio topbar */
#chat-headerbar.ai-lab-header .mai-orch-select {
  flex: 1 1 100%;
  min-width: 0;
  height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(231, 199, 143, 0.15);
  background: rgba(30, 24, 18, 0.7);
  color: #b8a890;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

#chat-headerbar.ai-lab-header .mai-orch-select:focus {
  outline: none;
  border-color: rgba(231, 199, 143, 0.45);
  box-shadow: 0 0 0 2px rgba(231, 199, 143, 0.08);
  color: #e7c78f;
}

#topbar-controls {
  display: none;
  flex-shrink: 0;
}

body.topbar-sheet-open #topbar-controls {
  display: grid;
  grid-template-columns: 120px 1fr;
  row-gap: 12px;
  column-gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid #1f2937;
  background: #0c0e12;
}

.topbar-provider-model {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 120px 1fr;
  row-gap: 10px;
  column-gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #2a2f3a;
  border-radius: 6px;
  background: #111317;
}

.topbar-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  white-space: nowrap;
}

#topbar-controls select {
  width: 100%;
  box-sizing: border-box;
  background: #161a22;
  color: #e2e8f0;
  border: 1px solid #2a2f3a;
  border-radius: 5px;
  font-size: 12px;
  padding: 5px 7px;
  cursor: pointer;
  margin: 0;
}

#topbar-controls select:focus {
  outline: none;
  border-color: #3b82f6;
}

#topbar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 699;
}

@keyframes topbar-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Compact inline Stop icon (inside Rounds control group) ────────────────── */

.mai-stop-ctrl-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 6px;
  font-size: 11px;
  line-height: 28px;
  text-align: center;
  border: 1px solid rgba(239, 68, 68, 0.42);
  background: rgba(127, 29, 29, 0.1);
  color: #fca5a5;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
}

.mai-stop-ctrl-btn:hover:not(:disabled) {
  border-color: rgba(239, 68, 68, 0.75);
  background: rgba(127, 29, 29, 0.22);
  color: #fecaca;
}

/* Idle — no session running */
.mai-stop-ctrl-btn:disabled:not(.is-stopping) {
  border-color: #2d3748;
  background: transparent;
  color: #374151;
  cursor: not-allowed;
  opacity: 0.55;
}

/* Stopping — stop requested, current bot still finishing */
.mai-stop-ctrl-btn.is-stopping {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(127, 29, 29, 0.06);
  color: rgba(252, 165, 165, 0.45);
  cursor: not-allowed;
  opacity: 0.7;
}

