/* ==========================================================================
   Agribegri Admin — Design System
   ========================================================================== */

:root {
  /* Brand */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --secondary: #10b981;

  /* WhatsApp accent (used sparingly for chat-preview / send actions) */
  --whatsapp: #25d366;
  --whatsapp-dark: #19c37d;

  /* Semantic */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-text: #15803d;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-text: #b45309;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --info: #4f46e5;
  --info-bg: #e0e7ff;
  --info-text: #4338ca;
  --neutral-bg: #f1f5f9;
  --neutral-text: #64748b;

  /* Surfaces */
  --color-bg: #f6f7fb;
  --color-surface: #ffffff;
  --color-border: #e7e9f0;
  --color-border-strong: #dde1ea;

  /* Text */
  --dark: #0f172a;
  --text-main: #334155;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --gray: #64748b;
  --light: #f8fafc;
  --bg-main: var(--color-bg);

  /* Sidebar */
  --sidebar-bg: #14161f;
  --sidebar-bg-alt: #191b26;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: rgba(79, 70, 229, 0.16);
  --sidebar-text: #9297ab;
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 80px;
  --topbar-h: 68px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--color-bg);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* Animations */
.fade-in { animation: revealUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes revealUp {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered entrance for card grids (message templates, etc.) */
.card-in { animation: cardIn 0.42s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-alt) 100%);
  color: var(--sidebar-text);
  min-height: 100vh;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
  box-shadow: var(--shadow-md);
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  overflow: hidden;
  white-space: nowrap;
}

.brand-mark {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.45);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  transition: opacity 0.15s ease;
}
.brand-text .brand-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.2px;
}
.brand-text .brand-subtitle {
  font-size: 0.68rem;
  font-weight: 600;
  color: #7d8296;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 2px;
}

.sidebar-section-label {
  padding: 18px 24px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #565b70;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 14px;
}

.sidebar .nav-link {
  color: var(--sidebar-text);
  padding: 11px 12px;
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.885rem;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.18s ease, color 0.18s ease;
}

.sidebar .nav-link:hover {
  color: #fff;
  background: var(--sidebar-hover);
}

.sidebar .nav-link.active {
  color: var(--sidebar-text-active);
  background: var(--sidebar-active-bg);
  font-weight: 600;
}

.sidebar .nav-link .nav-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
}

.sidebar .nav-link.active .nav-icon { color: #a5b4fc; }

.sidebar .nav-label { transition: opacity 0.15s ease; }

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

.sidebar-toggle-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: #7d8296;
  padding: 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  font-size: 0.82rem;
  font-weight: 600;
}
.sidebar-toggle-btn:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-toggle-btn i { transition: transform 0.25s ease; }

/* Collapsed state */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .main-content { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-toggle-btn .toggle-label {
  display: none;
}
body.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding: 11px 0; }
body.sidebar-collapsed .sidebar-toggle-btn i { transform: rotate(180deg); }

/* ==========================================================================
   Main content / Topbar
   ========================================================================== */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

.topbar {
  background: var(--color-surface);
  height: var(--topbar-h);
  padding: 0 28px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar-left { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.topbar-left h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--dark);
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-left p {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin: 1px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

.icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.18s ease;
}
.icon-btn:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }

.notif-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--color-surface);
}

.notif-menu { width: 260px; padding: 8px; border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.notif-empty { text-align: center; padding: 26px 10px; color: var(--text-tertiary); }
.notif-empty i { font-size: 1.4rem; opacity: 0.5; margin-bottom: 8px; display: block; }
.notif-empty p { margin: 0; font-size: 0.82rem; }

.topbar-divider { width: 1px; height: 26px; background: var(--color-border); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  padding: 4px 6px 4px 4px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.18s ease;
}
.user-chip:hover { background: var(--color-bg); }

.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.25; }
.user-name { font-size: 0.84rem; font-weight: 700; color: var(--dark); }
.user-role { font-size: 0.72rem; color: var(--text-tertiary); }

.chip-caret { font-size: 0.65rem; color: var(--text-tertiary); margin-left: 2px; }

