/* RAFIQ design tokens — never hardcode colors in templates. */
:root {
  --rafiq-primary: #1565C0;
  --rafiq-sidebar-bg: #0D1B2A;
  --rafiq-sidebar-text: #CBD5E1;
  --rafiq-sidebar-active: #1E3A5F;
  --rafiq-bg: #F8FAFC;
  --rafiq-surface: #FFFFFF;
  --rafiq-border: #E2E8F0;
  --rafiq-text: #1E293B;
  --rafiq-text-muted: #64748B;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --rafiq-sidebar-width: 260px;

  /* Status */
  --rafiq-status-open: #1565C0;         /* blue */
  --rafiq-status-in-progress: #D4A017;  /* yellow */
  --rafiq-status-waiting: #E67E22;      /* orange */
  --rafiq-status-resolved: #2E7D32;     /* green */
  --rafiq-status-closed: #6B7280;       /* gray */

  /* Priority */
  --rafiq-priority-low: #6B7280;        /* gray */
  --rafiq-priority-medium: #1565C0;     /* blue */
  --rafiq-priority-high: #E67E22;       /* orange */
  --rafiq-priority-urgent: #C62828;     /* red */

  /* Accent */
  --rafiq-warning: #CA8A04;
  --rafiq-warning-border: #FACC15;
  --rafiq-warning-bg: #FFFBEB;

  /* Roles — RAFIQ has no purple by design; super_admin = indigo. */
  --rafiq-role-super-admin: #4F46E5;  /* indigo */
  --rafiq-role-manager: #1565C0;      /* blue */
  --rafiq-role-supervisor: #0E9488;   /* teal */
  --rafiq-role-agent: #14B8A6;        /* teal-light */
  --rafiq-role-customer: #6B7280;     /* gray */

  /* User status */
  --rafiq-user-active: #16A34A;       /* green */
  --rafiq-user-inactive: #DC2626;     /* red */

  /* Settings (TASK-11) — RAFIQ teal accent for the settings page only,
     all other surfaces stay on the existing blue/sidebar palette. */
  --rafiq-teal: #01696F;
  --rafiq-teal-soft: #F0FAFA;
  --rafiq-row-hover: #F9FAFB;
  --rafiq-drawer-backdrop: rgba(0, 0, 0, 0.3);
  --rafiq-danger: #DC2626;
  --rafiq-danger-bg: #FEF2F2;

  /* Notifications (TASK-15) — bell, dropdown, mention dot. The
     ``--accent`` and ``--warning`` aliases match the names called for
     in the spec; both are token-driven (no hex literals in markup). */
  --accent: #01696F;
  --accent-hover: #018a91;
  --warning: #F59E0B;
  --text-muted: #64748B;
}

html, body {
  height: 100%;
}

body {
  background-color: var(--rafiq-bg);
  color: var(--rafiq-text);
  font-family: "Tajawal", "Cairo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--rafiq-primary);
}

/* Primary button uses the brand token. */
.btn-rafiq-primary {
  background-color: var(--rafiq-primary);
  border-color: var(--rafiq-primary);
  color: #fff;
  transition: filter var(--transition);
}
.btn-rafiq-primary:hover,
.btn-rafiq-primary:focus {
  background-color: var(--rafiq-primary);
  border-color: var(--rafiq-primary);
  color: #fff;
  filter: brightness(0.92);
}

/* ======= Export dropdown (TASK-16) =======
 * Outlined sibling of the primary action button. Used for the
 * "تصدير" dropdown on the Tickets / Customers / Reports list pages.
 * All colours flow through the existing design tokens — no hex
 * literals here, so the dark-mode override block at the bottom of
 * this file gets contrast right for free.
 */
.rafiq-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: transparent;
  color: var(--rafiq-primary);
  border: 1px solid var(--rafiq-primary);
  font-weight: 500;
  transition: background-color var(--transition), color var(--transition);
}
.rafiq-export-btn:hover,
.rafiq-export-btn:focus {
  background-color: var(--rafiq-primary);
  color: #fff;
}
.rafiq-export-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.rafiq-export-menu .dropdown-item i {
  color: var(--rafiq-primary);
}

/* ======= Auth layout ======= */
.rafiq-auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.rafiq-auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 14px;
  padding: 2rem 1.75rem;
  box-shadow: 0 10px 30px rgba(13, 27, 42, 0.06);
}

