/* ═══════════════════════════════════════════════════════════
   NIVA Botmaster — Shared Stylesheet
   Light theme · Sora font · Clean enterprise UI
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

:root {
  --white:        #ffffff;
  --off:          #f8f9fc;
  --off2:         #f1f3f8;
  --border:       #e4e7ef;
  --border2:      #d0d5e8;
  --black:        #0d0f1a;
  --dark:         #1a1d2e;
  --muted:        #6b7399;
  --muted2:       #9ba3c4;
  --accent:       #4f46e5;
  --accent2:      #6366f1;
  --accent-light: #eef2ff;
  --accent-mid:   #c7d2fe;
  --green:        #16a34a;
  --green-light:  #dcfce7;
  --amber:        #d97706;
  --amber-light:  #fef3c7;
  --red:          #dc2626;
  --red-light:    #fee2e2;
  --sidebar-w:    240px;
  --header-h:     60px;
  --radius:       10px;
  --radius-lg:    14px;
  --shadow:       0 1px 4px rgba(79,70,229,0.06), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.10);
  --transition:   all 0.18s ease;
}

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

html, body {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  background: var(--off);
  color: var(--dark);
  line-height: 1.6;
  height: 100%;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }

/* ══════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════ */
.bm-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.bm-sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.bm-sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.bm-logo-mark {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.bm-logo-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--dark);
  letter-spacing: .04em;
}

.bm-logo-text span {
  color: var(--accent);
}

.bm-bot-info {
  margin: 16px 14px 8px;
  background: var(--accent-light);
  border: 1px solid var(--accent-mid);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.bm-bot-info-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 3px;
}

.bm-bot-info-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bm-bot-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--green);
  margin-top: 3px;
  font-weight: 500;
}

.bm-bot-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.bm-nav {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
}

.bm-nav-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 10px 10px 6px;
}

.bm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.bm-nav-item i {
  font-size: 16px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.bm-nav-item:hover {
  background: var(--off);
  color: var(--dark);
}

.bm-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.bm-nav-item.active i {
  color: var(--accent);
}

.bm-nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.bm-sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.bm-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.bm-user-card:hover { background: var(--off); }

.bm-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bm-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.2;
}

.bm-user-role {
  font-size: 11px;
  color: var(--muted2);
}

.bm-user-card .bi-box-arrow-right {
  margin-left: auto;
  color: var(--muted2);
  font-size: 14px;
}

/* ── MAIN CONTENT ── */
.bm-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.bm-topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.bm-topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.bm-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.bm-icon-btn {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--off);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: var(--transition);
  position: relative;
  text-decoration: none;
}

.bm-icon-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent-mid);
}

.bm-icon-btn i { font-size: 16px; }

.bm-content {
  flex: 1;
  padding: 28px;
}

/* ══════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════ */
.bm-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.bm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.bm-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
}

.bm-card-sub {
  font-size: 12px;
  color: var(--muted2);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════════ */
.bm-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.bm-stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.bm-stat:hover {
  border-color: var(--accent-mid);
  box-shadow: var(--shadow-lg);
}

.bm-stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.bm-stat-icon.purple { background: var(--accent-light); color: var(--accent); }
.bm-stat-icon.green  { background: var(--green-light);  color: var(--green);  }
.bm-stat-icon.amber  { background: var(--amber-light);  color: var(--amber);  }
.bm-stat-icon.red    { background: var(--red-light);    color: var(--red);    }

.bm-stat-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
  font-family: 'DM Mono', monospace;
}

.bm-stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.bm-stat-change {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}

.bm-stat-change.up   { color: var(--green); }
.bm-stat-change.down { color: var(--red); }

/* ══════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════ */
.bm-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.bm-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

.bm-table thead tr {
  background: var(--off);
  border-bottom: 1px solid var(--border);
}

.bm-table th {
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  text-align: left;
  white-space: nowrap;
}