.user-menu { width: 230px; padding: 8px; border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.user-menu-header { display: flex; align-items: center; gap: 12px; padding: 8px 10px 12px; }
.user-menu .dropdown-divider { margin: 4px 0; }
.logout-form { margin: 0; }
.logout-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.logout-item:hover { background: var(--danger-bg); }

.content-wrapper {
  padding: 28px;
  flex: 1;
}

@media (max-width: 767px) {
  .user-meta { display: none; }
  .content-wrapper { padding: 18px; }
  .topbar { padding: 0 16px; }
}

/* ==========================================================================
   Stat / KPI cards (shared across dashboard, complaints, etc.)
   ========================================================================== */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-2px); }

.stat-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.stat-card__icon--indigo { background: var(--info-bg); color: var(--info-text); }
.stat-card__icon--amber  { background: var(--warning-bg); color: var(--warning-text); }
.stat-card__icon--green  { background: var(--success-bg); color: var(--success-text); }
.stat-card__icon--red    { background: var(--danger-bg); color: var(--danger-text); }
.stat-card__icon--slate  { background: var(--neutral-bg); color: var(--neutral-text); }

.stat-card__body { min-width: 0; }
.stat-card__label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.stat-card__value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
  margin-bottom: 5px;
}
.stat-card__hint { font-size: 0.74rem; color: var(--text-tertiary); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1024px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .stat-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   Panel (boxed section) — used for dashboard widgets, detail cards, settings
   ========================================================================== */
.panel,
.detail-card,
.settings-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.panel-header,
.detail-card .card-head,
.settings-card .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border);
}
.panel-header h2 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--dark);
  margin: 0;
}
.panel-header a {
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.panel-header a:hover { text-decoration: underline; }

.card-body-pad, .panel-body { padding: 22px 24px; }

.detail-card .card-head .icon-wrap,
.settings-card .card-head .icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.bottom-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
@media (max-width: 1024px) { .bottom-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   Media upload dropzone (template form, etc.)
   ========================================================================== */
.upload-dropzone {
  position: relative;
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 26px 20px;
  text-align: center;
  background: var(--color-bg);
  transition: border-color 0.2s ease, background 0.2s ease;
  cursor: pointer;
}
.upload-dropzone:hover, .upload-dropzone.has-file { border-color: var(--primary-100); background: var(--primary-50); }
.upload-dropzone i { font-size: 1.6rem; color: var(--text-tertiary); margin-bottom: 8px; display: block; }
.upload-dropzone p { margin: 0; font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.upload-dropzone .upload-hint { font-size: 0.74rem; color: var(--text-tertiary); font-weight: 400; margin-top: 3px; }
.upload-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0 !important;
}
.upload-filename {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 8px;
  text-align: center;
}

/* Sticky live preview (template form) */
.template-preview-sticky { position: sticky; top: calc(var(--topbar-h) + 20px); }
.preview-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}
.preview-label::after { content: ''; flex: 1; height: 1px; background: var(--color-border); }

/* ==========================================================================
   Data table
   ========================================================================== */
.data-table, table.data-table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0;
}
.data-table thead th {
  padding: 11px 24px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #fafbfc;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid #f1f3f7; transition: background 0.15s; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr.is-clickable { cursor: pointer; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table td { padding: 13px 24px; color: var(--text-main); vertical-align: middle; }
.data-table td a { color: var(--primary); font-weight: 600; text-decoration: none; }
.data-table td a:hover { text-decoration: underline; }
.data-table .empty-row td { padding: 0; }

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-tertiary); }
.empty-state .empty-icon { font-size: 2.6rem; opacity: 0.25; margin-bottom: 14px; }
.empty-state p { margin: 0; font-size: 0.88rem; }
.empty-state h5 { color: var(--dark); font-weight: 700; }

