/* =====================================================
   LSGD Staff Strength Monitoring System - Custom Styles
   Extracted from original HTML design
   ===================================================== */

/* ----- CSS Variables ----- */
:root {
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-darker: #172554;
  --primary-light: #dbeafe;
  --primary-lighter: #eff6ff;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --accent-light: #fef3c7;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --info: #0ea5e9;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
}

/* ----- Base Styles ----- */
* { font-family: 'DM Sans', sans-serif; }
.font-display { font-family: 'Outfit', sans-serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
/* Malayalam content (Read Me page & popup, see views/dashboard/readme_content.php).
   DM Sans / Outfit / JetBrains Mono have no Malayalam glyphs, so a dedicated
   Malayalam face is used. The `*` rule in templates/header.php applies to every
   element, hence the explicit descendant selector. */
.font-malayalam,
.font-malayalam * {
  font-family: 'Noto Sans Malayalam', 'DM Sans', sans-serif;
}
body { background: var(--bg); color: var(--text); overflow-x: hidden; }

/* ----- Background Pattern ----- */
.bg-pattern {
  background-image:
    radial-gradient(circle at 20% 50%, rgba(29, 78, 216, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(245, 158, 11, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 40% 20%, rgba(22, 163, 74, 0.03) 0%, transparent 50%);
}

/* ----- Cards ----- */
.card {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  border-color: var(--primary);
}
.stat-card {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
}
.stat-card.amber::before { background: var(--accent); }
.stat-card.success::before { background: var(--success); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.info::before { background: var(--info); }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3);
}
.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover {
  background: var(--primary-lighter);
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #b91c1c;
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ----- Badges ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-neutral { background: #f1f5f9; color: #475569; }
/* "New" pill used on hub cards (see application/views/menu/hub.php) */
.badge-new { background: #ede9fe; color: #6d28d9; }
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* ----- Forms ----- */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s ease;
  background: white;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

/* ----- Data Table ----- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.data-table tbody tr {
  transition: background 0.15s ease;
}
.data-table tbody tr:hover {
  background: #f8fafc;
}

/* ----- Sortable table headers ----- */
.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}
.data-table thead th.sortable:hover {
  color: var(--primary);
  background: #eef2ff;
}
.data-table thead th.sort-asc,
.data-table thead th.sort-desc {
  color: var(--primary);
}
.data-table thead th .sort-ind {
  margin-left: 6px;
  font-size: 10px;
  color: var(--primary);
}

/* ----- Universal table toolbar ----- */
.dt-toolbar-holder { margin-bottom: 12px; }
.modal-toolbar-static .dt-toolbar-holder { margin-bottom: 0; }
.dt-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.modal-toolbar-static .dt-toolbar {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
}

/* Popup toolbar: row 1 = search + filters, row 2 = sort + exports */
.dt-toolbar.dt-toolbar-modal {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 16px;
}
.dt-toolbar.dt-toolbar-modal .dt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}
.dt-toolbar.dt-toolbar-modal .dt-row-exports {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.dt-toolbar.dt-toolbar-modal .dt-search {
  flex: 1 1 220px;
  min-width: 170px;
}
.dt-toolbar.dt-toolbar-modal .dt-sort,
.dt-toolbar.dt-toolbar-modal .dt-filter {
  min-width: 140px;
  max-width: 240px;
}
.dt-toolbar .dt-caption {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: 4px;
}
.dt-toolbar .dt-search {
  position: relative;
  flex: 1 1 200px;
  min-width: 160px;
}
.dt-toolbar .dt-search > i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #94a3b8;
  pointer-events: none;
}
.dt-toolbar .dt-search .form-input {
  height: 38px;
  padding-left: 34px;
  font-size: 13px;
}
.dt-toolbar .dt-sort,
.dt-toolbar .dt-filter {
  height: 38px;
  width: auto;
  min-width: 150px;
  max-width: 230px;
  font-size: 13px;
  padding: 0 12px;
}
.dt-toolbar .btn {
  height: 38px;
  padding-top: 0;
  padding-bottom: 0;
}
.dt-toolbar .dt-reset {
  color: var(--text-muted);
}
.dt-toolbar .dt-reset:hover {
  color: var(--danger);
}

/* ----- Static modal header ----- */
.modal-sticky-top {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
}
.modal-sticky-top > div:first-child {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

/* ----- Table Controls ----- */
.table-controls input,
.table-controls select {
  padding: 8px 12px;
  font-size: 13px;
  height: 38px;
}

/* ----- Modals ----- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-backdrop.active {
  display: flex;
}
.modal {
  background: white;
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }

/* ----- Toasts ----- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  background: white;
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s ease;
  border-left: 4px solid var(--primary);
  min-width: 300px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* ----- News Ticker ----- */
.news-ticker {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, var(--primary-darker) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 10px 0;
  z-index: 30;
  overflow: hidden;
  display: flex;
  align-items: center;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}
.news-ticker-label {
  background: var(--accent);
  color: white;
  padding: 6px 16px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  border-radius: 0 6px 6px 0;
  position: relative;
  z-index: 2;
  box-shadow: 4px 0 8px rgba(0,0,0,0.2);
}
.news-ticker-content {
  display: flex;
  animation: scrollNews 40s linear infinite;
  white-space: nowrap;
  gap: 60px;
  font-size: 14px;
  position: absolute;
  left: 130px;
  right: 0;
}
.news-ticker-content span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
@keyframes scrollNews {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.news-ticker:hover .news-ticker-content {
  animation-play-state: paused;
}

/* Keep page content clear of the fixed bottom news ticker */
body { padding-bottom: 64px; }
#mainContent { padding-bottom: 64px; }

/* ----- Sidebar ----- */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}
.sidebar-link:hover {
  background: var(--primary-lighter);
  color: var(--primary-dark);
}
.sidebar-link.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

/* ----- Progress Bar ----- */
.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
  border-radius: 4px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----- Animations ----- */
.fade-in {
  animation: fadeInUp 0.5s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.stagger > * {
  opacity: 0;
  animation: fadeInUp 0.4s ease forwards;
}
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }

/* ----- Role Card ----- */
.role-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
  cursor: pointer;
}
.role-card:hover {
  transform: translateY(-4px);
  border-color: #1d4ed8;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.role-card .icon-wrap {
  transition: all 0.3s ease;
}
.role-card:hover .icon-wrap {
  transform: scale(1.1);
}

/* ----- Section Title ----- */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}
.section-title::before {
  content: '';
  width: 4px;
  height: 20px;
  background: var(--primary);
  border-radius: 2px;
}

/* ----- Tab Button ----- */
.tab-btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.tab-btn:not(.active):hover {
  background: var(--primary-lighter);
  color: var(--primary-dark);
  border-color: var(--primary);
}

/* ----- File Upload Area ----- */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  background: #f8fafc;
}
.file-upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-lighter);
}
.file-upload-area.has-file {
  border-color: var(--success);
  background: #f0fdf4;
}