.bm-table td {
  padding: 13px 16px;
  font-size: 13px;
  color: var(--dark);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.bm-table tbody tr:last-child td { border-bottom: none; }

.bm-table tbody tr {
  transition: var(--transition);
}

.bm-table tbody tr:hover {
  background: var(--off);
}

/* ══════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════ */
.bm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.bm-badge-green  { background: var(--green-light);  color: #15803d; }
.bm-badge-amber  { background: var(--amber-light);  color: #92400e; }
.bm-badge-red    { background: var(--red-light);    color: #991b1b; }
.bm-badge-purple { background: var(--accent-light); color: var(--accent); }
.bm-badge-gray   { background: var(--off2);         color: var(--muted); }

/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */
.bm-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: 'Sora', sans-serif;
  text-decoration: none;
  white-space: nowrap;
}

.bm-btn-primary {
  background: var(--accent);
  color: white;
}

.bm-btn-primary:hover {
  background: #4338ca;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79,70,229,0.35);
}

.bm-btn-outline {
  background: transparent;
  color: var(--dark);
  border: 1px solid var(--border2);
}

.bm-btn-outline:hover {
  background: var(--off);
  border-color: var(--accent-mid);
}

.bm-btn-danger {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fca5a5;
}

.bm-btn-danger:hover {
  background: var(--red);
  color: white;
}

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

/* ══════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════ */
.bm-form-group {
  margin-bottom: 18px;
}

.bm-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 6px;
}

.bm-label span {
  color: var(--red);
  margin-left: 2px;
}

.bm-input, .bm-select, .bm-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Sora', sans-serif;
  color: var(--dark);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}

.bm-input:focus, .bm-select:focus, .bm-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.bm-input::placeholder, .bm-textarea::placeholder {
  color: var(--muted2);
}

.bm-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

.bm-form-hint {
  font-size: 11px;
  color: var(--muted2);
  margin-top: 5px;
}

/* ══════════════════════════════════════════════
   TOGGLE SWITCH
══════════════════════════════════════════════ */
.bm-toggle {
  position: relative;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.bm-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.bm-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border2);
  border-radius: 22px;
  cursor: pointer;
  transition: var(--transition);
}

.bm-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.bm-toggle input:checked + .bm-toggle-slider {
  background: var(--accent);
}

.bm-toggle input:checked + .bm-toggle-slider::before {
  transform: translateX(16px);
}

/* ══════════════════════════════════════════════
   PERSONA TAG
══════════════════════════════════════════════ */
.persona-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  border: 1px solid var(--accent-mid);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.persona-chip.default-chip {
  background: var(--green-light);
  border-color: #86efac;
  color: var(--green);
}

/* ══════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════ */
.bm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
  color: var(--muted2);
}

.bm-empty i {
  font-size: 40px;
  margin-bottom: 16px;
  color: var(--border2);
}

.bm-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.bm-empty-sub {
  font-size: 13px;
}

/* ══════════════════════════════════════════════
   SEARCH
══════════════════════════════════════════════ */
.bm-search-wrap {
  position: relative;
}

.bm-search-wrap i {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted2);
  font-size: 14px;
  pointer-events: none;
}

.bm-search-wrap .bm-input {
  padding-left: 34px;
}

/* ══════════════════════════════════════════════
   PAGE HEADER
══════════════════════════════════════════════ */
.bm-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.bm-page-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.2;
}

.bm-page-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════
   SECTION DIVIDER
══════════════════════════════════════════════ */
.bm-divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

/* ══════════════════════════════════════════════
   CHAT BUBBLES
══════════════════════════════════════════════ */
.chat-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.chat-row.user-row {
  flex-direction: row-reverse;
}

.chat-av {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-av.bot-av {
  background: var(--accent-light);
  color: var(--accent);
}

.chat-av.user-av {
  background: var(--accent);
  color: white;
  overflow: hidden;
}

.chat-bubble {
  max-width: 72%;
  min-width: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-bubble.bot-bubble {
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
  color: var(--dark);
}

.chat-bubble.user-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 3px;
}

.chat-meta {
  font-size: 10px;
  color: var(--muted2);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════════ */
.bm-pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
}

.bm-page-btn {
  width: 32px; height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: var(--transition);
}

.bm-page-btn:hover, .bm-page-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ══════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════ */
.bm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13,15,26,.45);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.bm-modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.bm-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform .2s ease;
}

.bm-modal-backdrop.open .bm-modal {
  transform: translateY(0);
}

.bm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.bm-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

.bm-modal-close {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--off);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: var(--transition);
}

.bm-modal-close:hover {
  background: var(--red-light);
  color: var(--red);
}

/* ══════════════════════════════════════════════
   ALERTS / TOAST
══════════════════════════════════════════════ */
.bm-toast-area {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bm-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  color: var(--dark);
  min-width: 260px;
  animation: slideIn .25s ease;
}

.bm-toast.success { border-left: 3px solid var(--green); }
.bm-toast.error   { border-left: 3px solid var(--red);   }
.bm-toast.info    { border-left: 3px solid var(--accent); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0);    }
}

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 900px) {
  .bm-sidebar { transform: translateX(-100%); }
  .bm-sidebar.open { transform: translateX(0); }
  .bm-main { margin-left: 0; }
  .bm-stat-grid { grid-template-columns: repeat(2, 1fr); }
}