/* ==========================================================================
   Badges / status pills
   ========================================================================== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-status.pending, .status-PENDING { background: var(--warning-bg); color: var(--warning-text); }
.badge-status.resolved, .status-RESOLVED { background: var(--success-bg); color: var(--success-text); }
.badge-status.draft, .status-DRAFT_CATEGORY, .status-DRAFT_MEDIA { background: var(--info-bg); color: var(--info-text); }
.status-FAILED { background: var(--danger-bg); color: var(--danger-text); }
.status-STOPPED, .status-NONE { background: var(--neutral-bg); color: var(--neutral-text); }
.status-STARTING, .status-UNKNOWN { background: var(--info-bg); color: var(--info-text); }
.status-SCAN_QR_CODE { background: var(--warning-bg); color: var(--warning-text); }
.status-WORKING { background: var(--success-bg); color: var(--success-text); }

/* Status pill w/ pulsing dot (settings page connectivity) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.3px;
}
.status-pill .dot { width: 9px; height: 9px; border-radius: 50%; }
.status-pill.status-WORKING .dot { animation: pulseAnim 1.5s infinite; background: var(--success); }
.status-pill.status-SCAN_QR_CODE .dot { background: var(--warning); }
.status-pill.status-STOPPED .dot, .status-pill.status-NONE .dot { background: #aaa; }
.status-pill.status-FAILED .dot { background: var(--danger); }
.status-pill.status-STARTING .dot, .status-pill.status-UNKNOWN .dot { background: var(--info); }

@keyframes pulseAnim {
  0%   { box-shadow: 0 0 0 0 rgba(22,163,74,0.4); }
  70%  { box-shadow: 0 0 0 8px rgba(22,163,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}

.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  animation: pulseAnim 1.5s infinite;
  flex-shrink: 0;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  border-radius: var(--radius-sm) !important;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.18s ease;
}
.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
}
.btn-outline-secondary { border-color: var(--color-border-strong); color: var(--text-secondary); }
.btn-outline-secondary:hover { background: var(--color-bg); color: var(--dark); border-color: var(--color-border-strong); }
.btn-outline-primary { border-color: var(--primary-100); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); transform: translateY(-1px); }
.btn-outline-danger { border-color: #fecaca; color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); }
.btn:disabled, .btn.disabled { transform: none !important; box-shadow: none !important; }

/* Action buttons (settings session controls) */
.action-btn {
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.83rem;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}
.action-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-start   { background: var(--success); }
.btn-stop    { background: var(--warning); }
.btn-restart { background: var(--primary); }
.btn-create  { background: var(--success); }
.btn-logout  { background: var(--danger-bg); color: var(--danger); }
.btn-logout:hover { background: #fecaca; }
.btn-delete  { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca !important; }

.resolve-btn {
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 26px;
  font-weight: 700;
  font-size: 0.87rem;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.resolve-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(22,163,74,0.28); }

.send-btn {
  background: var(--whatsapp-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 26px;
  font-weight: 700;
  font-size: 0.87rem;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.send-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(25,195,125,0.3); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-control, .form-select {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  font-size: 0.88rem;
  transition: all 0.18s ease;
  color: var(--text-main);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}
.form-label { font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.form-text { font-size: 0.78rem; color: var(--text-tertiary); }
textarea.form-control { resize: vertical; }

.input-group-text { background: var(--color-bg); border-color: var(--color-border-strong); color: var(--text-tertiary); }

/* Filter buttons + search (complaints page) */
.filter-btn {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--color-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.filter-btn:hover { border-color: var(--primary-100); color: var(--primary); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.search-bar {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 0.86rem;
  width: 260px;
  outline: none;
  transition: border-color 0.2s ease;
  background: var(--color-surface);
}
.search-bar:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }

/* Toast alerts */
.toast-alert {
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  padding: 12px 18px;
  border: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-alert.success { background: var(--success-bg); color: var(--success-text); }
.toast-alert.error { background: var(--danger-bg); color: var(--danger-text); }

/* ==========================================================================
   Info rows (complaint detail)
   ========================================================================== */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f4f5f8;
  font-size: 0.88rem;
  gap: 12px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-tertiary); font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.info-value { font-weight: 600; color: var(--dark); text-align: right; }

.back-link { color: var(--text-tertiary); font-size: 0.85rem; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.back-link:hover { color: var(--dark); }

/* ==========================================================================
   QR / bot status widgets
   ========================================================================== */
#qrCodeContainer {
  text-align: center;
  padding: 20px;
  background: linear-gradient(135deg, #f8fffe, #f0fdf4);
  border: 1.5px dashed var(--whatsapp-dark);
  border-radius: var(--radius-md);
  margin-top: 20px;
}
#qrCodeDiv canvas, #qrCodeDiv img { border-radius: 10px; }

.bot-status-bar {
  margin: 12px 16px 16px;
  background: var(--success-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.bot-label strong { font-size: 0.82rem; color: var(--success-text); display: block; }
.bot-label span { font-size: 0.75rem; color: #86efac; }

/* Quick action list (dashboard) */
.action-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  transition: all 0.15s ease;
  background: var(--color-surface);
}
.action-item:hover { background: var(--color-bg); border-color: var(--primary-100); color: var(--primary); }
.action-item .ai-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.ai-icon.indigo { background: var(--info-bg); color: var(--info-text); }
.ai-icon.amber  { background: var(--warning-bg); color: var(--warning-text); }
.ai-icon.green  { background: var(--success-bg); color: var(--success-text); }
.ai-icon.blue   { background: #dbeafe; color: #2563eb; }

/* ==========================================================================
   Login page
   ========================================================================== */
.login-container { min-height: 100vh; display: flex; }

.login-image {
  flex: 1.2;
  background:
    linear-gradient(135deg, rgba(20, 22, 31, 0.92), rgba(79, 70, 229, 0.88)),
    url('https://images.unsplash.com/photo-1596524430615-b46475ddff6e?auto=format&fit=crop&q=80') center/cover;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding: 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Floating blurred blobs — slow ambient drift behind the content */
.login-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.45;
  pointer-events: none;
  animation: blobFloat 13s ease-in-out infinite;
}
.login-blob--1 {
  width: 280px; height: 280px; top: -70px; left: -60px;
  background: radial-gradient(circle, rgba(255,255,255,0.55), rgba(255,255,255,0) 70%);
}
.login-blob--2 {
  width: 240px; height: 240px; bottom: -70px; right: -50px;
  background: radial-gradient(circle, rgba(139,92,246,0.55), rgba(139,92,246,0) 70%);
  animation-duration: 16s;
  animation-delay: -5s;
}
.login-blob--3 {
  width: 180px; height: 180px; top: 45%; left: 55%;
  background: radial-gradient(circle, rgba(37,211,102,0.4), rgba(37,211,102,0) 70%);
  animation-duration: 11s;
  animation-delay: -2s;
}
@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(24px, -26px) scale(1.08); }
}

/* Floating feature chips — drift gently, purely decorative */
.login-float {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.22);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  pointer-events: none;
  animation: floatDrift 6.5s ease-in-out infinite;
}
.login-float i { color: rgba(255,255,255,0.85); font-size: 0.72rem; }
.login-float--1 { top: 12%; left: 8%; animation-delay: 0s; }
.login-float--2 { top: 60%; right: 6%; animation-delay: 1.4s; }
.login-float--3 { bottom: 10%; left: 12%; animation-delay: 2.8s; }
@keyframes floatDrift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

.login-content { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; }

.login-logo-mark {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 28px;
  backdrop-filter: blur(6px);
  animation: logoGlow 3s ease-in-out infinite;
}
@keyframes logoGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.22); }
  50% { box-shadow: 0 0 0 14px rgba(255,255,255,0); }
}

.login-image h1 {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}
.login-image p {
  font-size: 1.05rem;
  opacity: 0.85;
  max-width: 420px;
  line-height: 1.6;
}

.login-feature-list {
  list-style: none;
  padding: 0;
  margin: 26px 0 0;
  display: inline-flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.login-feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.9);
  opacity: 0;
  animation: featureIn 0.5s ease forwards;
}
.login-feature-list li .li-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  flex-shrink: 0;
}
@keyframes featureIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.login-form-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  position: relative;
}