.rafiq-auth-logo {
  color: var(--rafiq-primary);
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 1.75rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

/* ======= App shell ======= */
.rafiq-shell {
  display: flex;
  min-height: 100vh;
}

.rafiq-sidebar {
  width: var(--rafiq-sidebar-width);
  flex-shrink: 0;
  background: var(--rafiq-sidebar-bg);
  color: var(--rafiq-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  /* Physical-property layout (NOT logical) on purpose:
       RTL  →  sidebar anchored right, margin-right on main.
       LTR  →  sidebar anchored left,  margin-left  on main
               (the [dir="ltr"] override block below flips both).
     Logical-property pairs (inset-inline-* / margin-inline-*) resolved
     inconsistently across Chrome between fixed-position insets and
     flow margins on the same element, which let main content slide
     under the sidebar in RTL. Physical sides keep the two aligned
     regardless of dir / writing-mode. */
  right: 0;
  padding: 1.25rem 0;
}

.rafiq-main {
  flex: 1;
  /* Default = RTL (project baseline). [dir="ltr"] override below
     swaps to margin-left so content clears the left-anchored sidebar. */
  margin-right: var(--rafiq-sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rafiq-topbar {
  background: var(--rafiq-surface);
  border-bottom: 1px solid var(--rafiq-border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rafiq-content {
  padding: 1.5rem;
  flex: 1;
}

/* ======= Sidebar ======= */
.rafiq-sidebar-logo {
  color: #fff;
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 1.5rem;
  padding: 0.25rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rafiq-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.5rem;
  gap: 0.125rem;
  flex: 1;
}

.rafiq-nav-footer {
  padding: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.rafiq-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  color: var(--rafiq-sidebar-text);
  text-decoration: none;
  transition: background-color var(--transition), color var(--transition);
  font-size: 0.95rem;
}
.rafiq-nav a:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}
.rafiq-nav a.active {
  background: var(--rafiq-sidebar-active);
  color: #fff;
}
.rafiq-nav i {
  font-size: 1.1rem;
  line-height: 1;
}

/* ======= Status & priority badges ======= */
.rafiq-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
}
/* Status */
.rafiq-status-open { background: var(--rafiq-status-open); }
.rafiq-status-in_progress { background: var(--rafiq-status-in-progress); }
.rafiq-status-waiting { background: var(--rafiq-status-waiting); }
.rafiq-status-resolved { background: var(--rafiq-status-resolved); }
.rafiq-status-closed { background: var(--rafiq-status-closed); }
/* Priority */
.rafiq-priority-low { background: var(--rafiq-priority-low); }
.rafiq-priority-medium { background: var(--rafiq-priority-medium); }
.rafiq-priority-high { background: var(--rafiq-priority-high); }
.rafiq-priority-urgent { background: var(--rafiq-priority-urgent); }
/* Accent */
.rafiq-badge-internal { background: var(--rafiq-warning); }
/* Roles */
.rafiq-role-super_admin { background: var(--rafiq-role-super-admin); }
.rafiq-role-manager { background: var(--rafiq-role-manager); }
.rafiq-role-supervisor { background: var(--rafiq-role-supervisor); }
.rafiq-role-agent { background: var(--rafiq-role-agent); }
.rafiq-role-customer { background: var(--rafiq-role-customer); }
/* User status */
.rafiq-user-active { background: var(--rafiq-user-active); }
.rafiq-user-inactive { background: var(--rafiq-user-inactive); }

/* ======= Tickets table ======= */
.rafiq-table {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  overflow: hidden;
}
.rafiq-table table {
  margin: 0;
}
.rafiq-table tbody tr {
  cursor: pointer;
  transition: background-color var(--transition);
}
.rafiq-table tbody tr:hover {
  background: rgba(21, 101, 192, 0.04);
}

.rafiq-empty-state {
  background: var(--rafiq-surface);
  border: 1px dashed var(--rafiq-border);
  border-radius: 12px;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--rafiq-text-muted);
}
.rafiq-empty-state i {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

/* ======= Ticket detail ======= */
.rafiq-ticket-panel {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  padding: 1.5rem;
}
.rafiq-comment {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.rafiq-comment.is-internal {
  border-color: var(--rafiq-warning-border);
  background: var(--rafiq-warning-bg);
}
.rafiq-comment-meta {
  color: var(--rafiq-text-muted);
  font-size: 0.85rem;
}

/* ======= Dashboard stat cards ======= */
.rafiq-stat-card {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: transform var(--transition), box-shadow var(--transition);
}
.rafiq-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13, 27, 42, 0.05);
}
.rafiq-stat-label {
  color: var(--rafiq-text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.rafiq-stat-value {
  color: var(--rafiq-text);
  font-weight: 700;
  font-size: 2rem;
}

/* ======= Dashboard charts ======= */
.rafiq-chart-card {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}
.rafiq-chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--rafiq-text);
  margin: 0 0 1rem 0;
}
.rafiq-chart-body {
  position: relative;
  height: 260px;
  flex: 1;
}
.rafiq-chart-body--tall {
  height: 320px;
}
.rafiq-stat-unit {
  font-size: 1rem;
  color: var(--rafiq-text-muted);
  font-weight: 500;
  margin-right: 0.35rem;
}
.rafiq-filter-bar {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.rafiq-chart-empty {
  color: var(--rafiq-text-muted);
  text-align: center;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--rafiq-border);
  border-radius: 8px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ======================================================================
   Settings page (TASK-11)
   White, minimal, Linear/Plain-style. RTL-first: tabs sit on the RIGHT.
   ====================================================================== */
.rafiq-settings {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 14px;
  padding: 1.25rem;
  min-height: 70vh;
}

.rafiq-settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-inline-end: 0.75rem;
  border-inline-end: 1px solid var(--rafiq-border);
}

.rafiq-settings-tab {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: transparent;
  border: 0;
  color: var(--rafiq-text);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}
.rafiq-settings-tab:hover {
  background: var(--rafiq-row-hover);
}
.rafiq-settings-tab.is-active {
  background: var(--rafiq-teal-soft);
  color: var(--rafiq-teal);
}
.rafiq-settings-tab.is-active i {
  color: var(--rafiq-teal);
}
.rafiq-settings-tab i,
.rafiq-settings-tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.rafiq-settings-body {
  min-width: 0;
}

.rafiq-settings-panel {
  display: none;
}
.rafiq-settings-panel.is-active {
  display: block;
}

.rafiq-settings-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.rafiq-settings-section-head {
  margin-bottom: 0.25rem;
}
.rafiq-settings-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  color: var(--rafiq-text);
}
.rafiq-settings-section-help {
  margin: 0;
  color: var(--rafiq-text-muted);
  font-size: 0.9rem;
}

/* ----- Forms inside settings ----- */
.rafiq-settings-form {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--rafiq-surface);
}
.rafiq-form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.rafiq-form-row .form-label {
  font-weight: 500;
  color: var(--rafiq-text);
  margin: 0;
}
.rafiq-form-error {
  color: var(--rafiq-danger);
  font-size: 0.85rem;
}
.rafiq-form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.rafiq-form-feedback {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.rafiq-form-feedback--ok {
  color: #15803D;
}
.rafiq-form-feedback--error {
  color: var(--rafiq-danger);
}
.rafiq-form-feedback i,
.rafiq-form-feedback svg {
  width: 16px;
  height: 16px;
}

.rafiq-segmented {
  display: inline-flex;
  border: 1px solid var(--rafiq-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--rafiq-surface);
}
.rafiq-segmented-option {
  margin: 0;
  padding: 0.45rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  color: var(--rafiq-text-muted);
}
.rafiq-segmented-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.rafiq-segmented-option:has(input:checked) {
  background: var(--rafiq-teal-soft);
  color: var(--rafiq-teal);
  font-weight: 600;
}
.rafiq-segmented-option + .rafiq-segmented-option {
  border-inline-start: 1px solid var(--rafiq-border);
}

.rafiq-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  margin: 0;
}

/* ----- Users tab toolbar + table ----- */
.rafiq-users-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.rafiq-users-search {
  position: relative;
  flex: 1;
  max-width: 360px;
  min-width: 220px;
}
.rafiq-users-search input {
  padding-inline-start: 2.25rem;
}
.rafiq-users-search i,
.rafiq-users-search svg {
  position: absolute;
  inset-inline-start: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--rafiq-text-muted);
  pointer-events: none;
}
.rafiq-users-filter {
  width: auto;
  min-width: 160px;
}

.rafiq-users-table tbody tr {
  cursor: default;
}
.rafiq-users-table tbody tr:hover {
  background: var(--rafiq-row-hover);
}

.rafiq-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--rafiq-teal-soft);
  color: var(--rafiq-teal);
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
}
.rafiq-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rafiq-avatar--lg {
  width: 56px;
  height: 56px;
  font-size: 1.4rem;
}
.rafiq-avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 0.8rem;
}

/* Drawer avatar editor */
.rafiq-avatar-edit {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.rafiq-avatar-edit-controls {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rafiq-form-help {
  color: var(--rafiq-text-muted);
  font-size: 0.8rem;
}

/* Bulk action bar */
.rafiq-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border: 1px solid var(--rafiq-teal-soft);
  border-radius: 0.5rem;
  background: #f7fbfb;
  flex-wrap: wrap;
}
.rafiq-bulk-bar[hidden] { display: none; }
.rafiq-bulk-count {
  font-weight: 600;
  color: var(--rafiq-teal);
  font-size: 0.9rem;
}
.rafiq-bulk-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.rafiq-bulk-cell { width: 44px; text-align: center; }

/* Drawer collapsible sections (password reset, activity log) */
.rafiq-drawer-section {
  border-top: 1px solid #e5e7eb;
  padding: 0;
}
.rafiq-drawer-section-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--rafiq-text);
  user-select: none;
  list-style: none;
}
.rafiq-drawer-section-head::-webkit-details-marker { display: none; }
.rafiq-drawer-section-head .rafiq-drawer-section-chevron {
  margin-inline-start: auto;
  transition: transform 0.15s ease;
}
.rafiq-drawer-section[open] > .rafiq-drawer-section-head .rafiq-drawer-section-chevron {
  transform: rotate(180deg);
}
.rafiq-drawer-section-body {
  padding: 0 1.25rem 1.25rem;
}
.rafiq-drawer-section-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* Inline form messages (e.g. password reset success/error) */
.rafiq-form-msg {
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}
.rafiq-form-msg.is-ok {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.rafiq-form-msg.is-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* Activity timeline */
.rafiq-activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.rafiq-activity-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.5rem 0.75rem;
  border: 1px solid #f3f4f6;
  border-radius: 0.4rem;
  background: #fafafa;
}
.rafiq-activity-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--rafiq-teal-soft);
  color: var(--rafiq-teal);
  flex: 0 0 auto;
}
.rafiq-activity-body { flex: 1 1 auto; min-width: 0; }
.rafiq-activity-title {
  font-size: 0.9rem;
  color: var(--rafiq-text);
  font-weight: 500;
}
.rafiq-activity-target {
  color: var(--rafiq-text-muted);
  font-weight: 400;
}
.rafiq-activity-time {
  font-size: 0.8rem;
  color: var(--rafiq-text-muted);
  margin-top: 0.15rem;
}
.rafiq-activity-empty,
.rafiq-activity-loading {
  text-align: center;
  color: var(--rafiq-text-muted);
  padding: 1.5rem 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* ----- Toggle switch (Active/Inactive) ----- */
.rafiq-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--rafiq-text-muted);
  font-size: 0.85rem;
}
.rafiq-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}
.rafiq-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #E5E7EB;
  transition: background-color var(--transition);
}
.rafiq-toggle-thumb {
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: inset-inline-start var(--transition), background-color var(--transition);
}
.rafiq-toggle.is-on .rafiq-toggle-track {
  background: var(--rafiq-teal);
}
.rafiq-toggle.is-on .rafiq-toggle-thumb {
  inset-inline-start: 18px;
}
.rafiq-toggle.is-on {
  color: var(--rafiq-teal);
}

