/* ═══════════════════════════════════════════════════════════
   CRM Dashboard — Premium Dark Theme
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1c2a4a;
  --bg-input: #0d1b2a;
  --accent: #e94560;
  --accent-glow: rgba(233, 69, 96, 0.3);
  --accent-2: #7c3aed;
  --accent-3: #06d6a0;
  --text-primary: #e8e8f0;
  --text-secondary: #8b8fa3;
  --text-muted: #5a5e72;
  --border: rgba(255, 255, 255, 0.06);
  --border-active: rgba(233, 69, 96, 0.4);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-width: 260px;
  --font-ar: 'Cairo', sans-serif;
  --font-en: 'Inter', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* ═══════ SCROLLBAR ═══════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ═══════ APP LAYOUT ═══════ */
#app {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  max-width: 100vw;
  overflow-x: hidden;
}

/* ═══════ SIDEBAR ═══════ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

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

.logo-icon { font-size: 28px; }

.logo-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-en);
}

.logo-accent { color: var(--accent); }

.sidebar-toggle {
  display: none;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 18px;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
  position: relative;
}

.nav-item:hover {
  background: rgba(233, 69, 96, 0.08);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(233, 69, 96, 0.15), rgba(124, 58, 237, 0.1));
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-icon { font-size: 18px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
}

.status-dot.online {
  background: var(--accent-3);
  box-shadow: 0 0 8px rgba(6, 214, 160, 0.5);
  animation: pulse 2s infinite;
}

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

/* ═══════ MAIN CONTENT ═══════ */
.main-content {
  flex: 1 1 0%;
  min-width: 0 !important;
  max-width: 100%;
  margin: 0 !important;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

.page-header {
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 500;
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-menu-btn {
  display: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 18px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.last-update {
  font-size: 12px;
  color: var(--text-muted);
}

.page-content {
  padding: 20px 28px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* ═══════ CARDS ═══════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card:hover::before { opacity: 1; }

.stat-icon { font-size: 28px; margin-bottom: 8px; }

.stat-value {
  font-size: 32px;
  font-weight: 700;
  font-family: var(--font-en);
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* ═══════ DATA CARD ═══════ */
.data-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.data-card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.data-card-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.data-card-body { padding: 20px; }

/* ═══════ TABLE ═══════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: right;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.data-table tr:hover td {
  background: rgba(233, 69, 96, 0.04);
}

.data-table tr:last-child td { border-bottom: none; }

/* ═══════ FORMS ═══════ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-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-family: var(--font-ar);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

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

.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.form-textarea.prompt-editor {
  min-height: 300px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  direction: ltr;
  text-align: left;
}

/* ═══════ BUTTONS ═══════ */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-ar);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #c73e54);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--accent); }

.btn-success {
  background: linear-gradient(135deg, var(--accent-3), #05b388);
  color: white;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ═══════ BADGES ═══════ */
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-new { background: rgba(6, 214, 160, 0.15); color: var(--accent-3); }
.badge-active { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-vip { background: rgba(233, 69, 96, 0.15); color: var(--accent); }
.badge-blocked { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }
.badge-pending { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.badge-open { background: rgba(6, 214, 160, 0.15); color: var(--accent-3); }
.badge-closed { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }
.badge-escalated { background: rgba(233, 69, 96, 0.15); color: var(--accent); }

/* ═══════ CONFIG GRID ═══════ */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.config-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: var(--transition);
}

.config-item:hover { border-color: var(--border-active); }

.config-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.config-item-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.config-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.save-indicator {
  font-size: 11px;
  color: var(--accent-3);
  opacity: 0;
  transition: var(--transition);
}

.save-indicator.show { opacity: 1; }

/* ═══════ PROMPT TEMPLATES ═══════ */
.template-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.template-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.template-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══════ HERP SECTION ═══════ */
.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* ═══════ BOT TOGGLE SWITCH ═══════ */
.bot-toggle-container {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: 30px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.bot-toggle-container.test-mode-container {
  border-color: rgba(251, 191, 36, 0.3);
  background: linear-gradient(135deg, var(--bg-card), rgba(251, 191, 36, 0.05));
}

.bot-toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-3);
  transition: var(--transition);
}

.bot-toggle-label.disabled {
  color: var(--accent);
}

.bot-toggle-label.test-mode-label {
  color: #fbbf24;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--text-muted);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--accent-3), #05b388);
  box-shadow: 0 0 10px rgba(6, 214, 160, 0.4);
}

.switch-test input:checked + .slider {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--accent-3);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

.btn-icon-settings {
  background: none;
  border: none;
  font-size: 15px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 50%;
  transition: var(--transition);
  opacity: 0.8;
}

.btn-icon-settings:hover {
  opacity: 1;
  transform: rotate(45deg);
}

.herp-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.herp-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.herp-status-dot.connected { background: var(--accent-3); box-shadow: 0 0 8px rgba(6, 214, 160, 0.5); }
.herp-status-dot.disconnected { background: var(--text-muted); }

/* ═══════ TOAST ═══════ */
.toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: white;
  animation: slideIn 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.toast-success { background: linear-gradient(135deg, #06d6a0, #05b388); }
.toast-error { background: linear-gradient(135deg, var(--accent), #c73e54); }
.toast-info { background: linear-gradient(135deg, #3b82f6, #2563eb); }

@keyframes slideIn {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ═══════ MODAL ═══════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-start; }

/* ═══════ EMPTY STATE ═══════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-text { font-size: 16px; }

/* ═══════ LOADING ═══════ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════
   INSTAGRAM DIRECT CHAT & BRAIN ANALYSIS (Phase 10)
   ═══════════════════════════════════════════════════════════ */
.inbox-layout {
  display: flex;
  height: calc(100vh - 85px);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* ─── INBOX LIST (LEFT / RIGHT RTL) ─── */
.inbox-sidebar-list {
  width: 340px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #121222;
}

.inbox-search-box {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.inbox-threads {
  flex: 1;
  overflow-y: auto;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.thread-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.thread-item.active {
  background: linear-gradient(135deg, rgba(193, 53, 132, 0.15), rgba(131, 58, 180, 0.15));
  border-right: 3px solid #e1306c;
}

.ig-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.ig-avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: white;
}

.unread-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #0095f6;
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
}

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

.thread-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  justify-content: space-between;
}

.thread-time {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
}

.thread-last-msg {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-last-msg.unread {
  color: var(--text-primary);
  font-weight: 600;
}

/* ─── CHAT MAIN WINDOW ─── */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0b0b14;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.chat-header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-messages-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-row {
  display: flex;
  margin-bottom: 4px;
  align-items: flex-end;
  gap: 8px;
}

.msg-row.incoming {
  justify-content: flex-start;
}

.msg-row.outgoing {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 65%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: var(--transition);
}

.msg-row.incoming .msg-bubble {
  background: #262626;
  color: #efefef;
  border-bottom-right-radius: 4px;
}

.msg-row.outgoing .msg-bubble {
  background: linear-gradient(135deg, #c13584 0%, #833ab4 50%, #e1306c 100%);
  color: white;
  border-bottom-left-radius: 4px;
}

.msg-row.outgoing.draft .msg-bubble {
  background: #3a3a4c !important;
  color: #a0a0b0;
  border: 1px dashed var(--text-muted);
}

.msg-footer-info {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.8;
}

.msg-status-icon {
  font-size: 11px;
}

.msg-brain-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 10px;
  cursor: pointer;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.msg-brain-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* ─── BRAIN DRAWER / MODAL ─── */
.brain-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: flex;
  justify-content: flex-end;
}

.brain-panel {
  width: 480px;
  height: 100%;
  background: #141424;
  border-right: 1px solid var(--border);
  padding: 24px;
  overflow-y: auto;
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  animation: slideDrawer 0.3s ease-out;
}

@keyframes slideDrawer {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.brain-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.brain-step-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.confidence-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(6, 214, 160, 0.2);
  color: var(--accent-3);
}

.nav-badge {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: auto;
}

.nav-badge.hidden { display: none; }

/* ═══════════════════════════════════════════════════════════
   HERP Products View (Real ERP Design Clone)
   ═══════════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════════
   HERP / Real ERP Products — Exact Clone Design
   ═══════════════════════════════════════════════════════════ */

.herp-products-container {
  max-width: 780px;
  margin: 0 auto;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Header Card ── */
.herp-products-container .herp-header-card {
  background: #0c1220;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 28px 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.herp-products-container .herp-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 18px;
}

.herp-products-container .herp-title-box h1 {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 6px 0;
  line-height: 1.3;
}

.herp-products-container .herp-title-box p {
  font-size: 13.5px;
  color: #7b8a9e;
  margin: 0;
  line-height: 1.5;
}

.herp-products-container .herp-actions-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.herp-products-container .herp-btn-outline {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #d1d5db;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font-ar);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.herp-products-container .herp-btn-outline:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

/* ── Search ── */
.herp-products-container .herp-search-box {
  width: 100%;
}

.herp-products-container .herp-search-input {
  width: 100%;
  background: #060a11;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 14px 20px;
  color: #fff;
  font-size: 14px;
  font-family: var(--font-ar);
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.herp-products-container .herp-search-input::placeholder {
  color: #5a6577;
}

.herp-products-container .herp-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ── Add Product Collapsible ── */
.herp-products-container .herp-add-collapsible {
  background: #0c1220;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  overflow: hidden;
}

.herp-products-container .herp-add-trigger {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: transparent;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  font-family: var(--font-ar);
  border: none;
  width: 100%;
  transition: background 0.2s ease;
}

.herp-products-container .herp-add-trigger:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ── Products Grid ── */
.herp-products-container .herp-product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Product Card ── */
.herp-products-container .herp-product-card {
  background: #0c1220;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.herp-products-container .herp-product-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

/* ── Card Top Row: Image + Name + Dots ── */
.herp-products-container .herp-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.herp-products-container .herp-card-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.herp-products-container .herp-product-img {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: #141c2e;
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.herp-products-container .herp-product-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.herp-products-container .herp-badge-tag {
  background-color: #a37d2c;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
}

.herp-products-container .herp-category-sub {
  font-size: 12.5px;
  color: #7b8a9e;
  font-weight: 500;
}

/* ── Three Dots Menu ── */
.herp-products-container .herp-card-actions-menu {
  flex-shrink: 0;
}

.herp-products-container .herp-btn-dots {
  background: transparent;
  border: none;
  color: #7b8a9e;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  line-height: 1;
  transition: all 0.15s ease;
  font-weight: bold;
  letter-spacing: 1px;
}

.herp-products-container .herp-btn-dots:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

/* ── Card Bottom Row: Badges + Switch + Price ── */
.herp-products-container .herp-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
  gap: 10px;
}

.herp-products-container .herp-badges-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Description Snippet & Sizes Badges ── */
.herp-products-container .herp-desc-text {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
  line-height: 1.45;
  white-space: pre-line;
  background: rgba(255, 255, 255, 0.02);
  border-right: 2px solid rgba(255, 255, 255, 0.15);
  padding: 4px 8px;
  border-radius: 0 6px 6px 0;
  max-width: 480px;
}

.herp-products-container .herp-sizes-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.herp-products-container .herp-sizes-label {
  font-size: 11.5px;
  color: #64748b;
  font-weight: 600;
}

.herp-products-container .herp-size-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.28);
  font-family: var(--font-en), sans-serif;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
}

.herp-products-container .herp-pill-materials {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #94a3b8;
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-family: var(--font-ar);
  white-space: nowrap;
}

.herp-products-container .herp-pill-synced {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.30);
  color: #10b981;
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-family: var(--font-ar);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* ── Price + Switch Group ── */
.herp-products-container .herp-price-switch-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.herp-products-container .herp-switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  direction: rtl;
}

.herp-products-container .herp-switch-label {
  font-size: 13.5px;
  font-weight: 700;
  font-family: var(--font-ar);
  user-select: none;
  transition: color 0.2s ease;
}

.herp-products-container .herp-switch-label.active {
  color: #10b981 !important;
}

.herp-products-container .herp-switch-label.draft {
  color: #94a3b8 !important;
}

/* ── Toggle Switch (Matching Real ERP / Radix UI Switch) ── */
.herp-products-container .herp-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  direction: ltr !important;
}

.herp-products-container .herp-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.herp-products-container .herp-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #27272a !important; /* Zinc 800 Unchecked background */
  background-image: none !important;
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  border-radius: 9999px !important;
  box-shadow: none !important;
}

.herp-products-container .herp-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff !important; /* Pure White Thumb */
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  border-radius: 50% !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

.herp-products-container .herp-switch input:checked + .herp-slider {
  background-color: #10b981 !important; /* Emerald Green Checked background */
  background-image: none !important;
  box-shadow: none !important;
}

.herp-products-container .herp-switch input:checked + .herp-slider:before {
  transform: translateX(20px) !important;
  background-color: #ffffff !important;
}

/* ── Price Tag ── */
.herp-products-container .herp-price-tag {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  font-family: var(--font-en), var(--font-ar);
  white-space: nowrap;
  letter-spacing: -0.3px;
}

/* ── Sub Products (جزء من منتج) ── */
.herp-products-container .herp-chevron-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.herp-products-container .herp-chevron-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.herp-products-container .herp-sub-products-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-right: 24px;
  margin-top: 6px;
  margin-bottom: 6px;
}

.herp-products-container .herp-sub-product-card {
  background: #090e17;
  border: 1px solid #7d1818;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
}

.herp-products-container .herp-sub-product-card:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

.herp-products-container .herp-sub-badge-tag {
  color: #ffffff;
  padding: 6px 18px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14.5px;
  display: block;
  text-align: right;
  line-height: 1.4;
  white-space: nowrap;
  flex: 1;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .herp-products-container {
    padding: 0 4px;
  }
  
  .herp-products-container .herp-header-card {
    padding: 18px 16px 14px;
  }
  
  .herp-products-container .herp-product-card {
    padding: 16px;
  }

  .herp-products-container .herp-sub-products-group {
    margin-right: 12px;
  }

  .herp-products-container .herp-sub-product-card {
    padding: 12px 14px;
  }
  
  .herp-products-container .herp-header-top {
    flex-direction: column;
  }
  
  .herp-products-container .herp-card-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .herp-products-container .herp-price-switch-group {
    width: 100%;
    justify-content: space-between;
  }
  
  .herp-products-container .herp-product-img {
    width: 52px;
    height: 52px;
  }
}

/* ═══════ ADS AI DASHBOARD STYLES ═══════ */
.ads-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  margin-bottom: 20px;
  width: 100%;
}
.ads-subtab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.02);
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.ads-subtab:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}
.ads-subtab.active {
  background: linear-gradient(135deg, rgba(233, 69, 96, 0.2), rgba(124, 58, 237, 0.2));
  color: #fff;
  border-color: rgba(233, 69, 96, 0.4);
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.ads-subtab-icon { font-size: 15px; }
.subtab-badge, #pending-ads-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ads-subtab-content { min-height: 300px; width: 100%; max-width: 100%; }

/* KPI Grid */
.ads-kpi-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 16px; margin-bottom: 20px; }
@media (max-width: 768px) { .ads-kpi-grid { grid-template-columns: repeat(2, 1fr) !important; } }
.ads-kpi { text-align: center; }
.ads-kpi .stat-value { font-size: 1.6em; }

/* Highlight cards */
.ads-highlight-card { transition: transform 0.15s; }
.ads-highlight-card:hover { transform: translateY(-2px); }
.ads-mini-stats { display: flex; gap: 16px; font-size: 13px; color: var(--text-muted); }

/* Spend bar */
.ads-spend-bar { height: 12px; background: rgba(255,255,255,0.08); border-radius: 6px; overflow: hidden; }
.ads-spend-bar-fill { height: 100%; border-radius: 6px; transition: width 0.6s ease; }

/* Guardrails grid */
.ads-guardrails-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* Agent mode buttons */
.ads-mode-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 768px) { .ads-mode-buttons { grid-template-columns: 1fr; } }
.ads-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  border: 2px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
  font-family: 'Cairo', sans-serif;
}
.ads-mode-btn:hover { border-color: var(--mode-color); background: rgba(255,255,255,0.05); }
.ads-mode-btn.active { border-color: var(--mode-color); background: rgba(255,255,255,0.08); box-shadow: 0 0 20px rgba(0,0,0,0.3); }

/* Permissions */
.ads-permissions-grid { display: flex; flex-direction: column; gap: 12px; }
.ads-permission-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
}

/* Pending actions */
.ads-pending-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-wrap: wrap;
  gap: 10px;
}
.ads-pending-info { flex: 1; }
.ads-pending-btns { display: flex; gap: 8px; }

/* Creative grid */
.ads-creative-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 16px;
}
.ads-creative-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.ads-creative-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.ads-creative-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
}
.ads-creative-type { font-size: 20px; }
.ads-creative-body { padding: 12px 16px; }
.ads-creative-stats {
  display: flex;
  justify-content: space-around;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255,255,255,0.05);
}
.ads-creative-actions { padding: 12px 16px; }

/* Health bar */
.ads-health-bar { height: 4px; background: rgba(255,255,255,0.08); margin: 0 16px; border-radius: 2px; }
.ads-health-fill { height: 100%; border-radius: 2px; transition: width 0.4s; }

/* Purple badge for agent */
.badge-purple { background: rgba(124, 58, 237, 0.2); color: #a78bfa; }

/* Large button variant */
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ═══════ RESPONSIVE BREAKPOINTS ═══════ */
@media (max-width: 1280px) {
  .ads-subtabs { gap: 6px; }
  .ads-subtab { padding: 6px 12px; font-size: 12px; }
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(100%);
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: flex;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .main-content {
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  .page-header {
    padding: 14px 18px;
  }
  .page-content {
    padding: 16px;
  }
}

@media (max-width: 768px) {
  .header-actions {
    width: 100%;
    justify-content: space-between;
    margin-top: 6px;
  }
  .bot-toggle-container {
    padding: 4px 8px;
  }
  .ads-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 480px) {
  .ads-kpi-grid {
    grid-template-columns: 1fr !important;
  }
  .ads-subtabs {
    flex-direction: column;
  }
  .ads-subtab {
    width: 100%;
    justify-content: flex-start;
  }
}
