/* ══════════════════════════════════════════
   Discord AI Bots — Dashboard Styles
   Monochrome design system
   ══════════════════════════════════════════ */

:root {
  /* Monochrome palette */
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-surface: #161616;
  --bg-elevated: #1c1c1c;
  --bg-hover: #222222;
  --bg-active: #2a2a2a;

  --border-subtle: #1e1e1e;
  --border-default: #2a2a2a;
  --border-strong: #3a3a3a;

  --text-primary: #e8e8e8;
  --text-secondary: #999999;
  --text-muted: #666666;
  --text-faint: #444444;

  --accent: #ffffff;
  --accent-dim: rgba(255, 255, 255, 0.08);
  --accent-hover: rgba(255, 255, 255, 0.12);

  --success: #4ade80;
  --success-bg: rgba(74, 222, 128, 0.08);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.08);
  --warning: #fbbf24;

  /* Spacing */
  --sidebar-width: 260px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-normal: 200ms ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  display: flex;
}

/* ── Scrollbar ──────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ── Sidebar ────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.logo svg {
  opacity: 0.7;
}

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 4px 12px 8px;
  text-transform: uppercase;
}

/* ── Bot List ───────────────────────────── */
.bot-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bot-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.bot-entry:hover {
  background: var(--bg-hover);
}

.bot-entry.active {
  background: var(--bg-active);
}

.bot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-faint);
  transition: background var(--transition-normal);
}

.bot-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}

.bot-entry-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  transition: color var(--transition-fast);
}

.bot-entry.active .bot-entry-name {
  color: var(--text-primary);
}

.bot-entry-preset {
  font-size: 10px;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-surface);
  flex-shrink: 0;
}

/* ── New Bot Button ─────────────────────── */
.btn-new-bot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 12px 16px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.btn-new-bot:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* ── Main Area ──────────────────────────── */
.main {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-primary);
}

/* ── Empty State ────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
}

.empty-state svg {
  opacity: 0.2;
  margin-bottom: 8px;
}

.empty-state h2 {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 13px;
}

/* ── Bot Editor ─────────────────────────── */
.bot-editor {
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 40px 100px;
}

.bot-editor.hidden {
  display: none;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.editor-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-title h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.editor-status {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 100px;
  letter-spacing: 0.03em;
}

.editor-status.online {
  color: var(--success);
  background: var(--success-bg);
}

.editor-status.offline {
  color: var(--text-muted);
  background: var(--accent-dim);
}

.editor-actions {
  display: flex;
  gap: 8px;
}

/* ── Buttons ────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

.btn-primary:hover {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.3);
}

/* ── Tabs ───────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

/* ── Tab Content ────────────────────────── */
.tab-content {
  display: none;
  animation: fadeIn 200ms ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Form ───────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group.full {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

label .hint {
  color: var(--text-muted);
  font-weight: 400;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-hint a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.form-hint a:hover {
  color: var(--text-primary);
}

/* ── Token Input ────────────────────────── */
.token-input-wrap {
  display: flex;
  gap: 6px;
}

.token-input-wrap input {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* ── Info Card ──────────────────────────── */
.info-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 20px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.info-row:not(:last-child) {
  border-bottom: 1px solid var(--border-subtle);
}

.info-label {
  font-size: 12px;
  color: var(--text-muted);
}

.info-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Memories ───────────────────────────── */
.memories-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.memories-header p {
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
}

.memories-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.memory-guild {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.memory-user {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.memory-user:not(:last-child) {
  border-bottom: 1px solid var(--border-subtle);
}

.memory-username {
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 80px;
}

.memory-notes {
  color: var(--text-muted);
  line-height: 1.5;
}

.empty-memories {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: 13px;
}

/* ── Save Bar ───────────────────────────── */
.save-bar {
  position: fixed;
  bottom: -60px;
  left: var(--sidebar-width);
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 12px 40px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-default);
  transition: bottom 300ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.save-bar.visible {
  bottom: 0;
}

.save-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Toast Notifications ────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 300ms ease, toastOut 300ms ease 2.7s forwards;
  pointer-events: none;
}

.toast.success {
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--success);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ── Confirm Dialog ─────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 150ms ease;
}

.dialog {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.dialog h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.dialog p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Login Overlay ──────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.login-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.login-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 48px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
  min-width: 320px;
}

.login-box svg {
  color: var(--text-muted);
  margin-bottom: 4px;
}

.login-box h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-box input {
  width: 100%;
  padding: 10px 14px;
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.05em;
}

.login-btn {
  width: 100%;
  padding: 10px 20px !important;
  font-size: 14px !important;
}

.login-error {
  font-size: 12px;
  color: var(--danger);
  min-height: 16px;
  text-align: center;
}

/* ── Responsive ─────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 220px;
  }

  .bot-editor {
    padding: 20px 20px 100px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .save-bar {
    padding: 12px 20px;
  }
}