/* ----- Row action icon buttons ----- */
.rafiq-row-actions {
  display: inline-flex;
  gap: 0.25rem;
}
.rafiq-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--rafiq-text-muted);
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}
.rafiq-icon-btn:hover {
  background: var(--rafiq-row-hover);
  color: var(--rafiq-text);
  border-color: var(--rafiq-border);
}
.rafiq-icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.rafiq-icon-btn--danger:hover {
  background: var(--rafiq-danger-bg);
  color: var(--rafiq-danger);
  border-color: var(--rafiq-danger);
}
.rafiq-icon-btn i,
.rafiq-icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ----- Drawer ----- */
.rafiq-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--rafiq-drawer-backdrop);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 1040;
  animation: rafiq-fade-in 180ms ease-out;
}
.rafiq-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  /* RTL anchoring: inline-start in `dir="rtl"` resolves to the right
     edge of the viewport, which is what the task spec asks for. */
  inset-inline-start: 0;
  width: 420px;
  max-width: 100vw;
  background: var(--rafiq-surface);
  border-inline-end: 1px solid var(--rafiq-border);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(13, 27, 42, 0.18);
  animation: rafiq-drawer-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.rafiq-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rafiq-border);
}
.rafiq-drawer-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: var(--rafiq-text);
}
.rafiq-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.rafiq-drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.5rem;
  margin-top: auto;
  border-top: 1px solid var(--rafiq-border);
}
.rafiq-drawer-actions {
  padding-top: 1rem;
}

@keyframes rafiq-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes rafiq-drawer-in {
  /* dir-agnostic: pure opacity + a tiny vertical lift so the slide
     reads correctly in both RTL and LTR without flipping directions. */
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----- Stub cards (Roles + Notifications tabs) ----- */
.rafiq-stub-card {
  background: var(--rafiq-surface);
  border: 1px dashed var(--rafiq-border);
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--rafiq-text-muted);
}
.rafiq-stub-card i,
.rafiq-stub-card svg {
  width: 32px;
  height: 32px;
  color: var(--rafiq-teal);
  margin-bottom: 0.75rem;
}
.rafiq-stub-card-title {
  font-weight: 700;
  color: var(--rafiq-text);
  margin-bottom: 0.5rem;
}
.rafiq-stub-card-text {
  margin: 0;
  font-size: 0.9rem;
  max-width: 480px;
  margin-inline: auto;
}

/* Lucide icons inside settings: keep them visually balanced with bi-* */
.rafiq-settings i[data-lucide],
.rafiq-settings svg.lucide,
.rafiq-drawer i[data-lucide],
.rafiq-drawer svg.lucide,
.rafiq-icon-btn svg.lucide,
.rafiq-form-feedback svg.lucide {
  stroke-width: 2;
}

/* ----- Mobile: tabs become horizontal scroll at the top ----- */
@media (max-width: 768px) {
  .rafiq-settings {
    grid-template-columns: 1fr;
  }
  .rafiq-settings-tabs {
    flex-direction: row;
    overflow-x: auto;
    border-inline-end: 0;
    border-bottom: 1px solid var(--rafiq-border);
    padding-inline-end: 0;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
    flex-wrap: nowrap;
  }
  .rafiq-settings-tab {
    white-space: nowrap;
  }
  .rafiq-drawer {
    width: 100vw;
  }
}

/* ============================================================
   PERMISSIONS MATRIX (TASK-12 — Settings → الصلاحيات)
   White, minimal, Linear/Plain. No gradients. RAFIQ teal accent.
   ============================================================ */