/* ----- Cascade Step ----- */
.cascade-step {
  animation: fadeInUp 0.3s ease;
}
.cascade-step.hidden {
  display: none;
}

/* ----- Logo Mark ----- */
.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
}
.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ----- Scrollbar Styles ----- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* The main content area must NOT be a scroll container.
   overflow-x: hidden (the Tailwind overflow-x-hidden utility on <main>) forces
   overflow-y to compute to auto, which makes <main> the scrollport for every
   position: sticky descendant. As <main> itself never scrolls, a sticky table
   header would then stay glued to its own box and never stick while the page
   scrolls - i.e. it looks like sticky is completely broken.
   overflow-x: clip clips exactly the same way but keeps the element a plain,
   non scrolling box, so the sticky <thead> really sticks to the viewport
   (under the fixed 64px page topbar). */
#mainContent {
  overflow-x: clip;
}

/* ----- Responsive data tables (sticky header, no horizontal scrollbar) -----
   Put class "dt-responsive" on the wrapper of a .data-table.
   >=1280px : normal table. The <thead> is sticky and stays pinned under the
              fixed 64px page topbar while the page scrolls.
              The wrapper (and every ancestor) must NOT scroll on its own:
              any max-height / overflow on it turns that box into the scrollport
              and the header would then be pinned to it instead of the viewport.
   <1280px  : every row collapses into a labelled card (thead hidden),
              so no horizontal scrollbar ever appears.
   --dt-sticky-top: distance the sticky <thead> keeps from the top of the
              scrollport:
              64px -> the PAGE scrolls (normal case, topbar height)
              0px  -> the wrapper is itself a scroll box (max-height /
                      overflow-y: auto, e.g. inside a modal or .modal itself) */