.login-box { width: 100%; max-width: 400px; padding: 40px; }

.login-box .login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-50);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 18px;
}

.login-box h2 { font-weight: 800; font-size: 1.7rem; margin-bottom: 6px; color: var(--dark); }
.login-box .subtitle { color: var(--text-tertiary); margin-bottom: 28px; font-size: 0.9rem; }

/* Icon-prefixed inputs (username / password) */
.input-icon-field { position: relative; display: flex; align-items: center; }
.input-icon-field > i.field-icon {
  position: absolute;
  left: 14px;
  color: var(--text-tertiary);
  font-size: 0.85rem;
  pointer-events: none;
}
.input-icon-field .form-control { padding-left: 40px; }
.input-icon-field.password-field .form-control { padding-right: 44px; }

.password-toggle-btn {
  position: absolute;
  right: 4px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.password-toggle-btn:hover { color: var(--primary); background: var(--primary-50); }

@media (max-width: 900px) {
  .login-image { display: none; }
}

/* ==========================================================================
   Login success overlay (shown once on the page the user lands on right
   after a successful login — see base.html)
   ========================================================================== */
.login-success-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 17, 23, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: overlayFadeIn 0.25s ease both;
}
.login-success-overlay[hidden] { display: none; }
.login-success-overlay.is-leaving { animation: overlayFadeOut 0.35s ease forwards; }
@keyframes overlayFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayFadeOut { to { opacity: 0; } }

