/* ═══════════════════════════════════════════════
   BotNest.ai Dashboard — Global Stylesheet
   ═══════════════════════════════════════════════ */

:root {
  --indigo:       #5b5ef4;
  --indigo-light: #eef0ff;
  --violet:       #7c3aed;
  --border:       #e8eaf2;
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --radius-card:  16px;
  --radius-input: 12px;
  --shadow-card:  0 1px 8px rgba(0,0,0,.04);
  --shadow-drop:  0 8px 30px rgba(0,0,0,.10);
}

/* ── Reset / Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { font-family: 'Tajawal', 'Plus Jakarta Sans', sans-serif; margin: 0; padding: 0; }
body { background: #f7f8fc; color: #1e293b; }
a { text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
[v-cloak] { display: none !important; }

/* ── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #dde2ef; border-radius: 99px; }

/* ══════════════════════════════════════════════════
   AUTH PAGES
═══════════════════════════════════════════════════ */
.auth-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f1ff 0%, #faf5ff 50%, #f0f9ff 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  background: #fff;
  border-radius: 24px;
  width: 100%;
  padding: 40px 36px;
  box-shadow: 0 4px 40px rgba(91,94,244,.10);
}
.auth-logo {
  display: flex; align-items: center; gap: 12px; margin-bottom: 26px;
}
.auth-title {
  font-size: 1.3rem; font-weight: 800; color: #0f172a; margin-bottom: 4px;
}
.auth-sub {
  font-size: .82rem; color: #64748b; margin-bottom: 22px;
}
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0; color: #94a3b8; font-size: .78rem;
}
.auth-divider::before,
.auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Trial banner ─────────────────────────────── */
.trial-banner {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, #eef0ff, #f5f0ff);
  border: 1px solid #c7d2fe; border-radius: 12px;
  padding: 12px 14px; margin-bottom: 20px;
  font-size: .78rem; color: #4338ca; font-weight: 500;
}

/* ══════════════════════════════════════════════════
   FORM ELEMENTS
═══════════════════════════════════════════════════ */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: .8rem; font-weight: 600; color: #475569; margin-bottom: 6px;
}
.label-hint { font-weight: 400; color: #94a3b8; }

.field input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-input);
  font-size: .88rem; color: #0f172a; background: #fff;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(91,94,244,.12);
}
.field input.has-error { border-color: #f43f5e; }

.field-link {
  text-align: end; margin-bottom: 18px;
}
.field-link a { font-size: .75rem; color: var(--indigo); font-weight: 600; }

/* Password strength */
.strength-bar {
  height: 4px; background: var(--border); border-radius: 99px;
  overflow: hidden; margin-top: 6px;
}
.strength-fill { height: 100%; border-radius: 99px; transition: width .3s, background .3s; }
.strength-label { font-size: .68rem; margin-top: 4px; }

/* Terms note */
.terms-note {
  font-size: .7rem; color: #94a3b8; text-align: center;
  margin-top: 12px; line-height: 1.6;
}
.terms-note a { color: var(--indigo); }

/* ══════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════ */
.btn-primary {
  display: block; width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: #fff; font-weight: 700; font-size: .92rem;
  border: none; border-radius: var(--radius-input);
  transition: transform .2s, box-shadow .2s;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px); box-shadow: 0 8px 24px rgba(91,94,244,.3);
}
.btn-primary:disabled { opacity: .65; cursor: not-allowed; }

