* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a1f35;
  --bg-card-hover: #222842;
  --bg-input: #0f1322;
  --border: #2a3050;
  --text-primary: #e8edf5;
  --text-secondary: #8892b0;
  --text-muted: #5a6380;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --accent-glow: rgba(108, 99, 255, 0.25);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.12);
  --blue: #3b82f6;
  --sidebar-width: 240px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}
html, body { height: 100%; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.text-center { text-align: center; }

/* Login */
.login-screen {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #1a1040 0%, var(--bg-primary) 60%);
  padding: 20px;
}
.login-card {
  background: var(--bg-card); border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 420px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.login-header { text-align: center; margin-bottom: 32px; }
.logo-icon {
  width: 70px; height: 70px; border-radius: 50%; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center; font-size: 28px; color: #fff;
  box-shadow: 0 0 40px var(--accent-glow);
}
.login-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-header p { color: var(--text-secondary); font-size: 13px; }
.input-group {
  display: flex; align-items: center; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 14px; margin-bottom: 16px; transition: border-color .2s;
}
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.input-group i { color: var(--text-muted); font-size: 16px; }
.input-group input {
  background: none; border: none; outline: none; color: var(--text-primary); font-size: 15px;
  padding: 14px 12px; width: 100%;
}
.input-group input::placeholder { color: var(--text-muted); }
.login-error { color: var(--red); font-size: 13px; text-align: center; margin-bottom: 12px; min-height: 20px; }
.login-footer { margin-top: 24px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer; transition: transform .15s, box-shadow .2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-sm { padding: 8px 16px; width: auto; font-size: 13px; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-primary); font-size: 13px; cursor: pointer; transition: background .2s;
}
.btn-secondary:hover { background: var(--bg-card-hover); }
.btn-icon {
  background: none; border: none; color: var(--text-secondary); cursor: pointer;
  width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.btn-icon:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.btn-logout {
  background: none; border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; transition: all .2s; width: 100%;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }
.btn-action {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary);
  padding: 16px 20px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; transition: all .2s;
}
.btn-action:hover { background: var(--bg-card-hover); border-color: var(--accent); transform: translateX(4px); }
.btn-action i { font-size: 20px; color: var(--accent); }

/* Spinner */
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite;
}
.spinner-lg { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Main Layout */
.main-app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width); background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px; padding: 20px; border-bottom: 1px solid var(--border);
}
.logo-small { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #8b5cf6); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; }
.logo-text { font-size: 16px; font-weight: 700; }
.sidebar-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 14px; transition: all .2s;
}
.nav-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); font-weight: 500; }
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.wa-status-badge {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary);
  padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-card);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.disconnected { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status-dot.connecting { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--bg-secondary); flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h2 { font-size: 18px; font-weight: 600; }
#mobileMenuBtn { display: none; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-time { font-size: 13px; color: var(--text-muted); }
.content-body {
  flex: 1; overflow-y: auto; padding: 24px 28px;
}
.page { display: none; }
.page.active { display: block; }

/* Cards */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 24px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.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;
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0,0,0,.2); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
#statWhatsApp .stat-icon { background: var(--green-bg); color: var(--green); }
#statClients .stat-icon { background: var(--accent-glow); color: var(--accent); }
#statTotalClients .stat-icon { background: var(--blue); color: #fff; }
#statUptime .stat-icon { background: var(--yellow-bg); color: var(--yellow); }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-secondary); }

/* Quick Actions */
.quick-actions { display: flex; flex-direction: column; gap: 8px; }