.dt-responsive {
  --dt-sticky-top: 64px; /* page topbar height (h-16) */
  width: 100%;
}
.dt-responsive .data-table thead th {
  position: sticky;
  top: var(--dt-sticky-top);
  z-index: 5;
  /* border-collapse: collapse does not paint cell borders on sticky cells,
     so draw the header divider with an inset shadow instead */
  box-shadow: inset 0 -1px 0 var(--border);
}
@media (max-width: 1279px) {
  .dt-responsive { overflow-x: visible; }
  .dt-responsive .data-table { display: block; }
  .dt-responsive .data-table thead { display: none; }
  .dt-responsive .data-table tbody { display: block; }
  .dt-responsive .data-table tbody tr {
    display: block;
    margin: 0 0 12px;
    padding: 4px 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }
  .dt-responsive .data-table tbody tr[data-total-row] { background: #f1f5f9; }
  .dt-responsive .data-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
    text-align: right;
    overflow-wrap: break-word;
  }
  .dt-responsive .data-table tbody td:last-child { border-bottom: 0; }
  .dt-responsive .data-table tbody td::before {
    content: attr(data-label);
    flex: 1 1 auto;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
  }
  .dt-responsive .data-table tbody td > .form-input,
  .dt-responsive .data-table tbody td > .form-select { flex: 1 1 auto; min-width: 0; max-width: 60%; }
  /* Select2 replaces the <select> with a span that carries an inline width */
  .dt-responsive .data-table tbody td > .select2-container {
    flex: 1 1 auto;
    min-width: 0;
    width: auto !important;
    max-width: 60%;
  }
  .dt-responsive .data-table tbody tr[data-nodata] td { display: block; text-align: center; }
  .dt-responsive .data-table tbody tr[data-nodata] td::before { display: none; }
  .dt-responsive .data-table tbody tr[data-total-row] td:first-child {
    justify-content: flex-start;
    font-weight: 800;
  }
}
@media print {
  .dt-responsive,
  .dt-responsive .data-table,
  .dt-responsive .data-table tbody,
  .dt-responsive .data-table tbody tr,
  .dt-responsive .data-table tbody td { display: revert !important; }
  .dt-responsive .data-table thead { display: table-header-group !important; }
  .dt-responsive .data-table tbody td::before { content: none !important; }
}

/* ----- Print Styles ----- */
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  .no-print { display: none !important; }
}

/* =====================================================
   Messenger (Messages module) — modern two-pane layout
   Left pane  : conversation list (search, tabs, threads)
   Right pane : conversation (messages + composer)
   >=1024px   : panes sit side by side inside one frame.
   <1024px    : one pane visible; selecting a thread slides
                the chat pane over the list (slide-over).
   NOTE: Tailwind Play CDN injects its generated stylesheet after this file,
   so its .hidden / md:flex etc. win cascade ties against the display rules
   below — no !important needed (one that would also break responsive
   un-hides like `hidden md:flex` inside the messenger).
   ===================================================== */

/* Frame sizing: fills the viewport between the fixed topbar (64px) and the
   fixed bottom news ticker (~44px + 20px clearance). */
.messenger {
  --msg-topbar: 64px;   /* header.php .h-16 */
  --msg-ticker: 64px;   /* body padding-bottom in style.css */
  --msg-head: 128px;    /* list pane header + search + tabs */
  height: calc(100vh - var(--msg-topbar) - var(--msg-ticker));
  min-height: 420px;
}
.messenger-frame {
  height: 100%;
  display: flex;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  overflow: hidden;
  position: relative;
}

