/* SK Brand Tech WhatsApp API — Dashboard CSS */
:root {
  --wa:        #25D366;
  --wa-dark:   #128C7E;
  --wa-deep:   #075E54;
  --ink:       #0A1A0F;
  --ink-mid:   #1C3525;
  --ink-light: #2A4A35;
  --surface:   #142B1E;
  --border:    rgba(37,211,102,0.15);
  --border-s:  rgba(37,211,102,0.3);
  --muted:     rgba(255,255,255,0.45);
  --text:      rgba(255,255,255,0.92);
  --text-s:    rgba(255,255,255,0.6);
  --gold:      #E8A82A;
  --red:       #E55;
  --sidebar-w: 240px;
  --topbar-h:  60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--ink);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform .25s;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 1.2rem 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--wa); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.1rem;
  flex-shrink: 0;
}
.logo-brand { font-family: 'Syne', sans-serif; font-weight: 700; font-size: .9rem; display: block; }
.logo-sub   { font-size: .7rem; color: var(--muted); }

.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-section-label {
  font-size: .65rem; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  padding: .8rem 1.2rem .3rem; margin-top: .25rem;
}
.nav-divider { border-top: 1px solid var(--border); margin: .5rem 1rem; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: .55rem 1.2rem; font-size: .875rem; color: var(--text-s);
  text-decoration: none; border-radius: 8px; margin: 1px .5rem;
  transition: background .15s, color .15s; position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; fill: currentColor; }
.nav-item:hover, .nav-item.active {
  background: rgba(37,211,102,0.1);
  color: var(--wa);
}
.nav-item.sa:hover, .nav-item.sa.active {
  background: rgba(232,168,42,0.1);
  color: var(--gold);
}
.badge {
  margin-left: auto; background: var(--wa); color: var(--ink);
  font-size: .65rem; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--wa-dark); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.user-name { font-size: .8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .68rem; color: var(--muted); }
.logout-btn {
  color: var(--muted); text-decoration: none; padding: 4px;
  border-radius: 6px; transition: color .15s;
  display: flex; align-items: center;
}
.logout-btn:hover { color: var(--red); }

/* ── TOPBAR ──────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h); z-index: 100;
  background: rgba(10,26,15,0.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
}
.sidebar-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.3rem; cursor: pointer; }
.page-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.05rem; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.notif-bell {
  position: relative; cursor: pointer; color: var(--muted);
  padding: 4px; display: flex;
}
.notif-bell:hover { color: var(--wa); }
.notif-dot {
  width: 8px; height: 8px; background: var(--red); border-radius: 50%;
  position: absolute; top: 2px; right: 2px; border: 1px solid var(--ink);
}
.wa-status {
  display: flex; align-items: center; gap: 6px;
  font-size: .75rem; color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: .3rem .75rem; border-radius: 20px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #888; }
.status-dot.connected { background: var(--wa); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.4;} }

/* ── MAIN CONTENT ──────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 1.75rem;
  min-height: calc(100vh - var(--topbar-h));
  width: calc(100% - var(--sidebar-w));
}

/* ── FLASH ──────────────────────────────────── */
.flash {
  position: fixed; top: calc(var(--topbar-h) + 8px); left: 50%;
  transform: translateX(-50%); z-index: 999;
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.5rem; border-radius: 10px;
  font-size: .875rem; font-weight: 500;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  animation: slideDown .3s ease;
}
@keyframes slideDown { from{transform:translate(-50%,-12px);opacity:0} to{transform:translate(-50%,0);opacity:1} }
.flash button { background: none; border: none; cursor: pointer; color: inherit; font-size: 1.1rem; line-height: 1; }
.flash-success { background: #1a4a2a; border: 1px solid var(--wa); color: var(--wa); }
.flash-error   { background: #4a1a1a; border: 1px solid var(--red); color: #ff8888; }
.flash-info    { background: var(--ink-mid); border: 1px solid var(--border-s); color: var(--text); }

/* ── CARDS ──────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
}
.card-title {
  font-family: 'Syne', sans-serif; font-weight: 700;
  font-size: 1rem; margin-bottom: 1.25rem;
  display: flex; align-items: center; gap: 8px;
}
.card-title svg { width: 16px; height: 16px; fill: var(--wa); }

/* ── STAT CARDS ─────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border-s); }
.stat-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; }
.stat-value { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.9rem; color: var(--wa); line-height: 1; }
.stat-delta { font-size: .75rem; color: var(--muted); margin-top: .3rem; }
.stat-delta.up   { color: var(--wa); }
.stat-delta.down { color: var(--red); }

/* ── TABLES ─────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: rgba(37,211,102,0.06); }
th { padding: .75rem 1rem; text-align: left; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
td { padding: .8rem 1rem; font-size: .875rem; border-top: 1px solid var(--border); color: var(--text-s); }
tr:hover td { background: rgba(255,255,255,0.02); color: var(--text); }

/* ── FORMS ──────────────────────────────────── */
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .4rem; font-weight: 500; }
.form-control {
  width: 100%; padding: .65rem 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: .9rem;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--wa); }
