/* Admin console overrides. Loaded AFTER styles.css so these rules win.
   The chat UI owns styles.css — admin-only styling lives here. */

/* 1. Layout: full-width on desktop and mobile — no width cap. The old
   1080px cap left 420px of empty space on each side at 1920px. The
   single-column grid (topbar / tabs / main) lives in styles.css
   (.admin-app); nothing to override here. */

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex: 0 0 auto;
  display: block;
}

/* 2. Tab row: 8 tabs, single row, horizontal scroll on narrow screens. */
.tabs {
  flex-wrap: nowrap;
  scrollbar-width: thin;
}

.tabs .mode-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* 3. Toasts: top-right, success + error, above everything. */
.toast-root {
  position: fixed;
  top: calc(12px + var(--safe-top, 0px));
  right: 12px;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.toast-ok {
  border-color: rgba(143, 191, 122, 0.55);
}

.toast-ok::before {
  content: "✓ ";
  color: var(--ok);
  font-weight: 700;
}

.toast-error {
  border-color: rgba(224, 106, 79, 0.6);
}

.toast-error::before {
  content: "✕ ";
  color: var(--danger);
  font-weight: 700;
}

/* 4. In-page confirm modal (native dialogs are never used). */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}

.confirm-card {
  width: min(420px, 100%);
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}

.confirm-card h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.confirm-actions .ghost-btn,
.confirm-actions .danger-btn {
  min-height: 44px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.confirm-actions .ghost-btn {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

.danger-btn {
  border: 0;
  background: var(--danger);
  color: #fff;
}

/* Chat detail delete button sits directly in the .stack (not in a .card). */
.stack > .danger-btn {
  min-height: 44px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

/* 5. Admin cards: danger buttons, badges, detail rows. */
.card .danger-btn {
  margin-top: 16px;
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.card .row .danger-btn {
  margin-top: 0;
}

.card button:disabled,
.card input:disabled,
.card select:disabled,
.card textarea:disabled {
  opacity: 0.55;
  cursor: wait;
}

.card .field-label {
  margin-top: 10px;
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.badge-muted {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
}

.agent-prompt {
  width: 100%;
  min-height: 132px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
}

/* Skills tab: tool checkboxes + enabled toggle row. */
.skill-tools {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}

.skill-tool {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.skill-tool input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.skill-enabled-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

.skill-enabled-label input {
  width: 20px;
  height: 20px;
}

/* Chat session detail: clickable list rows + message bubbles. */
.chat-row {
  width: 100%;
  text-align: left;
  cursor: pointer;
  padding: 16px;
}

.chat-row:hover {
  border-color: var(--accent);
}

.chat-msg {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.55;
}

.chat-msg-role {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-msg-user {
  background: var(--user);
}

.chat-msg-assistant {
  background: var(--bot);
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.detail-head h2 {
  margin: 0;
}

.detail-head .ghost-btn {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  flex: 0 0 auto;
}

.user-card h2 {
  overflow-wrap: anywhere;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
  align-items: end;
}

.password-row input {
  min-width: 0;
}

.password-row button {
  margin-top: 0;
  white-space: nowrap;
  padding-left: 14px;
  padding-right: 14px;
  width: auto;
}

.role-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
  align-items: end;
}

.role-row select {
  min-width: 0;
}

/* Picker custom trong hàng role-row (grid 1fr auto): wrapper chiếm cột
   của select cũ, co được như select (min-width: 0) để nút Lưu không
   bị đẩy; nút picker full-width như trong .card. */
.role-row .custom-picker {
  min-width: 0;
}

.role-row button {
  margin-top: 0;
  white-space: nowrap;
  padding-left: 14px;
  padding-right: 14px;
  width: auto;
}

/* Thinking budgets: 3 inputs in one row on desktop, stacked on mobile. */
.budget-row {
  grid-template-columns: repeat(3, 1fr);
}

.budget-row label {
  margin-top: 0;
}

.budget-row input {
  margin-top: 6px;
}

/* 6. Mobile: no horizontal overflow; tab row scrolls, rows stack. */
@media (max-width: 639px) {
  html,
  body {
    overflow-x: hidden;
  }

  .admin-app {
    width: 100%;
  }

  .tabs {
    padding-bottom: 4px;
  }

  .password-row,
  .role-row,
  .budget-row {
    grid-template-columns: 1fr;
  }

  .password-row button,
  .role-row button {
    width: 100%;
  }

  .confirm-actions {
    grid-template-columns: 1fr;
  }
}