.rafiq-perm-matrix-wrap {
    border: 1px solid var(--rafiq-border, #e5e7eb);
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
}

.rafiq-perm-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.rafiq-perm-matrix thead th {
    background: #f9fafb;
    font-weight: 600;
    text-align: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--rafiq-border, #e5e7eb);
    color: #111827;
}

.rafiq-perm-matrix thead .rafiq-perm-corner {
    text-align: start;
    color: #6b7280;
    font-weight: 500;
}

.rafiq-perm-matrix tbody tr + tr {
    border-top: 1px solid var(--rafiq-border, #e5e7eb);
}

.rafiq-perm-module {
    text-align: start;
    padding: 1rem;
    color: #01696f;
    font-weight: 600;
    background: #ffffff;
    width: 12rem;
    vertical-align: top;
}

.rafiq-perm-cell {
    padding: 0.85rem 0.75rem;
    vertical-align: middle;
    border-inline-start: 1px solid var(--rafiq-border, #e5e7eb);
}

.rafiq-perm-cell-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    justify-content: center;
}

.rafiq-perm-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    cursor: pointer;
    user-select: none;
}

.rafiq-perm-toggle.is-locked {
    cursor: not-allowed;
}

.rafiq-perm-switch {
    appearance: none;
    -webkit-appearance: none;
    width: 2rem;
    height: 1.1rem;
    border-radius: 999px;
    background: #d1d5db;
    position: relative;
    cursor: pointer;
    transition: background-color 120ms ease;
    flex-shrink: 0;
    margin: 0;
}

.rafiq-perm-switch::before {
    content: "";
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 0.15rem;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    background: #ffffff;
    transform: translateY(-50%);
    transition: inset-inline-start 120ms ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.rafiq-perm-switch:checked {
    background: #01696f;
}

.rafiq-perm-switch:checked::before {
    inset-inline-start: calc(100% - 1rem);
}

.rafiq-perm-switch:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.rafiq-perm-switch:focus-visible {
    outline: 2px solid #01696f;
    outline-offset: 2px;
}

.rafiq-perm-action {
    font-size: 0.78rem;
    color: #6b7280;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.rafiq-perm-toggle.is-locked .rafiq-perm-action {
    color: #9ca3af;
}

/* Toast — bottom-center, transient, auto-removed by inline JS */
.rafiq-perm-toast {
    position: fixed;
    inset-block-end: 1.5rem;
    inset-inline: 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 1100;
}

.rafiq-perm-toast-msg {
    pointer-events: auto;
    background: #111827;
    color: #ffffff;
    padding: 0.6rem 1.1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    animation: rafiq-perm-toast-in 160ms ease-out, rafiq-perm-toast-out 240ms ease-in 1.6s forwards;
}

.rafiq-perm-toast-msg.is-ok {
    background: #01696f;
}

.rafiq-perm-toast-msg.is-error {
    background: #b91c1c;
}

@keyframes rafiq-perm-toast-in {
    from { opacity: 0; transform: translateY(0.5rem); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes rafiq-perm-toast-out {
    to { opacity: 0; transform: translateY(0.4rem); }
}

@media (max-width: 720px) {
    .rafiq-perm-matrix-wrap { overflow-x: auto; }
    .rafiq-perm-matrix { min-width: 640px; }
    .rafiq-perm-module { width: auto; }
}

/* 403 page (TASK-12) */
.rafiq-403 {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 3rem 1rem;
}
.rafiq-403-card {
    background: #ffffff;
    border: 1px solid var(--rafiq-border, #e5e7eb);
    border-radius: 14px;
    padding: 2.4rem 2rem;
    max-width: 32rem;
    width: 100%;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.rafiq-403-icon {
    color: #01696f;
    margin-bottom: 0.9rem;
    display: inline-flex;
}
.rafiq-403-title {
    font-size: 1.15rem;
    color: #111827;
    margin: 0 0 0.5rem;
    font-weight: 600;
}
.rafiq-403-help {
    color: #6b7280;
    margin: 0 0 1.4rem;
    font-size: 0.95rem;
}
.rafiq-403-cta {
    display: inline-block;
    background: #01696f;
    color: #ffffff;
    padding: 0.55rem 1.2rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.95rem;
    transition: background-color 120ms ease;
}
.rafiq-403-cta:hover {
    background: #015458;
    color: #ffffff;
}

/* ============================================================
   TASK-14 — RTL/LTR direction (per-user, baseline=RTL)
   ============================================================
   Sidebar layout uses physical properties (right/left + margin-right/
   margin-left) — see the comment on .rafiq-sidebar for why we stepped
   off logical properties. The base rules above are the RTL defaults;
   the [dir="ltr"] block below flips both the sidebar anchor and the
   main-column margin so content always renders on the opposite side
   of the sidebar. */
[dir="rtl"] .rafiq-sidebar { right: 0; left: auto; }
[dir="ltr"] .rafiq-sidebar { left: 0; right: auto; }
[dir="ltr"] .rafiq-main {
  margin-left: var(--rafiq-sidebar-width);
  margin-right: 0;
}

/* The pref-toggle buttons in the topbar — keep them consistent with
   the existing logout button shape (btn-sm btn-outline-secondary)
   plus a tiny inline label slot for the AR/EN code. */
.rafiq-pref-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1;
}
.rafiq-pref-toggle-label {
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
}

/* ============================================================
   TASK-14 — DARK MODE
   ============================================================
   Activated by ``<html data-rafiq-theme="dark">``. Overrides the
   existing design tokens so every component already wired to a
   token (sidebar, topbar, tables, cards, drawers, forms, badges)
   flips automatically. Extra rules below cover places that hard-
   coded white/grey hex values plus Bootstrap form/button defaults.
   Linear-app inspired palette per the TASK-14 brief. NO purple,
   NO gradients. Accent stays RAFIQ teal so the brand survives the
   theme swap. */
[data-rafiq-theme="dark"] {
  /* Body / surfaces */
  --rafiq-bg: #0f0f0f;
  --rafiq-surface: #1a1a1a;
  --rafiq-row-hover: #222222;
  --rafiq-border: #2e2e2e;

  /* Notification token overrides — keep the hue family but bump
     saturation slightly so the mention dot still pops on a dark
     surface and the muted text reads against #1a1a1a. */
  --accent: #01696F;
  --accent-hover: #018a91;
  --warning: #FBBF24;
  --text-muted: #a0a0a0;

  /* Text */
  --rafiq-text: #f0f0f0;
  --rafiq-text-muted: #a0a0a0;

  /* Sidebar — slightly darker than body so it reads as a separate
     surface even without a border. */
  --rafiq-sidebar-bg: #0a0a0a;
  --rafiq-sidebar-text: #a0a0a0;
  --rafiq-sidebar-active: #222222;

  /* Drawer backdrop — heavier in dark so it cuts through the
     low-contrast surface beneath. */
  --rafiq-drawer-backdrop: rgba(0, 0, 0, 0.6);

  /* Settings teal accents — RAFIQ teal stays the same hue, but the
     soft-tint background slot needs a darker variant or it reads as
     a glowing block. */
  --rafiq-teal-soft: #0d2628;
  --rafiq-danger-bg: #2a1414;

  /* Bootstrap-bg (used by inline form-controls etc.) */
  color-scheme: dark;
}

/* Body + global text — Bootstrap's .text-muted uses a hex literal
   that turns invisible against #1a1a1a, so override it too. */
[data-rafiq-theme="dark"] body {
  background-color: var(--rafiq-bg);
  color: var(--rafiq-text);
}
[data-rafiq-theme="dark"] .text-muted,
[data-rafiq-theme="dark"] .form-text,
[data-rafiq-theme="dark"] .small.text-muted {
  color: var(--rafiq-text-muted) !important;
}

/* Headings — Bootstrap leaves these on body color which we already
   overrode, but explicit rules guard against future regressions. */
[data-rafiq-theme="dark"] h1,
[data-rafiq-theme="dark"] h2,
[data-rafiq-theme="dark"] h3,
[data-rafiq-theme="dark"] h4,
[data-rafiq-theme="dark"] h5,
[data-rafiq-theme="dark"] h6,
[data-rafiq-theme="dark"] label,
[data-rafiq-theme="dark"] .form-label,
[data-rafiq-theme="dark"] .fw-semibold {
  color: var(--rafiq-text);
}

/* Topbar contrast — the topbar shares ``--rafiq-surface`` so it
   inherits the override; the avatar fallback rim also needs a
   darker base. */
[data-rafiq-theme="dark"] .rafiq-topbar {
  border-bottom-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .rafiq-avatar {
  background: var(--rafiq-sidebar-active);
  color: var(--rafiq-text);
}

/* Tables — Bootstrap's .table inherits color from --bs-table-color
   which is hardcoded to #212529. We override via the rafiq surface
   tokens but Bootstrap's own table-striping needs explicit rules. */
[data-rafiq-theme="dark"] .table,
[data-rafiq-theme="dark"] .table > :not(caption) > * > * {
  color: var(--rafiq-text);
  background-color: transparent;
  border-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .rafiq-table tbody tr:hover {
  background: var(--rafiq-row-hover);
}
[data-rafiq-theme="dark"] .table thead th {
  background: #141414;
  color: var(--rafiq-text);
  border-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .table > tbody > tr {
  background-color: var(--rafiq-surface);
}

/* Cards / panels / drawers / empty states — all use --rafiq-surface
   so they flip via the token override. Borders need an explicit
   dark variant in a couple of places that hard-coded #e5e7eb. */
[data-rafiq-theme="dark"] .rafiq-perm-matrix-wrap,
[data-rafiq-theme="dark"] .rafiq-perm-matrix thead th,
[data-rafiq-theme="dark"] .rafiq-perm-module,
[data-rafiq-theme="dark"] .rafiq-perm-cell {
  background: var(--rafiq-surface);
  color: var(--rafiq-text);
  border-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .rafiq-perm-matrix thead th {
  background: #141414;
}
[data-rafiq-theme="dark"] .rafiq-perm-matrix .rafiq-perm-corner {
  color: var(--rafiq-text-muted);
}
[data-rafiq-theme="dark"] .rafiq-perm-module {
  /* Module label keeps the teal hue — it's the brand accent. */
  color: var(--rafiq-teal);
}

/* Forms — Bootstrap form-controls hardcode white backgrounds, so
   they need explicit overrides for inputs to not look stamped. */
[data-rafiq-theme="dark"] .form-control,
[data-rafiq-theme="dark"] .form-select,
[data-rafiq-theme="dark"] textarea,
[data-rafiq-theme="dark"] input[type="text"],
[data-rafiq-theme="dark"] input[type="email"],
[data-rafiq-theme="dark"] input[type="password"],
[data-rafiq-theme="dark"] input[type="search"],
[data-rafiq-theme="dark"] input[type="number"] {
  background-color: #141414;
  color: var(--rafiq-text);
  border-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .form-control:focus,
[data-rafiq-theme="dark"] .form-select:focus {
  background-color: #141414;
  color: var(--rafiq-text);
  border-color: var(--rafiq-teal);
  box-shadow: 0 0 0 0.2rem rgba(1, 105, 111, 0.25);
}
[data-rafiq-theme="dark"] .form-control::placeholder {
  color: var(--rafiq-text-muted);
  opacity: 1;
}
[data-rafiq-theme="dark"] .form-check-input {
  background-color: #141414;
  border-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .form-check-input:checked {
  background-color: var(--rafiq-teal);
  border-color: var(--rafiq-teal);
}

/* Buttons — outline-secondary becomes nearly invisible in dark on
   black, so swap it to a clear border + light text variant. */
[data-rafiq-theme="dark"] .btn-outline-secondary {
  color: var(--rafiq-text);
  border-color: var(--rafiq-border);
  background-color: transparent;
}
[data-rafiq-theme="dark"] .btn-outline-secondary:hover,
[data-rafiq-theme="dark"] .btn-outline-secondary:focus {
  background-color: var(--rafiq-row-hover);
  color: var(--rafiq-text);
  border-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .btn-light {
  background-color: var(--rafiq-row-hover);
  color: var(--rafiq-text);
  border-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .btn-link {
  color: var(--rafiq-teal);
}

/* Modals / dropdowns — Bootstrap defaults to white, override. */
[data-rafiq-theme="dark"] .modal-content,
[data-rafiq-theme="dark"] .dropdown-menu {
  background-color: var(--rafiq-surface);
  color: var(--rafiq-text);
  border-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .dropdown-item {
  color: var(--rafiq-text);
}
[data-rafiq-theme="dark"] .dropdown-item:hover,
[data-rafiq-theme="dark"] .dropdown-item:focus {
  background-color: var(--rafiq-row-hover);
  color: var(--rafiq-text);
}
[data-rafiq-theme="dark"] .modal-header,
[data-rafiq-theme="dark"] .modal-footer {
  border-color: var(--rafiq-border);
}

/* Drawer backdrop already token-driven; the drawer body uses
   --rafiq-surface so it flips. The drawer border was hardcoded
   in places. */
[data-rafiq-theme="dark"] .rafiq-drawer,
[data-rafiq-theme="dark"] .rafiq-drawer-section,
[data-rafiq-theme="dark"] .rafiq-drawer-header {
  background: var(--rafiq-surface);
  color: var(--rafiq-text);
  border-color: var(--rafiq-border);
}

/* Activity log timeline — uses muted text + a small icon chip;
   keep it readable. */
[data-rafiq-theme="dark"] .rafiq-activity-list,
[data-rafiq-theme="dark"] .rafiq-activity-item {
  color: var(--rafiq-text);
  background: var(--rafiq-surface);
  border-color: var(--rafiq-border);
}
[data-rafiq-theme="dark"] .rafiq-activity-icon {
  background: var(--rafiq-row-hover);
  color: var(--rafiq-text-muted);
}

/* Badges — role/status hues stay legible at full saturation
   against dark backgrounds, so we keep them. The internal-comment
   warning badge had a hardcoded warm BG that overpowers dark; mute. */
[data-rafiq-theme="dark"] .rafiq-comment.is-internal {
  background: #2a2410;
  border-color: var(--rafiq-warning);
}

/* 403 page */
[data-rafiq-theme="dark"] .rafiq-403-card {
  background: var(--rafiq-surface);
  border-color: var(--rafiq-border);
  color: var(--rafiq-text);
}
[data-rafiq-theme="dark"] .rafiq-403-cta {
  background: var(--rafiq-teal);
  color: #ffffff;
}
[data-rafiq-theme="dark"] .rafiq-403-cta:hover {
  background: #018a91;
  color: #ffffff;
}

/* Auth (login) layout — the login page uses base_auth.html which
   is unauthenticated and therefore stays light by default. We
   still ship the dark variant so a pre-rendered <html data-rafiq-theme>
   from a future stay-logged-in flow renders correctly. */
[data-rafiq-theme="dark"] .rafiq-auth-card {
  background: var(--rafiq-surface);
  border-color: var(--rafiq-border);
  color: var(--rafiq-text);
}

/* Bootstrap-icons + Lucide colors — explicit muted color so they
   don't render as full-bright white on hover. */
[data-rafiq-theme="dark"] .bi,
[data-rafiq-theme="dark"] svg.lucide,
[data-rafiq-theme="dark"] i[data-lucide] {
  color: var(--rafiq-text-secondary, var(--rafiq-text-muted));
}
[data-rafiq-theme="dark"] .rafiq-nav a:hover .bi,
[data-rafiq-theme="dark"] .rafiq-nav a.active .bi {
  color: #ffffff;
}

/* ============================================================
   Notifications (TASK-15) — bell, dropdown, full-page list,
   prefs panel. All tokens live in :root + the dark override
   block above; nothing here uses a hex literal.
   ============================================================ */

/* ----- Bell button + badge ----- */
.rafiq-bell-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.rafiq-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  padding: 0;
}

.rafiq-bell:hover,
.rafiq-bell:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.rafiq-bell .lucide,
.rafiq-bell i[data-lucide] {
  width: 18px;
  height: 18px;
}

.rafiq-bell-badge {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--rafiq-danger);
  color: var(--rafiq-surface);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
  border: 1px solid var(--rafiq-surface);
}

.rafiq-bell-badge.is-empty {
  display: none;
}

/* ----- Dropdown panel ----- */
.rafiq-notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  z-index: 1080;
  display: none;
}

.rafiq-notif-panel.is-open {
  display: block;
}

.rafiq-notif-panel:empty {
  display: none;
}

.rafiq-notif-dropdown {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 480px;
}

.rafiq-notif-dropdown-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px 8px;
}

.rafiq-notif-dropdown-title {
  font-weight: 600;
  color: var(--rafiq-text);
  font-size: 15px;
}

.rafiq-notif-dropdown-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ----- Tabs ----- */
.rafiq-notif-tabs {
  display: flex;
  gap: 4px;
  padding: 0 12px;
  border-bottom: 1px solid var(--rafiq-border);
}

.rafiq-notif-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
}

.rafiq-notif-tab:hover {
  color: var(--rafiq-text);
}

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

.rafiq-notif-tab .lucide,
.rafiq-notif-tab i[data-lucide] {
  width: 14px;
  height: 14px;
}

.rafiq-notif-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--rafiq-row-hover);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.rafiq-notif-tab.is-active .rafiq-notif-tab-badge {
  background: var(--accent);
  color: var(--rafiq-surface);
}

/* ----- Action row + list ----- */
.rafiq-notif-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px 16px;
  border-bottom: 1px solid var(--rafiq-border);
}

.rafiq-notif-mark-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: transparent;
  border: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.rafiq-notif-mark-all:hover:not(:disabled) {
  color: var(--accent-hover);
}

.rafiq-notif-mark-all:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

.rafiq-notif-mark-all .lucide,
.rafiq-notif-mark-all i[data-lucide] {
  width: 14px;
  height: 14px;
}

.rafiq-notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.rafiq-notif-row {
  border-bottom: 1px solid var(--rafiq-border);
  position: relative;
}

.rafiq-notif-row:last-child {
  border-bottom: 0;
}

.rafiq-notif-row-link {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--rafiq-text);
  background: transparent;
  transition: background var(--transition);
}

.rafiq-notif-row-link:hover,
.rafiq-notif-row-link:focus-visible {
  background: var(--rafiq-row-hover);
  color: var(--rafiq-text);
}

.rafiq-notif-row.is-unread {
  background: var(--rafiq-teal-soft);
}

.rafiq-notif-icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--rafiq-row-hover);
  color: var(--text-muted);
}

.rafiq-notif-row.kind-ticket .rafiq-notif-icon {
  color: var(--accent);
  background: var(--rafiq-teal-soft);
}

.rafiq-notif-row.kind-mention .rafiq-notif-icon {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 12%, var(--rafiq-surface));
}

.rafiq-notif-row.kind-system .rafiq-notif-icon {
  color: var(--text-muted);
}

.rafiq-notif-icon .lucide,
.rafiq-notif-icon i[data-lucide] {
  width: 14px;
  height: 14px;
}

.rafiq-notif-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rafiq-notif-title {
  font-size: 13px;
  color: var(--rafiq-text);
  font-weight: 400;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.rafiq-notif-row.is-unread .rafiq-notif-title {
  font-weight: 600;
}

.rafiq-notif-body {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rafiq-notif-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.rafiq-notif-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--text-muted);
}

.rafiq-notif-row.kind-ticket .rafiq-notif-dot {
  background: var(--accent);
}

.rafiq-notif-row.kind-mention .rafiq-notif-dot {
  background: var(--warning);
}

.rafiq-notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.rafiq-notif-empty .lucide,
.rafiq-notif-empty i[data-lucide] {
  width: 28px;
  height: 28px;
}

.rafiq-notif-dropdown-foot {
  border-top: 1px solid var(--rafiq-border);
  padding: 10px 16px;
  display: flex;
  justify-content: center;
}

.rafiq-notif-see-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}

.rafiq-notif-see-all:hover {
  color: var(--accent-hover);
}

.rafiq-notif-see-all .lucide,
.rafiq-notif-see-all i[data-lucide] {
  width: 14px;
  height: 14px;
}

/* LTR sidebar — flip the dropdown anchoring point so it doesn't fall
   off the screen when language=='en' (Bootstrap doesn't help here
   because we anchor with logical properties already, but the panel
   width is large enough that we still want a hard right-edge in LTR). */
html[dir="ltr"] .rafiq-notif-panel {
  inset-inline-start: auto;
  inset-inline-end: 0;
}

/* ----- Full-page list ----- */
.rafiq-notif-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0;
}

.rafiq-notif-page-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rafiq-notif-page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--rafiq-text);
}