select.form-control { cursor: pointer; background-color: var(--ink-mid); }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: .6rem 1.3rem; border-radius: 10px;
  font-family: 'Syne', sans-serif; font-weight: 700;
  font-size: .85rem; cursor: pointer; text-decoration: none;
  border: none; transition: all .2s;
}
.btn-primary  { background: var(--wa); color: var(--ink); }
.btn-primary:hover  { background: #1dba57; transform: translateY(-1px); }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border-s); }
.btn-outline:hover  { border-color: var(--wa); color: var(--wa); }
.btn-danger   { background: #4a1a1a; color: #ff8888; border: 1px solid rgba(255,80,80,.3); }
.btn-danger:hover   { background: #6a2020; }
.btn-gold     { background: rgba(232,168,42,.15); color: var(--gold); border: 1px solid rgba(232,168,42,.3); }
.btn-sm       { padding: .35rem .8rem; font-size: .78rem; }
.btn-icon     { padding: .45rem; border-radius: 8px; }

/* ── BADGES ─────────────────────────────────── */
.badge-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
.badge-green  { background: rgba(37,211,102,.12); color: var(--wa); }
.badge-yellow { background: rgba(232,168,42,.12); color: var(--gold); }
.badge-red    { background: rgba(229,85,85,.12); color: var(--red); }
.badge-gray   { background: rgba(255,255,255,.06); color: var(--muted); }

/* ── MODAL ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 2rem;
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
}
.modal-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.1rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── GRID LAYOUTS ───────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }

/* ── INBOX SPECIFIC ─────────────────────────── */
.inbox-layout { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - var(--topbar-h) - 3.5rem); gap: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); }
.convo-list { background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
.convo-item { padding: .9rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.convo-item:hover, .convo-item.active { background: rgba(37,211,102,0.08); }
.convo-name { font-weight: 500; font-size: .875rem; }
.convo-preview { font-size: .78rem; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-panel { display: flex; flex-direction: column; background: var(--ink); }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.bubble { max-width: 65%; padding: .65rem 1rem; border-radius: 12px; font-size: .875rem; line-height: 1.5; }
.bubble-in  { background: var(--ink-mid); border-radius: 12px 12px 12px 2px; align-self: flex-start; }
.bubble-out { background: rgba(37,211,102,0.15); border: 1px solid var(--border); border-radius: 12px 12px 2px 12px; align-self: flex-end; }
.chat-input-bar { padding: .9rem 1rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; align-items: flex-end; background: var(--surface); }
.chat-input-bar textarea { flex: 1; resize: none; }

/* ── CHATBOT BUILDER ─────────────────────────── */
.flow-canvas { background: var(--ink); border: 1px solid var(--border); border-radius: 12px; min-height: 500px; position: relative; overflow: hidden; }
.flow-node {
  position: absolute; background: var(--ink-mid); border: 1px solid var(--border-s);
  border-radius: 12px; padding: .75rem 1rem; min-width: 180px;
  cursor: grab; user-select: none; font-size: .82rem;
}
.flow-node.selected { border-color: var(--wa); box-shadow: 0 0 0 2px rgba(37,211,102,.2); }
.flow-node-header { font-weight: 600; font-size: .8rem; margin-bottom: .3rem; color: var(--wa); }

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .topbar { left: 0; }
  .main-content { margin-left: 0; width: 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .inbox-layout { grid-template-columns: 1fr; }
}

/* ── AUTH PAGES ──────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--ink);
  background-image: radial-gradient(ellipse 60% 40% at 50% 0%, rgba(37,211,102,0.1) 0%, transparent 60%);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 2.5rem;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 2rem;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.1rem;
}
.auth-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.4rem; margin-bottom: .5rem; }
.auth-sub   { font-size: .875rem; color: var(--muted); margin-bottom: 2rem; }
.auth-link  { color: var(--wa); text-decoration: none; font-weight: 500; }
.auth-link:hover { text-decoration: underline; }
.auth-divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── SCROLLBAR ────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(37,211,102,0.25); border-radius: 3px; }