.btn-outline-block {
  display: block; width: 100%; padding: 12px; text-align: center;
  border: 1.5px solid var(--indigo); border-radius: var(--radius-input);
  color: var(--indigo); font-weight: 700; font-size: .88rem;
  transition: background .2s;
}
.btn-outline-block:hover { background: var(--indigo-light); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 10px; font-weight: 600; font-size: .83rem; padding: 9px 18px;
  transition: all .2s; border: none;
}
.btn-sm-primary {
  background: linear-gradient(135deg, var(--indigo), var(--violet)); color: #fff;
}
.btn-sm-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(91,94,244,.3); }
.btn-ghost  { background: transparent; color: #64748b; }
.btn-ghost:hover { background: #f7f8fc; color: #0f172a; }
.btn-ghost.border { border: 1px solid var(--border); }
.btn-danger { background: #f43f5e; color: #fff; }
.btn-danger:hover { background: #e11d48; }

.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: transparent; border: none; color: #64748b;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: #f7f8fc; color: #0f172a; }
.btn-icon.sm { width: 28px; height: 28px; border-radius: 8px; }

/* ══════════════════════════════════════════════════
   ALERTS
═══════════════════════════════════════════════════ */
.alert-error {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: #fff1f2; border: 1px solid #fecdd3; border-radius: 10px;
  font-size: .82rem; color: #e11d48; margin-bottom: 16px;
}

/* ══════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════ */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  font-size: .72rem; font-weight: 700;
}
.badge-indigo { background: #eef0ff; color: var(--indigo); }
.badge-green  { background: #f0fdf4; color: #16a34a; }
.badge-slate  { background: #f1f5f9; color: #64748b; }

/* ══════════════════════════════════════════════════
   LOGO
═══════════════════════════════════════════════════ */
.logo-mark {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: #fff; font-weight: 800; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
}
.logo-mark.sm { width: 34px; height: 34px; border-radius: 10px; font-size: .9rem; }
.logo-text { font-weight: 800; font-size: 1.05rem; color: #0f172a; line-height: 1.2; }
.logo-dot  { color: var(--indigo); }
.logo-sub  { font-size: .72rem; color: #94a3b8; }

/* ══════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════ */
.card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
}
.stat-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 20px 22px;
  display: flex; align-items: flex-start; gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: .75rem; color: #94a3b8; margin-bottom: 3px; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: #0f172a; line-height: 1; }
.stat-change { font-size: .72rem; margin-top: 4px; }

/* ══════════════════════════════════════════════════
   DROPDOWN
═══════════════════════════════════════════════════ */
.dropdown-wrap { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 8px); z-index: 50;
  background: #fff; border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-drop);
  padding: 6px; min-width: 180px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: 8px; font-size: .82rem; color: #475569;
  background: transparent; border: none; width: 100%; text-align: start;
  transition: background .15s;
}
.dropdown-item:hover { background: #f7f8fc; color: #0f172a; }
.dropdown-item.danger:hover { background: #fff1f2; color: #f43f5e; }
.dropdown-item.sm { font-size: .8rem; padding: 7px 10px; }
.dropdown-item.active-lang { background: var(--indigo-light); color: var(--indigo); font-weight: 600; }
.dropdown-divider { height: 1px; background: var(--border); margin: 5px 4px; }

/* ══════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w); background: #fff;
  border-inline-end: 1px solid var(--border);
  height: 100vh; position: fixed; top: 0; inset-inline-start: 0;
  display: flex; flex-direction: column; z-index: 40;
  transition: transform .3s;
}
.sidebar-logo {
  padding: 18px 16px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-section {
  font-size: .68rem; font-weight: 700; color: #94a3b8;
  padding: 6px 8px 4px; letter-spacing: .08em; margin-bottom: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 500;
  color: #64748b;
  transition: all .15s;
  margin-bottom: 5px;
  cursor: pointer;
}
.nav-item:hover { background: #f7f8fc; color: #0f172a; }
.nav-item.active { background: var(--indigo-light); color: var(--indigo); font-weight: 600; }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); }
.plan-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.plan-label { font-size: .75rem; font-weight: 600; color: #64748b; }
.usage-bar { height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.usage-fill { height: 100%; background: linear-gradient(90deg, var(--indigo), var(--violet)); border-radius: 99px; }
.usage-text { font-size: .7rem; color: #94a3b8; margin-top: 5px; }

/* ══════════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════════ */
.main-area {
  margin-inline-start: var(--sidebar-w);
  min-height: 100vh; display: flex; flex-direction: column;
}
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  height: var(--topbar-h); display: flex; align-items: center;
  padding: 0 28px; gap: 14px; position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: .95rem; font-weight: 700; color: #0f172a; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.notif-btn { position: relative; }
.notif-dot {
  position: absolute; top: 6px; inset-inline-end: 6px;
  width: 8px; height: 8px; background: var(--indigo);
  border-radius: 50%; border: 2px solid #fff;
}

.user-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px 5px 12px; border-radius: 12px;
  border: 1.5px solid var(--border); background: #fff;
  transition: border-color .2s;
}
.user-btn.open { border-color: var(--indigo); }
.user-info { text-align: end; }
.user-name { font-size: .78rem; font-weight: 700; color: #0f172a; line-height: 1.2; }
.user-plan { font-size: .68rem; color: #94a3b8; }

.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: #fff; font-weight: 700; font-size: .82rem;
  display: flex; align-items: center; justify-content: center;
}

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

/* ══════════════════════════════════════════════════
   DASHBOARD HOME
═══════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.home-grid {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 20px; align-items: start;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: .95rem; font-weight: 700; color: #0f172a; }
.section-title.sm { font-size: .88rem; }
.link-primary { font-size: .72rem; color: var(--indigo); font-weight: 600; }

/* Bots grid */
.bots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.bot-card { padding: 18px; }
.bot-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.bot-avatar {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.bot-name { font-size: .85rem; font-weight: 700; color: #0f172a; margin-bottom: 3px; }
.bot-desc { font-size: .78rem; color: #64748b; line-height: 1.6; margin-bottom: 12px; }
.bot-footer {
  display: flex; align-items: center; gap: 14px;
  padding-top: 10px; border-top: 1px solid #f1f3f9;
}
.bot-stat { font-size: .75rem; color: #94a3b8; }
.bot-stat strong { font-weight: 700; color: #0f172a; }
.bot-open { font-size: .72rem; font-weight: 600; color: var(--indigo); margin-inline-start: auto; }

.new-bot-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; border-style: dashed; border-color: #dde2ef; background: #fafbff;
  min-height: 140px; cursor: pointer; transition: all .2s; padding: 18px;
}
.new-bot-card:hover { border-color: var(--indigo); background: var(--indigo-light); }
.new-bot-icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--indigo-light);
  display: flex; align-items: center; justify-content: center;
}
.new-bot-label { font-size: .82rem; font-weight: 600; color: var(--indigo); }

/* Right column */
.right-col { display: flex; flex-direction: column; gap: 16px; }

/* Recent chats */
.chat-list { display: flex; flex-direction: column; gap: 2px; }
.chat-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 8px; border-radius: 10px; cursor: pointer;
  transition: background .15s;
}
.chat-row:hover { background: #f7f8fc; }
.chat-icon {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.chat-body { flex: 1; min-width: 0; }
.chat-bot { font-size: .72rem; color: #94a3b8; margin-bottom: 2px; }
.chat-msg { font-size: .8rem; color: #334155; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: .67rem; color: #cbd5e1; white-space: nowrap; flex-shrink: 0; margin-top: 2px; }

/* Quick actions */
.actions-list { display: flex; flex-direction: column; gap: 8px; }
.action-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 10px; border: 1px solid var(--border); transition: background .15s;
}
.action-item:hover { background: #f7f8fc; }
.action-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.action-label { font-size: .8rem; font-weight: 600; color: #334155; }

/* ══════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.3);
  z-index: 50; display: flex; align-items: center; justify-content: center;
}
.modal-box { width: 380px; padding: 28px; border-radius: 20px; }
.modal-icon-wrap {
  width: 46px; height: 46px; border-radius: 12px; background: #fff1f2;
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.modal-title { font-size: 1rem; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.modal-body  { font-size: .82rem; color: #64748b; line-height: 1.7; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ══════════════════════════════════════════════════
   ICON SIZES
═══════════════════════════════════════════════════ */
.icon-xs { width: 15px; height: 15px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; flex-shrink: 0; }
.icon-md { width: 20px; height: 20px; flex-shrink: 0; }
.icon-lg { width: 22px; height: 22px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════
   PAGE LOADER
═══════════════════════════════════════════════════ */
.page-loader {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--indigo-light); border-top-color: var(--indigo);
  animation: spin .7s linear infinite;
}
@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.45; } }

/* ══════════════════════════════════════════════════
   MOBILE
═══════════════════════════════════════════════════ */
/* Burger only visible on mobile */
.menu-toggle { display: none; }

.mobile-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35;
}

@media (max-width: 768px) {
  .menu-toggle { display: flex; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0) !important; }
  .main-area { margin-inline-start: 0; }
  .home-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ══════════════════════════════════════════════════
   BOT DETAIL — TABS
═══════════════════════════════════════════════════ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 9px 18px; font-size: .83rem; font-weight: 600; color: #64748b;
  background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--indigo); }
.tab-btn.active { color: var(--indigo); border-bottom-color: var(--indigo); }

/* ══════════════════════════════════════════════════
   ALERTS
═══════════════════════════════════════════════════ */
.alert-error {
  background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3;
  border-radius: 10px; padding: 10px 14px; font-size: .82rem;
}
.alert-success {
  background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0;
  border-radius: 10px; padding: 10px 14px; font-size: .82rem;
}

/* ══════════════════════════════════════════════════
   UPLOAD ZONE
═══════════════════════════════════════════════════ */
.upload-zone {
  border: 2px dashed #dde2ef; border-radius: 14px; padding: 32px 20px;
  text-align: center; cursor: pointer; transition: all .2s; color: #94a3b8;
}
.upload-zone:hover, .upload-zone.dragging {
  border-color: var(--indigo); background: var(--indigo-light); color: var(--indigo);
}

/* ══════════════════════════════════════════════════
   KNOWLEDGE CHUNKS TABLE
═══════════════════════════════════════════════════ */
.chunks-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.chunk-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: #fff;
}
.chunk-body { flex: 1; min-width: 0; }
.chunk-source { font-size: .68rem; color: #94a3b8; margin-bottom: 3px; }
.chunk-preview { font-size: .8rem; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chunk-meta { font-size: .68rem; color: #cbd5e1; margin-top: 3px; }

/* ══════════════════════════════════════════════════
   WIDGET EMBED CODE
═══════════════════════════════════════════════════ */
.code-block {
  background: #0f172a; color: #a5f3fc; border-radius: 12px; padding: 16px 18px;
  font-family: 'Courier New', monospace; font-size: .78rem; line-height: 1.7;
  overflow-x: auto; white-space: pre; margin: 12px 0;
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
}