/* ----- Left pane: conversation list ----- */
.messenger-list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #ffffff;
  border-right: 1px solid var(--border);
}
@media (min-width: 1024px) {
  .messenger-list-pane { width: 360px; flex: 0 0 360px; }
}
@media (min-width: 1280px) {
  .messenger-list-pane { width: 400px; flex-basis: 400px; }
}
.messenger-list-head {
  padding: 14px 16px 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(to right, #ffffff 55%, rgba(248, 250, 252, 0.6));
  border-bottom: 1px solid var(--border);
}
.msg-app-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}
.msg-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.msg-pill-blue { background: #2563eb; color: #fff; }

/* Search */
.messenger-search {
  position: relative;
  margin: 12px 14px 0;
}
.messenger-search > i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #94a3b8;
  pointer-events: none;
}
.msg-search-input {
  width: 100%;
  height: 38px;
  padding: 0 34px 0 34px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  font-size: 13px;
  color: var(--text);
  transition: all 0.2s ease;
}
.msg-search-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}
.msg-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.msg-search-clear:hover { color: var(--danger); background: #fee2e2; }

/* Tabs (Inbox / Archived) */
.messenger-tabs {
  display: flex;
  gap: 6px;
  margin: 10px 14px 0;
  padding: 4px;
  background: #f1f5f9;
  border-radius: 11px;
}
.messenger-tab {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s ease;
}
.messenger-tab:hover { color: var(--primary-dark); }
.messenger-tab.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.messenger-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

/* Thread list scroll area */
.messenger-threadlist {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 8px 14px;
}
.msg-thread {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.msg-thread:hover { background: #f8fafc; }
.msg-thread.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.msg-thread-archived .msg-avatar { opacity: 0.75; }
.msg-avatar {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.msg-avatar-lg { width: 42px; height: 42px; border-radius: 12px; font-size: 16px; }
.msg-avatar-0 { background: linear-gradient(135deg, #2563eb, #4f46e5); }
.msg-avatar-1 { background: linear-gradient(135deg, #059669, #0d9488); }
.msg-avatar-2 { background: linear-gradient(135deg, #d97706, #ea580c); }
.msg-avatar-3 { background: linear-gradient(135deg, #db2777, #9333ea); }
.msg-avatar-4 { background: linear-gradient(135deg, #0891b2, #2563eb); }
.msg-avatar-5 { background: linear-gradient(135deg, #65a30d, #16a34a); }
.msg-avatar-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #ffffff;
}
.msg-thread-main { flex: 1 1 auto; min-width: 0; }
.msg-thread-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.msg-thread-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-thread.unread .msg-thread-name { font-weight: 800; }
.msg-thread-time {
  flex-shrink: 0;
  font-size: 10.5px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}
.msg-thread.subtle .msg-thread-name { color: #475569; font-weight: 600; }
.msg-thread-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  color: #64748b;
}
.msg-thread-preview-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-thread.unread .msg-thread-preview-text { color: #1e293b; font-weight: 600; }
.msg-thread-count {
  flex-shrink: 0;
  font-size: 10.5px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}
.msg-thread-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
}
.msg-thread-badge-amber { background: #d97706; }

/* ----- Right pane: conversation ----- */
.messenger-chat-pane {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  min-width: 0;
  background: #f1f5f9;
}
.messenger-chat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.messenger-chat-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.messenger-chat-inner,
#msgChatInner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
/* the id selector would beat Tailwind's .hidden, so pin the hidden state */
#msgChatInner.hidden { display: none !important; }

/* Empty state */
.messenger-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.msg-empty-art { position: relative; width: 84px; height: 84px; }
.msg-empty-bubble {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #94a3b8;
}
.msg-empty-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.msg-empty-dot.d1 { top: 2px; right: 0; background: #93c5fd; animation: msgFloat 3s ease-in-out infinite; }
.msg-empty-dot.d2 { bottom: 6px; left: -4px; background: #fcd34d; animation: msgFloat 3s ease-in-out 0.7s infinite; }
.msg-empty-dot.d3 { top: 24px; left: -10px; background: #6ee7b7; animation: msgFloat 3s ease-in-out 1.4s infinite; }
@keyframes msgFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Messages area */
#msgMessages {
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
}
.msg-day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 8px;
}
.msg-day-divider::before,
.msg-day-divider::after {
  content: '';
  flex: 1 1 auto;
  height: 1px;
  background: #cbd5e1;
}
.msg-day-divider span {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  background: #e2e8f0;
  padding: 3px 12px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.msg-unread-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 8px;
}
.msg-unread-divider::before,
.msg-unread-divider::after {
  content: '';
  flex: 1 1 auto;
  height: 1px;
  background: #fca5a5;
}
.msg-unread-divider span {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  color: #b91c1c;
  background: #fee2e2;
  padding: 3px 12px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* Message rows */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
  animation: fadeInUp 0.25s ease;
}
.msg-row.mine { justify-content: flex-end; }
.msg-row-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-bottom: 20px;
}
.msg-row-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(78%, 560px);
}
.msg-row.mine .msg-row-stack { align-items: flex-end; }
.msg-bubble {
  padding: 9px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.msg-row.theirs .msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.msg-row.mine .msg-bubble {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
}
.msg-bubble-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  padding: 0 4px;
  font-size: 10px;
  color: #94a3b8;
}
.msg-bubble-meta .msg-meta-name { font-weight: 700; }
.msg-row.mine .msg-bubble-meta .msg-meta-name { color: #2563eb; }

/* Typing indicator (shown while sending) */
.msg-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.msg-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: msgTyping 1.2s ease-in-out infinite;
}
.msg-typing span:nth-child(2) { animation-delay: 0.15s; }
.msg-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes msgTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Composer */
.messenger-composer {
  padding: 10px 12px 12px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--border);
}
.msg-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.msg-composer-input {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 140px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
  font-size: 13.5px;
  line-height: 1.5;
  resize: none;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.msg-composer-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}
.msg-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
  transition: all 0.2s ease;
}
.msg-send-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35); }
.msg-send-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.msg-composer-hint {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
  padding: 0 4px;
  font-size: 10.5px;
  color: #94a3b8;
}
.msg-composer-hint kbd {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 9.5px;
  font-family: inherit;
}
.msg-link-btn {
  display: inline-flex;
  align-items: center;
  color: #64748b;
  font-size: 10.5px;
  font-weight: 600;
  transition: color 0.15s ease;
}
.msg-link-btn:hover { color: var(--primary); }
.msg-composer-hint .spacer { flex: 1 1 auto; }

/* Icon buttons in panes */
.msg-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.msg-icon-btn:hover { background: #f1f5f9; color: #0f172a; }
.msg-icon-btn-amber:hover { background: #fef3c7; color: #b45309; }
.msg-icon-btn-blue:hover { background: #dbeafe; color: #1d4ed8; }

/* Banners */
.msg-banner-amber {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
}

/* Spinner */
.msg-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  animation: msgSpin 0.8s linear infinite;
}
@keyframes msgSpin { to { transform: rotate(360deg); } }

/* Skeleton rows while the list loads */
.msg-skeleton {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
}
.msg-skeleton .sk-avatar {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  flex-shrink: 0;
}
.msg-skeleton .sk-lines { flex: 1 1 auto; }
.msg-skeleton .sk-line {
  height: 10px;
  border-radius: 5px;
  margin-bottom: 8px;
}
.msg-skeleton .sk-line.w60 { width: 60%; }
.msg-skeleton .sk-line.w85 { width: 85%; }
.msg-skeleton .sk-avatar,
.msg-skeleton .sk-line {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: msgShimmer 1.3s infinite;
}
@keyframes msgShimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ----- Responsive: mobile slide-over (<1024px) ----- */
@media (max-width: 1023.98px) {
  .messenger-list-pane { flex: 1 1 auto; width: 100%; }
  .messenger-chat-pane {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 5;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }
  .messenger-frame.chat-open .messenger-chat-pane {
    transform: translateX(0);
    box-shadow: -12px 0 32px rgba(15, 23, 42, 0.12);
  }
  #msgBackBtn { display: inline-flex; }
}
@media (min-width: 1024px) {
  .messenger-chat-pane { display: flex; }
  #msgBackBtn { display: none; }
  .messenger-frame.chat-open .messenger-chat-pane { box-shadow: none; }
}

/* Reduced motion: keep it functional but calm */
@media (prefers-reduced-motion: reduce) {
  .msg-row, .messenger-chat-pane { animation: none; transition: none; }
  .msg-empty-dot { animation: none; }
}