.rafiq-notif-page-help {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.rafiq-notif-tabs--page {
  border-bottom: 1px solid var(--rafiq-border);
  padding: 0;
}

.rafiq-notif-tabs--page .rafiq-notif-tab {
  text-decoration: none;
}

.rafiq-notif-page-actions {
  display: flex;
  justify-content: flex-end;
}

.rafiq-notif-list--page {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  overflow: hidden;
}

.rafiq-notif-list--page .rafiq-notif-row {
  display: flex;
  align-items: stretch;
}

.rafiq-notif-list--page .rafiq-notif-row-link {
  flex: 1;
}

.rafiq-notif-row-delete {
  display: flex;
  align-items: center;
  padding-inline-end: 12px;
}

.rafiq-notif-row-delete-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.rafiq-notif-row-delete-btn:hover {
  color: var(--rafiq-danger);
  background: var(--rafiq-danger-bg);
}

.rafiq-notif-pager {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 12px 0;
}

.rafiq-notif-pager-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}

.rafiq-notif-pager-link:hover {
  color: var(--accent-hover);
}

.rafiq-notif-pager-meta {
  color: var(--text-muted);
  font-size: 12px;
}

.rafiq-notif-empty--page {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  padding: 48px 16px;
}

/* ----- Settings prefs panel ----- */
.rafiq-notif-prefs-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rafiq-notif-prefs-section {
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--rafiq-surface);
}