/* Tables */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border);
  color: var(--text-secondary); font-weight: 600; white-space: nowrap;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-primary); }
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table .status-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
}
.status-badge.active { background: var(--green-bg); color: var(--green); }
.status-badge.inactive { background: var(--red-bg); color: var(--red); }
.status-badge.sent { background: var(--green-bg); color: var(--green); }
.status-badge.failed { background: var(--red-bg); color: var(--red); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; background: var(--bg-input); color: var(--text-secondary); margin: 1px; }
.action-btns { display: flex; gap: 4px; }
.btn-table { padding: 4px 8px; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; color: #fff; transition: opacity .2s; }
.btn-table:hover { opacity: .8; }
.btn-edit { background: var(--blue); }
.btn-delete { background: var(--red); }
.btn-deactivate { background: var(--yellow); color: #000; }
.btn-reset { background: var(--accent); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 500px; box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal form { padding: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.form-group label small { color: var(--text-muted); font-weight: 400; }
.form-group input, .form-group textarea {
  width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; outline: none;
}
.form-group input:focus { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; }
.copy-field .btn-icon { background: var(--accent-glow); color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.modal-actions .btn-primary { width: auto; }

/* QR Page */
.qr-body { text-align: center; }
.qr-status { display: flex; gap: 32px; justify-content: center; margin-bottom: 24px; }
.status-detail { display: flex; flex-direction: column; gap: 4px; }
.status-detail .label { font-size: 12px; color: var(--text-secondary); }
.status-detail .value { font-size: 18px; font-weight: 700; }
.qr-display { padding: 24px; }
.qr-display h4 { margin-bottom: 20px; }
.qr-code-container { display: inline-block; margin-bottom: 16px; }
.qr-code-container img, .qr-code-container canvas { border-radius: var(--radius-sm); border: 2px solid #fff; }
.qr-hint { font-size: 13px; color: var(--text-secondary); }
.qr-connected { padding: 40px 20px; }
.qr-connected i { font-size: 64px; color: var(--green); margin-bottom: 16px; }
.qr-connected h4 { font-size: 20px; margin-bottom: 8px; }
.qr-connected p { color: var(--text-secondary); }
.qr-loading { padding: 40px; }
.qr-loading p { color: var(--text-secondary); margin-top: 12px; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 100; transition: left .3s; }
  .sidebar.open { left: 0; }
  #mobileMenuBtn { display: flex; }
  .main-content { width: 100%; }
  .content-header { padding: 12px 16px; }
  .content-body { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 32px 24px; }
  .qr-status { flex-direction: column; gap: 16px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
}

/* Docs Page */
.docs-body { padding: 0; }
.docs-body > *:first-child { padding: 24px 28px; }
.docs-loading, .docs-error { text-align: center; padding: 60px 20px; }
.docs-error i { font-size: 32px; color: var(--yellow); margin-bottom: 12px; }
.docs-error p { color: var(--text-secondary); }
.docs-body h1 { font-size: 26px; margin: 0 0 8px; padding: 28px 28px 0; }
.docs-body h1 + p { padding: 0 28px; color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.docs-body h2 {
  font-size: 20px; margin: 32px 0 16px; padding: 0 28px;
  border-bottom: 1px solid var(--border); padding-bottom: 12px;
}
.docs-body h3 { font-size: 16px; margin: 24px 0 12px; padding: 0 28px; color: var(--accent); }
.docs-body h4 { font-size: 14px; margin: 16px 0 8px; padding: 0 28px; }
.docs-body p { padding: 0 28px; margin-bottom: 12px; line-height: 1.7; color: var(--text-secondary); }
.docs-body strong { color: var(--text-primary); }
.docs-body a { color: var(--accent); }
.docs-body a:hover { text-decoration: underline; }
.docs-body hr { border: none; border-top: 1px solid var(--border); margin: 28px 28px; }
.docs-body ul, .docs-body ol { padding: 0 28px 0 56px; margin-bottom: 12px; color: var(--text-secondary); }
.docs-body li { margin-bottom: 4px; line-height: 1.7; }
.docs-body blockquote {
  margin: 12px 28px; padding: 12px 16px; background: var(--bg-input);
  border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary); font-size: 13px;
}
.docs-body code {
  background: #0d1117; padding: 2px 6px; border-radius: 4px;
  font-size: 13px; color: #f0c674; font-family: 'Consolas', 'Courier New', monospace;
}
.docs-body pre {
  margin: 12px 28px; background: #0d1117; border-radius: var(--radius-sm);
  border: 1px solid var(--border); overflow-x: auto;
}
.docs-body pre code { background: none; padding: 0; color: #e6edf3; }
.docs-body table.doc-table {
  margin: 12px 28px; width: calc(100% - 56px); border-collapse: collapse;
}
.docs-body table.doc-table th, .docs-body table.doc-table td {
  padding: 10px 14px; border: 1px solid var(--border); text-align: left;
  font-size: 13px;
}
.docs-body table.doc-table th {
  background: var(--bg-input); color: var(--text-primary); font-weight: 600;
}
.docs-body table.doc-table td { color: var(--text-secondary); }
.docs-body table.doc-table tr:hover td { background: var(--bg-card-hover); }
.docs-body img { max-width: 100%; border-radius: var(--radius-sm); margin: 12px 0; }
