/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg-base:       #0d0f14;
  --bg-card:       #151820;
  --bg-sidebar:    #0f1117;
  --bg-input:      #1a1d25;
  --bg-hover:      #1e2230;
  --border:        #252a38;
  --border-light:  #2a3045;
  --text-primary:  #e8eaf0;
  --text-secondary:#8b90a0;
  --text-muted:    #5a6078;
  --accent:        #25d366;   /* WhatsApp green */
  --accent-hover:  #1fb855;
  --accent-glow:   rgba(37,211,102,0.15);
  --danger:        #e74c3c;
  --danger-hover:  #c0392b;
  --warning:       #f39c12;
  --info:          #3498db;
  --success:       #27ae60;
  --font-mono:     'JetBrains Mono', monospace;
  --font-main:     'Syne', sans-serif;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --sidebar-w:     240px;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Warning Banner ────────────────────────────────────────────────────────── */
.warning-banner {
  background: linear-gradient(90deg, #7a2b00, #a33800);
  color: #ffdd99;
  text-align: center;
  padding: 6px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 999;
  border-bottom: 1px solid #c04a00;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: calc(100vh - 32px);
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 32px;
  height: calc(100vh - 32px);
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 2rem; }
.logo-title { font-size: 1rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.logo-sub   { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }

.wa-status-pill {
  margin: 12px 12px 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.status-dot.connected { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status-dot.qr        { background: var(--warning); }
.status-dot.connecting{ background: var(--info); }
.status-dot.disconnected{ background: var(--danger); }

.sidebar-nav { padding: 8px 0; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-left-color: var(--accent);
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-warning {
  font-size: 0.72rem;
  color: #a06020;
  background: #1e1500;
  border: 1px solid #3a2800;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
  line-height: 1.4;
}

/* ── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.page-header {
  padding: 20px 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}
.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  padding-bottom: 16px;
}
.content-area { padding: 20px 24px; flex: 1; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}
.card-title { font-size: 1rem; font-weight: 700; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }
.mb-3 { margin-bottom: 12px; }

/* ── Stats Grid ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--accent); }
.stat-card.success { border-color: var(--success); }
.stat-card.danger  { border-color: var(--danger); }
.stat-icon  { font-size: 1.6rem; margin-bottom: 4px; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text-primary); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  font-weight: 600;
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-hover); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--accent); color: #0d1a12; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #1e9450; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: var(--danger-hover); }
.btn-outline   { background: transparent; color: var(--text-primary); border: 1px solid var(--border-light); }
.btn-outline:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn-sm  { padding: 5px 10px; font-size: 0.78rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Inputs ────────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 0.875rem;
  font-family: var(--font-main);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }
.input-sm { padding: 6px 10px; font-size: 0.8rem; }
textarea.input { resize: vertical; }
select.input { cursor: pointer; }

.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-pending    { background: #1e2030; color: #8b90a0; border: 1px solid #3a3f55; }
.badge-running    { background: #0d2040; color: #60a0ff; border: 1px solid #204080; animation: pulse 1.5s infinite; }
.badge-completed  { background: #0d2018; color: var(--accent); border: 1px solid #1a4030; }
.badge-stopped    { background: #201a0d; color: var(--warning); border: 1px solid #403010; }
.badge-failed     { background: #200d0d; color: var(--danger); border: 1px solid #401010; }
.badge-info       { background: #0d1a28; color: var(--info); border: 1px solid #102040; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.search-bar form { display: flex; gap: 8px; align-items: center; }
.toolbar .search-bar { flex: 1; }

/* ── Modals ────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-lg  { max-width: 700px; }
.modal-xl  { max-width: 960px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body   { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Info / Warning Boxes ──────────────────────────────────────────────────── */
.warning-box {
  background: #1a1000;
  border: 1px solid #4a2a00;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: #d0920a;
  font-size: 0.85rem;
  line-height: 1.6;
}
.warning-box ul { padding-left: 18px; }
.warning-box li { margin-bottom: 4px; }
.info-box {
  background: #0d1a28;
  border: 1px solid #152840;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: #60a0d0;
  font-size: 0.85rem;
}

/* ── Upload ────────────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text-primary);
}
.upload-icon { font-size: 2.5rem; margin-bottom: 8px; }
.progress-bar-wrap { background: var(--bg-input); border-radius: 4px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #00e676); border-radius: 4px; transition: width 0.3s; }
.result-box { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.85rem; }
.result-success { background: #0d2018; border: 1px solid #1a4030; color: var(--accent); }
.result-error   { background: #200d0d; border: 1px solid #401010; color: #e87070; }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.page-btn {
  display: inline-block;
  width: 32px; height: 32px;
  line-height: 32px;
  text-align: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-decoration: none;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #0d1a12; font-weight: 700; }

/* ── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state p { margin: 10px 0 16px; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.text-success { color: var(--accent); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-muted); }
.font-mono    { font-family: var(--font-mono); font-size: 0.85em; }
.text-center  { text-align: center; }

/* ── Connect Page ──────────────────────────────────────────────────────────── */
.connect-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.connect-card { }
.wa-status-display {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px 20px;
}
.status-circle {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border: 3px solid var(--border);
  flex-shrink: 0;
}
.status-connected { border-color: var(--accent); background: var(--accent-glow); }
.status-qr        { border-color: var(--warning); background: rgba(243,156,18,0.1); }
.status-connecting{ border-color: var(--info); background: rgba(52,152,219,0.1); animation: pulse 1.5s infinite; }
.status-disconnected{ border-color: var(--danger); background: rgba(231,76,60,0.1); }
.status-label { font-size: 1.3rem; font-weight: 800; }
.status-sub   { color: var(--text-muted); }
.qr-section   { padding: 0 20px 20px; text-align: center; }
.qr-instructions { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 16px; line-height: 2; }
.qr-image {
  width: 260px; height: 260px;
  border: 6px solid #fff;
  border-radius: var(--radius);
  background: #fff;
}
.qr-expire-note { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; }
.qr-wrapper { display: inline-block; }
.connected-section { padding: 0 20px 20px; }
.conn-row { display: flex; gap: 12px; margin-bottom: 8px; font-size: 0.9rem; }
.conn-label { color: var(--text-muted); width: 70px; }
.conn-value { font-weight: 700; }
.connect-actions { padding: 0 20px 20px; }
.tips-list { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.tip-item { display: flex; gap: 12px; font-size: 0.85rem; color: var(--text-secondary); }
.tip-icon { font-size: 1.3rem; flex-shrink: 0; }

/* ── Groups ────────────────────────────────────────────────────────────────── */
.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding: 16px; }
.group-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.2s;
}
.group-card:hover { border-color: var(--accent); }
.group-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.group-name { font-size: 1rem; font-weight: 700; }
.group-actions { display: flex; gap: 6px; flex-shrink: 0; }
.group-desc { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 10px; }
.group-meta { display: flex; justify-content: space-between; align-items: center; }

/* ── Templates ─────────────────────────────────────────────────────────────── */
.templates-list { display: flex; flex-direction: column; gap: 0; }
.template-card {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.template-card:last-child { border-bottom: none; }
.template-card:hover { background: var(--bg-hover); }
.template-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.template-name { font-weight: 700; font-size: 0.95rem; }
.template-actions { display: flex; gap: 6px; }
.template-header-preview { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.template-body-preview { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; }
.template-footer-preview { font-size: 0.78rem; font-style: italic; margin-bottom: 6px; }
.template-buttons-preview { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.btn-preview { padding: 4px 10px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.btn-preview-quick_reply { background: #0d1a28; color: #60a0ff; border: 1px solid #204080; }
.btn-preview-url  { background: #0d2018; color: var(--accent); border: 1px solid #1a4030; }
.btn-preview-call { background: #1a1000; color: var(--warning); border: 1px solid #4a2a00; }
.template-meta { font-size: 0.72rem; }

/* Template Builder */
.template-builder { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
.template-form { }
.template-preview-panel { }
.preview-title { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.wa-phone-frame {
  background: #111b21;
  border-radius: 12px;
  padding: 16px 12px;
  border: 1px solid #25d36630;
  max-width: 280px;
}
.wa-message-bubble {
  background: #1f2c34;
  border-radius: 8px 8px 8px 0;
  padding: 10px 12px;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  position: relative;
}
.wa-header { font-weight: 800; font-size: 0.9rem; color: #e8eaf0; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid #2d3d45; }
.wa-body { color: #d0d8dc; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.wa-footer { font-size: 0.75rem; color: #8b9898; margin-top: 6px; font-style: italic; }
.wa-buttons { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.wa-btn-preview {
  background: #2a3942;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.82rem;
  color: #53bdeb;
  text-align: center;
  font-weight: 600;
}

/* Button builder */
.btn-type-selector { display: flex; gap: 8px; flex-wrap: wrap; }
.buttons-container { display: flex; flex-direction: column; gap: 8px; }
.button-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--bg-input); border-radius: var(--radius-sm); padding: 8px; }
.btn-row-type { font-size: 0.75rem; color: var(--text-muted); width: 80px; flex-shrink: 0; }
.groups-checkbox-list { display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }
.checkbox-item { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.875rem; }
.checkbox-item input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ── Campaigns ─────────────────────────────────────────────────────────────── */
.live-campaign-panel { border-color: #204080; }
.progress-section { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.progress-stats { display: flex; gap: 20px; flex-wrap: wrap; font-size: 0.875rem; margin-bottom: 8px; }
.live-log {
  height: 260px;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.log-line { padding: 2px 0; }
.log-success { color: var(--accent); }
.log-error   { color: var(--danger); }
.log-warn    { color: var(--warning); }
.log-info    { color: var(--text-secondary); }

/* ── Quick Actions ─────────────────────────────────────────────────────────── */
.section-title { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.action-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.15s;
  text-decoration: none;
}
.action-card:hover { border-color: var(--accent); color: var(--text-primary); background: var(--accent-glow); text-decoration: none; }
.action-icon { font-size: 2rem; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
  .connect-layout { grid-template-columns: 1fr; }
  .template-builder { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar-nav { display: flex; flex-wrap: wrap; padding: 4px; }
  .nav-item { border-left: none; border-bottom: 3px solid transparent; padding: 8px 10px; }
  .nav-item.active { border-bottom-color: var(--accent); border-left: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