.rafiq-notif-prefs-legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--rafiq-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
}

.rafiq-notif-prefs-legend .lucide,
.rafiq-notif-prefs-legend i[data-lucide] {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.rafiq-notif-prefs-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--rafiq-row-hover);
}

.rafiq-notif-prefs-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--rafiq-border);
}

.rafiq-notif-prefs-section .rafiq-notif-prefs-toggle:last-child {
  border-bottom: 0;
}

.rafiq-notif-prefs-toggle .form-check-input {
  margin-top: 2px;
}

/* RAFIQ teal accent for the form-switch when checked. */
.rafiq-notif-prefs-toggle .form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.rafiq-notif-prefs-toggle .form-check-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rafiq-notif-prefs-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--rafiq-text);
}

.rafiq-notif-prefs-help {
  font-size: 12px;
  color: var(--text-muted);
}

.rafiq-notif-prefs-toast {
  position: sticky;
  bottom: 8px;
  align-self: flex-end;
  pointer-events: none;
  min-height: 24px;
}

.rafiq-notif-prefs-toast-msg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--rafiq-surface);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  animation: rafiq-toast-pop 200ms ease-out;
}

.rafiq-notif-prefs-toast-msg .lucide,
.rafiq-notif-prefs-toast-msg i[data-lucide] {
  width: 12px;
  height: 12px;
}

@keyframes rafiq-toast-pop {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----- Dark-mode tweaks ----- */
[data-rafiq-theme="dark"] .rafiq-notif-row.is-unread {
  background: rgba(1, 105, 111, 0.10);
}

[data-rafiq-theme="dark"] .rafiq-notif-tab-badge {
  background: var(--rafiq-row-hover);
  color: var(--rafiq-text);
}

[data-rafiq-theme="dark"] .rafiq-bell-badge {
  border-color: var(--rafiq-bg);
}

[data-rafiq-theme="dark"] .rafiq-notif-dropdown {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* =========================================================
   Knowledge Base (TASK-17)
   ========================================================= */

.rafiq-kb-card {
  background: var(--rafiq-card);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  color: var(--rafiq-text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.rafiq-kb-card:hover {
  border-color: var(--rafiq-primary);
  transform: translateY(-1px);
  text-decoration: none;
  color: var(--rafiq-text);
}
.rafiq-kb-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--rafiq-primary-soft, rgba(1, 105, 111, 0.10));
  color: var(--rafiq-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.rafiq-kb-card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
  color: var(--rafiq-text);
}
.rafiq-kb-card-desc {
  font-size: 13px;
  color: var(--rafiq-text-muted);
  margin: 0 0 0.5rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rafiq-kb-card-count {
  font-size: 12px;
  color: var(--rafiq-text-muted);
  background: var(--rafiq-row-hover);
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
}

.rafiq-kb-results .list-group-item {
  background: var(--rafiq-card);
  border-color: var(--rafiq-border);
  color: var(--rafiq-text);
}
.rafiq-kb-result-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--rafiq-text);
}
.rafiq-kb-result-meta {
  font-size: 12px;
  color: var(--rafiq-text-muted);
  margin: 2px 0;
}
.rafiq-kb-result-excerpt {
  font-size: 13px;
  color: var(--rafiq-text-muted);
  line-height: 1.55;
}
.rafiq-kb-result-excerpt mark,
.rafiq-kb-result-title mark {
  background: var(--rafiq-warning-soft, rgba(255, 193, 7, 0.25));
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.rafiq-kb-article {
  background: var(--rafiq-card);
  border: 1px solid var(--rafiq-border);
  border-radius: 12px;
  padding: 1.5rem;
}
.rafiq-kb-article-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  color: var(--rafiq-text);
}
.rafiq-kb-article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.rafiq-kb-article-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--rafiq-text);
}
.rafiq-kb-article-body h2,
.rafiq-kb-article-body h3 {
  margin-top: 1.5rem;
  font-weight: 600;
}
.rafiq-kb-article-body code {
  background: var(--rafiq-row-hover);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}
