/* Admin: тестовый чат с агентом (тёмная тема, оранжевые акценты) */
.admin-agent-chat-mount {
  min-height: calc(100vh - 48px);
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 8px 24px;
}

.aag-disabled {
  padding: 24px;
  background: #1a1520;
  border: 1px solid #3d2a18;
  border-radius: 14px;
  color: #e8c49a;
  font-size: 14px;
  line-height: 1.5;
}

.aag-disabled code {
  background: #0d0d10;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fbbf24;
}

.aag-key-form {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
}

.aag-key-label {
  font-size: 13px;
  color: #e8dcc8;
}

.aag-key-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #3d2a18;
  background: #0d0d10;
  color: #f5f0e8;
  font-size: 14px;
  font-family: ui-monospace, monospace;
}

.aag-key-input:focus {
  outline: none;
  border-color: #e76332;
  box-shadow: 0 0 0 1px rgba(231, 99, 50, 0.35);
}

.aag-key-submit {
  align-self: flex-start;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(180deg, #e76332 0%, #c94e22 100%);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.aag-key-submit:hover {
  filter: brightness(1.06);
}

.aag-key-hint {
  margin-top: 12px;
  font-size: 12px;
  color: #9a8a78;
  max-width: 480px;
}

.aag-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  min-height: calc(100vh - 120px);
  background: #0c0c0f;
  border: 1px solid #252830;
  border-radius: 16px;
  overflow: hidden;
}

.aag-sidebar {
  background: #111116;
  border-right: 1px solid #252830;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.aag-new-chat {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #e76332;
  background: linear-gradient(180deg, #e76332 0%, #c94e22 100%);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.aag-new-chat:hover {
  filter: brightness(1.05);
}

.aag-chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  max-height: calc(100vh - 220px);
}

.aag-chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #c5c9d4;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
}

.aag-chat-item:hover,
.aag-chat-item.active {
  background: #1c1f28;
  border-color: #2a3142;
  color: #fff;
}

.aag-chat-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aag-chat-del {
  opacity: 0.5;
  padding: 0 4px;
  font-size: 16px;
  line-height: 1;
  border: none;
  background: none;
  color: #888;
  cursor: pointer;
}

.aag-chat-del:hover {
  color: #f87171;
  opacity: 1;
}

.aag-main {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  background: #0f0f12;
}

.aag-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.aag-hero-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #e76332, #f59e0b);
  color: #0c0c0f;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.aag-hero-title {
  font-size: 26px;
  font-weight: 700;
  color: #f4f4f5;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

.aag-hero-sub {
  font-size: 14px;
  color: #8b919d;
  max-width: 420px;
  margin: 0;
  line-height: 1.5;
}

.aag-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.aag-msg {
  max-width: 720px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
}

.aag-msg--user {
  align-self: flex-end;
  background: #1e2430;
  border: 1px solid #2f3545;
  color: #e8eaef;
}

.aag-msg--assistant {
  align-self: flex-start;
  background: #16161c;
  border: 1px solid #2a2d38;
  color: #d4d7de;
}

.aag-msg-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #e76332;
  margin-bottom: 8px;
  font-weight: 600;
}

.aag-msg-text {
  word-break: break-word;
}

.aag-composer-wrap {
  border-top: 1px solid #252830;
  padding: 0;
  background: #0c0c10;
}

.aag-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  font-size: 12px;
  color: #c4a574;
  background: linear-gradient(90deg, #1f1710, #1a1510);
  border-bottom: 1px solid #3d2f1a;
}

.aag-banner-x {
  border: none;
  background: none;
  color: #a89a82;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.aag-composer {
  padding: 12px 16px 16px;
}

.aag-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 88px;
  max-height: 240px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #2f3545;
  background: #14141a;
  color: #e8eaef;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.45;
}

.aag-input:focus {
  outline: none;
  border-color: #e7633288;
  box-shadow: 0 0 0 1px rgba(231, 99, 50, 0.25);
}

