/* ==========================================
   Zalo Manager — Premium Dark UI
   ========================================== */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-hover: #252838;
  --bg-input: #161822;
  --border: #2a2d3e;
  --border-focus: #4f6ef7;
  
  --text-primary: #e4e6f0;
  --text-secondary: #8b8fa3;
  --text-muted: #5c6078;

  --accent: #4f6ef7;
  --accent-hover: #6380ff;
  --accent-glow: rgba(79, 110, 247, 0.15);
  
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.1);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.1);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 50%;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  overflow-y: auto;
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

body::-webkit-scrollbar { width: 5px; }
body::-webkit-scrollbar-track { background: transparent; }
body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

#app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ==================== HEADER ==================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: white;
  box-shadow: 0 2px 12px rgba(79, 110, 247, 0.3);
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
}

.header-status.connected {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.header-status.disconnected {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
}

.connected .status-dot {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}

.disconnected .status-dot {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==================== TABS ==================== */
.tabs {
  display: flex;
  padding: 0 18px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 2px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.tab:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab svg { opacity: 0.7; }
.tab.active svg { opacity: 1; }

/* ==================== TAB CONTENT ==================== */
.tab-content {
  display: none;
  padding: 14px 18px;
  flex: 1;
}

.tab-content.active { display: block; }

/* ==================== CARDS ==================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-header h3, .card-header h4 {
  font-size: 13px;
  font-weight: 600;
}

.card-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px;
  color: var(--text-secondary);
}

/* ==================== SPINNER ==================== */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== ACCOUNT INFO ==================== */
.account-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  border: 2px solid var(--accent);
  object-fit: cover;
  box-shadow: 0 0 12px var(--accent-glow);
}

.account-details h2 {
  font-size: 17px;
  font-weight: 700;
}

.account-id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==================== ACCOUNT ACTIONS ==================== */
.account-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: center;
}

/* ==================== NOT CONNECTED ==================== */
.not-connected {
  text-align: center;
  padding: 20px;
}

.not-connected .icon-warning {
  color: var(--warning);
  margin-bottom: 12px;
}

.not-connected h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.not-connected p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.6;
}

.not-connected a {
  color: var(--accent);
  text-decoration: none;
}

.not-connected a:hover { text-decoration: underline; }

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover { background: var(--border); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.25);
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-input);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-sm { padding: 5px 10px; font-size: 11px; }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* ==================== FORMS ==================== */
.form-group { margin-bottom: 12px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-select,
.form-input,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  transition: var(--transition);
  outline: none;
}

.form-select:focus,
.form-input:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.form-hint {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.settings-row {
  display: flex;
  gap: 12px;
}

.form-group-inline {
  flex: 1;
}

.form-group-inline .form-input {
  text-align: center;
}

/* ==================== ACTION BUTTONS ==================== */
.action-buttons {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.action-buttons .btn { flex: 1; justify-content: center; }
.btn-full { width: 100%; padding: 12px 16px; font-size: 14px; font-weight: 600; }

/* ==================== GROUPS LIST ==================== */
.groups-list {
  max-height: 340px;
  overflow-y: auto;
}

.groups-list::-webkit-scrollbar { width: 4px; }
.groups-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.group-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: default;
}

.group-item:hover { background: var(--bg-hover); }

.group-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #4f6ef7, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.group-info { flex: 1; min-width: 0; }

.group-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== SEARCH RESULTS ==================== */
.search-results {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.user-list {
  max-height: 400px;
  overflow-y: auto;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.user-item:hover { background: var(--bg-hover); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-hover);
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 12px;
  font-weight: 500;
}

.user-phone {
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
}

.user-status {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.user-status.found {
  background: var(--success-bg);
  color: var(--success);
}

.user-status.not-found {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

/* ==================== PROGRESS ==================== */
.progress-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* ==================== LOGS ==================== */
.log-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.log-list {
  max-height: 300px;
  overflow-y: auto;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  line-height: 1.8;
}

.log-list::-webkit-scrollbar { width: 3px; }
.log-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.log-entry { padding: 1px 0; }

.log-entry.success { color: var(--success); }
.log-entry.error { color: var(--danger); }
.log-entry.warning { color: var(--warning); }
.log-entry.info { color: var(--info); }

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ==================== FOOTER ==================== */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
}

/* ==================== UTILITIES ==================== */
.hidden { display: none !important; }

/* ==================== WORKFLOW INFO ==================== */
.workflow-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-secondary);
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--accent-glow);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-status.pending {
  background: var(--warning-bg);
  color: var(--warning);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card { animation: fadeIn 0.3s ease; }

.tab-content.active { animation: fadeIn 0.15s ease; }