.rafiq-kb-article-body pre {
  background: var(--rafiq-row-hover);
  padding: 0.85rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
}
.rafiq-kb-article-body blockquote {
  border-inline-start: 3px solid var(--rafiq-primary);
  padding: 4px 12px;
  color: var(--rafiq-text-muted);
}

.rafiq-md-area {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
}

.rafiq-badge-draft {
  background: var(--rafiq-row-hover);
  color: var(--rafiq-text-muted);
  border: 1px solid var(--rafiq-border);
}
.rafiq-badge-archived {
  background: var(--rafiq-row-hover);
  color: var(--rafiq-text-muted);
  text-decoration: line-through;
}
.rafiq-badge-published {
  background: var(--rafiq-primary-soft, rgba(1, 105, 111, 0.12));
  color: var(--rafiq-primary);
}

.alert-rafiq-info {
  background: var(--rafiq-primary-soft, rgba(1, 105, 111, 0.08));
  border: 1px solid var(--rafiq-border);
  color: var(--rafiq-text);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
}

.rafiq-breadcrumb {
  background: transparent;
  padding: 0;
  font-size: 13px;
  margin-bottom: 0.75rem;
}
.rafiq-breadcrumb .breadcrumb-item a {
  color: var(--rafiq-primary);
}

/* ===== SLA Tracking (TASK-18) =====
 * State tokens map to the spec hex values. Templates only ever
 * reference the var(--…) names so swapping in a custom palette is a
 * single-file edit here. Pill base + state modifiers stay flat
 * (no shadows, no gradients, no colored borders) per the project
 * style rule.
 */
:root {
  --rafiq-sla-ok-bg: #f0fdf4;
  --rafiq-sla-ok-fg: #16a34a;
  --rafiq-sla-warning-bg: #fffbeb;
  --rafiq-sla-warning-fg: #d97706;
  --rafiq-sla-breached-bg: #fef2f2;
  --rafiq-sla-breached-fg: #dc2626;
  --rafiq-sla-done-bg: #f3f4f6;
  --rafiq-sla-done-fg: #6b7280;
}

.rafiq-sla-stack {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
  min-width: 140px;
}

.rafiq-sla-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  position: relative;
}
.rafiq-sla-pill__label { font-weight: 500; }
.rafiq-sla-pill__time { font-weight: 600; }
.rafiq-sla-pill i { font-size: 12px; line-height: 1; }

.rafiq-sla-pill--ok       { background: var(--rafiq-sla-ok-bg);       color: var(--rafiq-sla-ok-fg); }
.rafiq-sla-pill--warning  { background: var(--rafiq-sla-warning-bg);  color: var(--rafiq-sla-warning-fg); }
.rafiq-sla-pill--breached { background: var(--rafiq-sla-breached-bg); color: var(--rafiq-sla-breached-fg); }
.rafiq-sla-pill--done     { background: var(--rafiq-sla-done-bg);     color: var(--rafiq-sla-done-fg); }

.rafiq-sla-pill--with-bar { padding-bottom: 6px; }
.rafiq-sla-pill__bar {
  display: block;
  position: absolute;
  inset-inline: 6px;
  bottom: 2px;
  height: 3px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  overflow: hidden;
}
.rafiq-sla-pill__bar-fill {
  display: block;
  height: 100%;
  background: currentColor;
  opacity: 0.7;
  border-radius: 2px;
}

/* Filter row above the ticket list */
.rafiq-sla-filter { gap: 0; }
.rafiq-sla-filter__btn {
  background: var(--rafiq-surface);
  color: var(--rafiq-text-muted);
  border: 1px solid var(--rafiq-border);
  font-size: 13px;
}
.rafiq-sla-filter__btn:hover {
  background: var(--rafiq-row-hover);
  color: var(--rafiq-text);
}
.rafiq-sla-filter__btn.is-active {
  background: var(--rafiq-teal-soft);
  color: var(--rafiq-teal);
  border-color: var(--rafiq-teal);
  font-weight: 600;
}

/* SLA panel on the ticket detail page */
.rafiq-sla-panel {
  background: var(--rafiq-surface);
  border: 1px solid var(--rafiq-border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 1.25rem;
}
.rafiq-sla-panel__header { margin-bottom: 12px; }
.rafiq-sla-panel__title {
  display: inline-block;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rafiq-text-muted);
  font-weight: 600;
}
.rafiq-sla-panel__rows { display: grid; gap: 14px; }
.rafiq-sla-panel__row { display: grid; gap: 6px; }
.rafiq-sla-panel__row-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rafiq-sla-panel__row-label { font-weight: 600; }
.rafiq-sla-panel__row-state { margin-inline-start: auto; }
.rafiq-sla-panel__row-due { font-size: 13px; color: var(--rafiq-text); }
.rafiq-sla-panel__bar {
  display: block;
  height: 4px;
  background: var(--rafiq-row-hover);
  border-radius: 2px;
  overflow: hidden;
}
.rafiq-sla-panel__bar-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
}
.rafiq-sla-panel__row--ok       .rafiq-sla-panel__bar-fill { background: var(--rafiq-sla-ok-fg); }
.rafiq-sla-panel__row--warning  .rafiq-sla-panel__bar-fill { background: var(--rafiq-sla-warning-fg); }
.rafiq-sla-panel__row--breached .rafiq-sla-panel__bar-fill { background: var(--rafiq-sla-breached-fg); width: 100% !important; }
.rafiq-sla-panel__row--done     .rafiq-sla-panel__bar-fill { background: var(--rafiq-sla-done-fg); }
.rafiq-sla-panel__empty {
  margin: 0;
  font-size: 13px;
  color: var(--rafiq-text-muted);
}

/* Settings → SLA tab */
.rafiq-sla-settings-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.rafiq-sla-settings-table th,
.rafiq-sla-settings-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rafiq-border);
  font-size: 14px;
}
.rafiq-sla-settings-table th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rafiq-text-muted);
  text-align: start;
}
.rafiq-sla-settings-table input[type="number"] {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--rafiq-border);
  border-radius: 6px;
  background: var(--rafiq-surface);
}
.rafiq-sla-settings-table input[type="number"]:focus {
  outline: none;
  border-color: var(--rafiq-teal);
  box-shadow: 0 0 0 3px rgba(1, 105, 111, 0.12);
}
.rafiq-sla-row__error {
  font-size: 12px;
  color: var(--rafiq-danger);
  margin: 4px 0 0;
}
.rafiq-sla-row--saved {
  animation: rafiqSlaRowSavedFlash 1s ease-out;
}
.rafiq-sla-row--error {
  background: var(--rafiq-sla-breached-bg);
}
.rafiq-sla-row__priority {
  font-weight: 600;
  color: var(--rafiq-text);
}
.rafiq-sla-row__input {
  width: 80px;
}
.rafiq-sla-row__switch .form-check-input:checked {
  background-color: var(--rafiq-teal);
  border-color: var(--rafiq-teal);
}
.rafiq-sla-settings-table__actions {
  text-align: end;
}
@keyframes rafiqSlaRowSavedFlash {
  0%   { background: var(--rafiq-sla-ok-bg); }
  100% { background: transparent; }
}