.login-success-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: successPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes successPop {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.success-check { width: 84px; height: 84px; }
.success-check__circle { fill: var(--success); }
.success-check__mark {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 34;
  stroke-dashoffset: 34;
  animation: successMark 0.4s 0.25s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}
@keyframes successMark { to { stroke-dashoffset: 0; } }

.success-text { color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: 0.2px; }

/* ==========================================================================
   WhatsApp template preview cards
   ========================================================================== */
/* Masonry-style packing so shorter cards don't leave a blank gap under
   themselves just because a taller card sits in the same row (CSS grid
   locks row height to its tallest item — a multi-column flow avoids that). */
.template-grid {
  column-width: 340px;
  column-gap: 22px;
}

.template-card {
  background-color: #efeae2;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xs);
  position: relative;
  border: 1px solid rgba(0,0,0,0.05);
  overflow: hidden;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin-bottom: 22px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.template-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.chat-bubble {
  background-color: #ffffff;
  border-radius: 0 12px 12px 12px;
  padding: 14px;
  margin: 22px 20px 18px 30px;
  position: relative;
  z-index: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-size: 14px;
  line-height: 1.5;
}

.chat-bubble::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 0;
  width: 0;
  height: 0;
  border-top: 12px solid #ffffff;
  border-left: 12px solid transparent;
}

.chat-image { width: 100%; border-radius: 8px; margin-bottom: 12px; object-fit: cover; max-height: 200px; }
.chat-text { color: #111b21; white-space: pre-wrap; }
.chat-text strong { font-weight: 700; }
.chat-text em { font-style: italic; }
.chat-text s { opacity: 0.75; }
.chat-text code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.88em;
}

.chat-buttons {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid #f0f2f5;
  padding-top: 10px;
}
.chat-btn {
  background-color: #ffffff;
  color: var(--whatsapp-dark);
  padding: 10px 14px;
  text-align: center;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.87rem;
  border: 1px solid #e9edef;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chat-btn:hover { background: #f7fdfb; border-color: #cdeee1; }
.chat-btn i { font-size: 0.75rem; opacity: 0.75; }

.template-footer {
  background-color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px solid #f0f2f5;
  z-index: 1;
  flex-wrap: wrap;
  gap: 10px;
}
.template-footer h4 { margin: 0; font-size: 0.95rem; font-weight: 700; color: #111b21; }
.template-badge {
  background-color: var(--neutral-bg);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--neutral-text);
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.template-badge.template-badge--accent { background: var(--info-bg); color: var(--info-text); }
