/* WALazy SaaS - Main Stylesheet */
:root {
  --bg-base: #0a0d12;
  --bg-surface: #111620;
  --bg-card: #161c28;
  --bg-card-hover: #1c2336;
  --border: #1f2a3d;
  --border-bright: #2a3a56;
  --accent: #25D366;
  --accent-dim: rgba(37,211,102,0.12);
  --accent-glow: rgba(37,211,102,0.3);
  --text-primary: #e8edf5;
  --text-secondary: #7a8aaa;
  --text-muted: #3d4d6a;
  --danger: #ff4757;
  --warning: #ffa502;
  --info: #3d8bff;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 1000;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 38px; height: 38px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #000; font-size: 18px;
  box-shadow: 0 0 20px var(--accent-glow);
}
.brand-text {
  font-size: 18px; font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -.3px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.nav-section-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-muted); padding: 12px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: all .15s ease;
  position: relative; margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-item i { font-size: 15px; min-width: 18px; }
.nav-badge {
  margin-left: auto; background: var(--danger);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.device-status-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  padding: 8px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 6px currentColor;
  transition: all .3s;
}
.status-dot.connected { background: var(--accent); }
.status-dot.disconnected { background: var(--danger); }
.status-dot.connecting { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:.4 } }

/* ── Sidebar overlay (mobile) ──────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 999;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
}

/* ── Main wrapper ──────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .3s;
}
@media (max-width: 991px) { .main-wrapper { margin-left: 0; } }

/* ── Topbar ────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 100;
}
.topbar h1 {
  font-size: 16px; font-weight: 600;
  color: var(--text-primary); margin: 0;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-time { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

.btn-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.btn-icon:hover { border-color: var(--border-bright); color: var(--text-primary); }

.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #128c7e);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #000;
}

/* ── Page content ──────────────────────────────────────── */
.page-content { padding: 28px; flex: 1; }
@media (max-width: 767px) { .page-content { padding: 16px; } }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s;
}
.card:hover { border-color: var(--border-bright); }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 20px; }

/* ── Stat cards ─────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: all .2s;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: var(--accent-color, var(--accent));
  opacity: 0; transition: opacity .2s;
}
.stat-card:hover { border-color: var(--border-bright); }
.stat-card:hover::before { opacity: 1; }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ── Forms ─────────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  background: var(--bg-surface);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.input-group-text {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-secondary);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn { font-family: var(--font); font-weight: 500; border-radius: var(--radius-sm); }
.btn-accent {
  background: var(--accent); color: #000;
  border: none; font-weight: 600;
}
.btn-accent:hover { background: #1db954; color: #000; box-shadow: 0 0 20px var(--accent-glow); }
.btn-outline-accent {
  border: 1px solid var(--accent); color: var(--accent); background: transparent;
}
.btn-outline-accent:hover { background: var(--accent-dim); }

/* ── Tables ─────────────────────────────────────────────── */
.table-dark { --bs-table-bg: transparent; --bs-table-striped-bg: rgba(255,255,255,.02); }
.table { border-color: var(--border); font-size: 13.5px; }
.table th { font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--text-secondary); font-weight: 600; }
.table td { vertical-align: middle; }

/* ── Badges ─────────────────────────────────────────────── */
.badge-status { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-pending  { background: rgba(255,165,2,.15); color: var(--warning); }
.badge-success  { background: rgba(37,211,102,.15); color: var(--accent); }
.badge-failed   { background: rgba(255,71,87,.15); color: var(--danger); }
.badge-processing { background: rgba(61,139,255,.15); color: var(--info); }

/* ── Chat UI ─────────────────────────────────────────────── */
.chat-container { display: flex; height: calc(100vh - var(--topbar-h) - 56px); gap: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.chat-sidebar { width: 280px; flex-shrink: 0; background: var(--bg-surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg-card); }
.chat-search { padding: 16px; border-bottom: 1px solid var(--border); }
.conversation-list { flex: 1; overflow-y: auto; }
.conversation-item { display: flex; gap: 12px; padding: 14px 16px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.03); transition: background .15s; }
.conversation-item:hover, .conversation-item.active { background: var(--accent-dim); }
.conv-avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, #3d8bff, #7b5cfa); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.conv-name { font-size: 14px; font-weight: 600; }
.conv-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 10px; color: var(--text-muted); }

.chat-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }

.msg-bubble { max-width: 70%; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.msg-in  { background: var(--bg-surface); border-bottom-left-radius: 4px; }
.msg-out { background: var(--accent); color: #000; border-bottom-right-radius: 4px; margin-left: auto; }
.msg-meta { font-size: 10px; opacity: .6; margin-top: 4px; }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  min-width: 280px;
}
.toast-header { background: transparent; border-bottom: 1px solid var(--border); color: var(--text-primary); }

/* ── Loading spinner ─────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10,13,18,.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.spinner-ring {
  width: 48px; height: 48px; position: relative;
}
.spinner-ring div {
  position: absolute; width: 38px; height: 38px;
  margin: 5px; border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  animation: spin .8s cubic-bezier(.5,0,.5,1) infinite;
}
.spinner-ring div:nth-child(1) { animation-delay: -.3s; }
.spinner-ring div:nth-child(2) { animation-delay: -.2s; }
.spinner-ring div:nth-child(3) { animation-delay: -.1s; }
@keyframes spin { 0% { transform: rotate(0) } 100% { transform: rotate(360deg) } }

/* ── Dropdown ─────────────────────────────────────────────── */
.dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.dropdown-item { color: var(--text-primary); font-size: 13.5px; padding: 8px 16px; }
.dropdown-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.dropdown-header { color: var(--text-secondary); font-size: 12px; padding: 8px 16px; }
.dropdown-divider { border-color: var(--border); }

/* ── Modal ─────────────────────────────────────────────── */
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
}
.modal-header {
  background: transparent; border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}
.modal-footer { background: transparent; border-top: 1px solid var(--border); }
.btn-close { filter: invert(1) brightness(.7); }

/* ── Activity feed ─────────────────────────────────────── */
.activity-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: 13px;
}
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }

/* ── Code blocks ─────────────────────────────────────────── */
.code-block {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  white-space: pre-wrap; word-break: break-all;
  color: var(--accent);
}

/* ── Switch ─────────────────────────────────────────────── */
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-switch .form-check-input { width: 36px; height: 20px; }

/* ── Progress ─────────────────────────────────────────────── */
.progress { background: var(--bg-surface); height: 6px; border-radius: 3px; }
.progress-bar { background: var(--accent); }

/* ── Nav tabs ─────────────────────────────────────────────── */
.nav-tabs { border-bottom: 1px solid var(--border); }
.nav-tabs .nav-link { color: var(--text-secondary); border: none; padding: 10px 16px; font-size: 13.5px; border-radius: 0; }
.nav-tabs .nav-link:hover { color: var(--text-primary); }
.nav-tabs .nav-link.active { color: var(--accent); border-bottom: 2px solid var(--accent); background: transparent; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.fade-up { animation: fadeUp .3s ease both; }
.fade-up:nth-child(2) { animation-delay:.05s; }
.fade-up:nth-child(3) { animation-delay:.1s; }
.fade-up:nth-child(4) { animation-delay:.15s; }
.fade-up:nth-child(5) { animation-delay:.2s; }
.fade-up:nth-child(6) { animation-delay:.25s; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; }