/* ============================================================
   TASK-20 — WhatsApp integration
   ============================================================
   Hex literals from the spec are pinned to design tokens here so
   templates reference variables (architecture rule #4) and a future
   theme refresh is one place to edit. Kept on a brand axis distinct
   from the status / SLA palettes so a "WhatsApp message" never gets
   confused with a "resolved" badge or an "ok SLA" pill. */
:root {
  /* Brand */
  --rafiq-wa-brand: #25d366;
  --rafiq-wa-brand-soft: #e9f7ef;
  --rafiq-wa-brand-fg: #15803d;

  /* Connection-status banner — green on connected, amber on missing creds */
  --rafiq-wa-ok-bg: #f0fdf4;
  --rafiq-wa-ok-border: #bbf7d0;
  --rafiq-wa-ok-fg: #065f46;
  --rafiq-wa-ok-dot: #10b981;
  --rafiq-wa-warn-bg: #fefce8;
  --rafiq-wa-warn-border: #fde68a;
  --rafiq-wa-warn-fg: #92400e;

  /* Thread bubbles — outbound on the brand-light tone, inbound on
     a slightly cooler green so direction is glanceable without
     reading the icon. */
  --rafiq-wa-bubble-out-bg: #f0fafa;
  --rafiq-wa-bubble-in-bg: #e9f7ef;
  --rafiq-wa-bubble-fg: #374151;
  --rafiq-wa-bubble-meta-fg: #9ca3af;

  /* Accordion + form chrome */
  --rafiq-wa-card-border: #e5e7eb;
  --rafiq-wa-card-bg: #f9fafb;
  --rafiq-wa-label-fg: #374151;
  --rafiq-wa-muted-fg: #6b7280;
  --rafiq-wa-input-bg: #ffffff;
  --rafiq-wa-btn-secondary-bg: #f3f4f6;
  --rafiq-wa-btn-secondary-fg: #374151;
}

/* ----- Connection-status banner ----- */
.rafiq-wa-status-banner {
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.rafiq-wa-status-banner--ok {
  background: var(--rafiq-wa-ok-bg);
  border: 1px solid var(--rafiq-wa-ok-border);
  color: var(--rafiq-wa-ok-fg);
}
.rafiq-wa-status-banner--warn {
  background: var(--rafiq-wa-warn-bg);
  border: 1px solid var(--rafiq-wa-warn-border);
  color: var(--rafiq-wa-warn-fg);
}
.rafiq-wa-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rafiq-wa-ok-dot);
  display: inline-block;
}

/* ----- Settings form ----- */
.rafiq-wa-form {
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.rafiq-wa-form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--rafiq-wa-label-fg);
  margin-bottom: 4px;
  display: block;
}
.rafiq-wa-form-actions {
  display: flex;
  gap: 8px;
}
.rafiq-wa-btn-primary {
  background: var(--rafiq-primary, #01696f);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.rafiq-wa-btn-secondary {
  background: var(--rafiq-wa-btn-secondary-bg);
  color: var(--rafiq-wa-btn-secondary-fg);
  border: none;
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.rafiq-wa-webhook-card {
  background: var(--rafiq-wa-card-bg);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 24px;
  font-size: 13px;
  color: var(--rafiq-wa-label-fg);
}
.rafiq-wa-webhook-url {
  margin-top: 6px;
  font-family: monospace;
  background: var(--rafiq-wa-input-bg);
  border: 1px solid var(--rafiq-wa-card-border);
  border-radius: 6px;
  padding: 8px;
}
.rafiq-wa-webhook-help {
  color: var(--rafiq-wa-muted-fg);
  margin-top: 6px;
  font-size: 12px;
}

/* ----- Accordion (vanilla disclosure pattern, no JS framework) ----- */
.rafiq-wa-accordion {
  margin-top: 32px;
}
.rafiq-wa-accordion-item {
  border: 1px solid var(--rafiq-wa-card-border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.rafiq-wa-accordion-item--warn {
  border-color: var(--rafiq-wa-warn-border);
}
.rafiq-wa-accordion-trigger {
  width: 100%;
  text-align: start;
  padding: 14px 16px;
  background: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--rafiq-wa-label-fg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rafiq-wa-accordion-item--warn .rafiq-wa-accordion-trigger {
  background: var(--rafiq-wa-warn-bg);
  color: var(--rafiq-wa-warn-fg);
}
.rafiq-wa-accordion-body {
  display: none;
  padding: 16px;
  background: var(--rafiq-wa-card-bg);
  border-top: 1px solid var(--rafiq-wa-card-border);
}
.rafiq-wa-accordion-item--warn .rafiq-wa-accordion-body {
  background: var(--rafiq-wa-warn-bg);
  border-top-color: var(--rafiq-wa-warn-border);
  color: var(--rafiq-wa-warn-fg);
}
.rafiq-wa-accordion-body[data-open="true"] {
  display: block;
}
.rafiq-wa-accordion-body ul,
.rafiq-wa-accordion-body ol {
  font-size: 13px;
  color: var(--rafiq-wa-label-fg);
  margin: 0;
  padding-inline-start: 20px;
  line-height: 2;
}
.rafiq-wa-accordion-item--warn .rafiq-wa-accordion-body ul {
  color: var(--rafiq-wa-warn-fg);
}
.rafiq-wa-accordion-body ol {
  line-height: 2.2;
}
.rafiq-wa-accordion-body a {
  color: var(--rafiq-primary, #01696f);
}

/* ----- Inline test/save result ----- */
.rafiq-wa-result--ok {
  color: var(--rafiq-wa-ok-fg);
  background: var(--rafiq-wa-ok-bg);
  border: 1px solid var(--rafiq-wa-ok-border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}
.rafiq-wa-result--err {
  color: var(--rafiq-wa-warn-fg);
  background: var(--rafiq-wa-warn-bg);
  border: 1px solid var(--rafiq-wa-warn-border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ----- Ticket-list source badge ----- */
.rafiq-source-whatsapp {
  background: var(--rafiq-wa-brand-soft);
  color: var(--rafiq-wa-brand-fg);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rafiq-source-whatsapp i {
  color: var(--rafiq-wa-brand);
}

/* ----- Ticket-detail thread bubbles ----- */
.rafiq-wa-thread {
  margin-bottom: 1.5rem;
}
.rafiq-wa-thread-title {
  color: var(--rafiq-wa-muted-fg);
  font-size: 13px;
  margin-bottom: 0.5rem;
}
.rafiq-wa-row {
  display: flex;
  margin-bottom: 0.5rem;
}
/* Inbound = customer = visually anchored to the side aligned with
   incoming traffic in RTL/LTR. Outbound (system reply) sits on the
   opposite side. WhatsApp's own UI uses left/right but we align
   logically to dir so the metaphor reads correctly in Arabic. */
.rafiq-wa-row--in  { justify-content: flex-end; }
.rafiq-wa-row--out { justify-content: flex-start; }
.rafiq-wa-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--rafiq-wa-bubble-fg);
}
.rafiq-wa-bubble--in  { background: var(--rafiq-wa-bubble-in-bg); }
.rafiq-wa-bubble--out { background: var(--rafiq-wa-bubble-out-bg); }
.rafiq-wa-bubble-meta {
  font-size: 11px;
  color: var(--rafiq-wa-bubble-meta-fg);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.rafiq-wa-bubble-meta i { color: var(--rafiq-wa-brand); }