.aag-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.aag-toolbar-left,
.aag-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.aag-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #353945;
  background: #18181f;
  color: #b8bec9;
  font-size: 12px;
  cursor: pointer;
}

.aag-icon-btn:hover:not(:disabled) {
  border-color: #4a5568;
  color: #fff;
}

.aag-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.aag-lib-btn .aag-lib-ico {
  font-size: 14px;
}

.aag-pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #e76332;
  background: transparent;
  color: #e8c4a8;
  font-size: 12px;
  cursor: not-allowed;
  opacity: 0.7;
}

.aag-model-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.aag-model-spark {
  color: #fbbf24;
  font-size: 14px;
}

.aag-model {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #353945;
  background: #14141a;
  color: #e8eaef;
  font-size: 12px;
  min-width: 180px;
}

.aag-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, #e76332, #c94e22);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aag-send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.aag-send:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* Library overlay */
.aag-lib-overlay,
.aag-tpl-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.aag-lib-modal {
  width: min(920px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #121218;
  border: 1px solid #2f3545;
  border-radius: 16px;
  padding: 20px 22px;
}

.aag-lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.aag-lib-head h3 {
  margin: 0;
  font-size: 18px;
  color: #f4f4f5;
}

.aag-lib-close {
  border: none;
  background: #1f1f28;
  color: #9ca3af;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.aag-lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.aag-lib-card {
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #2a3142;
  background: #18181f;
  cursor: pointer;
  color: inherit;
}

.aag-lib-card:hover {
  border-color: #e7633266;
}

.aag-lib-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.aag-lib-runs {
  font-size: 11px;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.12);
  padding: 3px 8px;
  border-radius: 999px;
}

.aag-lib-pop {
  font-size: 10px;
  font-weight: 700;
  color: #fbbf24;
  border: 1px solid #fbbf2444;
  padding: 2px 6px;
  border-radius: 4px;
}

.aag-lib-card-title {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  margin-bottom: 6px;
}

.aag-lib-card-desc {
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.4;
}

/* Template detail */
.aag-tpl-modal {
  width: min(960px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #0f0f12;
  border: 1px solid #2f3545;
  border-radius: 16px;
  padding: 16px 20px 20px;
}

.aag-tpl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.aag-tpl-back {
  border: none;
  background: none;
  color: #e76332;
  font-size: 13px;
  cursor: pointer;
}

.aag-tpl-h4 {
  margin: 0 0 16px;
  font-size: 18px;
  color: #fff;
}

.aag-tpl-columns {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}

@media (max-width: 820px) {
  .aag-layout {
    grid-template-columns: 1fr;
  }
  .aag-sidebar {
    border-right: none;
    border-bottom: 1px solid #252830;
    max-height: 200px;
  }
  .aag-tpl-columns {
    grid-template-columns: 1fr;
  }
}

.aag-tpl-step {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.aag-tpl-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.aag-tpl-num--0 {
  background: #db2777;
}
.aag-tpl-num--1 {
  background: #0891b2;
}
.aag-tpl-num--2 {
  background: #7c3aed;
}

.aag-tpl-label {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 6px;
}

.aag-tpl-field {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #353945;
  background: #14141a;
  color: #e8eaef;
  font-size: 13px;
}

.aag-tpl-preview-h {
  font-size: 13px;
  color: #e8eaef;
  margin-bottom: 8px;
}

.aag-tpl-tip {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 400;
}

.aag-tpl-textarea {
  width: 100%;
  min-height: 220px;
  box-sizing: border-box;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #353945;
  background: #14141a;
  color: #e8eaef;
  font-size: 13px;
  line-height: 1.5;
  font-family: inherit;
}

.aag-tpl-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #252830;
}

.aag-tpl-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aag-run-prompt {
  padding: 12px 22px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, #e76332, #c94e22);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.aag-run-prompt:hover {
  filter: brightness(1.06);
}
