/* ===========================================================
   Socialheat2027 (Fanpage Monitor) — Design System
   Inspired by AutoCampaign (Metronic / Modern Indigo SaaS)
   Responsive across all browsers and devices
   =========================================================== */

/* --- CSS Variables & Design Tokens --- */
:root {
  /* Primary Blue Brand (Metronic Demo1) */
  --primary: #3B82F6;
  --primary-light: #93C5FD;
  --primary-dark: #2563EB;
  --primary-bg: #EFF6FF;
  --primary-rgb: 59, 130, 246;
  --primary-line: rgba(59, 130, 246, 0.25);

  /* Semantic Palette */
  --success: #22C55E;
  --success-light: #86EFAC;
  --success-bg: #F0FDF4;
  --warning: #F59E0B;
  --warning-light: #FCD34D;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  --danger-light: #FCA5A5;
  --danger-bg: #FEF2F2;
  --info: #06B6D4;
  --info-light: #67E8F9;
  --info-bg: #ECFEFF;
  --purple: #8B5CF6;
  --purple-bg: #F5F3FF;
  --pink: #EC4899;
  --pink-bg: #FDF2F8;
  --orange: #F97316;
  --orange-bg: #FFF7ED;

  /* Clean Zinc Surfaces (Light Theme - Metronic Demo1) */
  --bg-body: #F4F4F5;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --bg-header: #FFFFFF;
  --bg-hover: #F4F4F5;
  --bg-active: #EFF6FF;
  --bg-subtle: #FAFAFA;
  --bg-input: #FFFFFF;
  --bg-secondary: #F4F4F5;

  /* Text Colors (Zinc Scale) */
  --text-primary: #09090B;
  --text-secondary: #71717A;
  --text-muted: #A1A1AA;
  --text-white: #FFFFFF;

  /* Borders & Dividers */
  --border: #E4E4E7;
  --border-color: #E4E4E7;
  --border-light: #F4F4F5;
  --border-strong: #D4D4D8;
  --border-focus: #3B82F6;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Layout Dimensions (Metronic Demo1: 280px / 80px) */
  --sidebar-width: 280px;
  --sidebar-collapsed: 80px;
  --header-height: 64px;

  /* Radius Scale (Demo1 base token: 8px) */
  --radius-xs: 0.125rem;
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Dark Theme Tokens (Metronic Demo1 Zinc Palette) --- */
[data-theme="dark"] {
  --primary: #2563EB;
  --primary-light: #60A5FA;
  --primary-dark: #1D4ED8;
  --primary-bg: rgba(37, 99, 235, 0.16);
  --primary-rgb: 37, 99, 235;
  --primary-line: rgba(59, 130, 246, 0.35);

  --success: #34D399;
  --success-bg: rgba(52, 211, 153, 0.15);
  --warning: #FBBF24;
  --warning-bg: rgba(251, 191, 36, 0.15);
  --danger: #F87171;
  --danger-bg: rgba(248, 113, 113, 0.15);
  --info: #38BDF8;
  --info-bg: rgba(56, 189, 248, 0.15);
  --purple: #A78BFA;
  --purple-bg: rgba(167, 139, 250, 0.15);
  --pink: #F472B6;
  --pink-bg: rgba(244, 114, 182, 0.15);
  --orange: #FB923C;
  --orange-bg: rgba(251, 146, 60, 0.15);

  --bg-body: #09090B;
  --bg-card: #18181B;
  --bg-sidebar: #18181B;
  --bg-header: #18181B;
  --bg-hover: #27272A;
  --bg-active: rgba(37, 99, 235, 0.2);
  --bg-subtle: #18181B;
  --bg-input: #18181B;
  --bg-secondary: #18181B;

  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;

  --border: #27272A;
  --border-color: #27272A;
  --border-light: #18181B;
  --border-strong: #3F3F46;
  --border-focus: #3B82F6;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

/* --- Base & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--primary-dark);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Headings */
h1, .h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.25; color: var(--text-primary); }
h2, .h2 { font-size: 1.375rem; font-weight: 600; line-height: 1.3; color: var(--text-primary); }
h3, .h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.35; color: var(--text-primary); }
h4, .h4 { font-size: 1rem; font-weight: 600; line-height: 1.4; color: var(--text-primary); }

.text-2xs { font-size: 0.6875rem; line-height: 1.2; } /* 11px */
.text-xs { font-size: 0.75rem; line-height: 1.33; }   /* 12px */
.text-sm { font-size: 0.875rem; line-height: 1.43; }  /* 14px */
.text-base { font-size: 1rem; line-height: 1.5; }     /* 16px */
.text-lg { font-size: 1.125rem; line-height: 1.55; }  /* 18px */
.text-xl { font-size: 1.25rem; line-height: 1.4; }    /* 20px */
.text-2xl { font-size: 1.5rem; line-height: 1.33; }   /* 24px */
.text-3xl { font-size: 1.875rem; line-height: 1.2; }  /* 30px */
.text-4xl { font-size: 2.25rem; line-height: 1.11; }  /* 36px */
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-primary-color { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }

.fw-normal { font-weight: 400; }
.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===========================================================
   Layout Structure (App Shell)
   =========================================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
  background: var(--bg-body);
  width: calc(100% - var(--sidebar-width));
}

.app-content {
  flex: 1;
  padding: 20px 24px 32px;
  margin-top: var(--header-height);
}

.container-fluid {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-slow), transform var(--transition-slow);
  overflow: hidden;
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, #4338CA 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.sidebar-logo span {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-muted);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.sidebar-toggle svg {
  transition: transform var(--transition-base);
}

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

.sidebar-menu {
  list-style: none;
  padding: 0 12px;
}

.menu-section {
  list-style: none;
  margin-bottom: 4px;
}

.menu-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 10px 6px;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.menu-heading:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.menu-heading-arrow {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.25s ease, color 0.15s ease;
  flex-shrink: 0;
}

.menu-heading:hover .menu-heading-arrow {
  color: var(--text-primary);
}

.menu-section.collapsed .menu-heading-arrow {
  transform: rotate(-90deg);
}

.menu-group {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
  max-height: 800px;
  opacity: 1;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

.menu-section.collapsed .menu-group {
  max-height: 0 !important;
  opacity: 0;
  pointer-events: none;
  margin: 0;
}

/* In collapsed sidebar (icon rail mode), show all items without titles */
.sidebar-collapsed .sidebar .menu-section.collapsed .menu-group {
  max-height: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.menu-item {
  margin-bottom: 3px;
  position: relative;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.menu-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.menu-link.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.menu-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}
.menu-link.active .menu-icon,
.menu-link:hover .menu-icon {
  color: var(--primary);
}

.menu-arrow {
  margin-left: auto;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
  color: var(--text-muted);
  flex-shrink: 0;
}
.menu-item.open > .menu-link .menu-arrow {
  transform: rotate(90deg);
}

.submenu {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
  padding-left: 16px;
  margin-left: 20px;
  border-left: 1px solid var(--border-color);
}
.menu-item.open > .submenu {
  max-height: 500px;
}
.submenu .menu-link {
  font-size: 0.8125rem;
  font-weight: 400;
  padding: 6px 12px;
  position: relative;
}

/* Sidebar Collapsed State */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}
.sidebar-collapsed .sidebar .sidebar-logo span,
.sidebar-collapsed .sidebar .menu-heading,
.sidebar-collapsed .sidebar .menu-arrow,
.sidebar-collapsed .sidebar .submenu,
.sidebar-collapsed .sidebar .badge {
  display: none !important;
}
.sidebar-collapsed .sidebar .menu-link {
  justify-content: center;
  padding: 10px;
}
.sidebar-collapsed .sidebar .menu-link span:not(.menu-icon) {
  display: none;
}
.sidebar-collapsed .sidebar .sidebar-header {
  justify-content: center;
  padding: 0;
}
.sidebar-collapsed .sidebar .sidebar-toggle {
  display: none;
}
.sidebar-collapsed .sidebar .sidebar-content .sidebar-menu {
  padding: 0 8px;
}
.sidebar-collapsed .app-main {
  margin-left: var(--sidebar-collapsed);
  width: calc(100% - var(--sidebar-collapsed));
}
.sidebar-collapsed .header {
  left: var(--sidebar-collapsed);
}

/* Sidebar Mobile Overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 99;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-base);
}
.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* --- Header --- */
.header {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 90;
  transition: left var(--transition-slow);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.mobile-menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.mobile-menu-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--text-secondary);
  font-weight: 500;
}
.breadcrumb a:hover {
  color: var(--primary);
}
.breadcrumb .separator {
  color: var(--border-color);
}
.breadcrumb .current {
  color: var(--text-primary);
  font-weight: 600;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Header Action Buttons */
.header-icon-btn,
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  position: relative;
}
.header-icon-btn:hover,
.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.notification-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #FFFFFF;
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-card);
  padding: 0 4px;
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.user-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
  color: #FFFFFF;
  font-size: 0.8125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
  flex-shrink: 0;
}

.user-info {
  text-align: left;
}
.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 110;
  animation: dropdownSlideIn 0.15s ease;
}
.dropdown-menu.show {
  display: block;
}

@keyframes dropdownSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}
.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.dropdown-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}
.dropdown-item:hover svg {
  color: currentColor;
}
.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* ===========================================================
   Card Component
   =========================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
  overflow: hidden;
}
.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.card-body {
  padding: 20px;
}
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===========================================================
   Metric & Stat Cards (AutoCampaign Style)
   =========================================================== */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  transform: translateY(-1px);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 14px;
}

.stat-value {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

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

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: 8px;
  width: fit-content;
}
.stat-change.up {
  color: var(--success);
  background: var(--success-bg);
}
.stat-change.down {
  color: var(--danger);
  background: var(--danger-bg);
}

/* Metric Cards Grids (Responsive) */
.metrics-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metrics-grid-6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metrics-grid-8 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (min-width: 1400px) {
  .metrics-grid-8 {
    grid-template-columns: repeat(8, 1fr);
  }
}
@media (max-width: 1200px) {
  .metrics-grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
  .metrics-grid-8 {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 991px) {
  .metrics-grid-4,
  .metrics-grid-6,
  .metrics-grid-8 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 575px) {
  .metrics-grid-4,
  .metrics-grid-6,
  .metrics-grid-8 {
    grid-template-columns: 1fr;
  }
}

.metric-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}
.metric-box:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric-box-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.metric-box-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.metric-box-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-box-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.metric-box-sub {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===========================================================
   Buttons
   =========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
  text-decoration: none;
  outline: none;
}
.btn:disabled,
.btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-lg);
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF !important;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.25);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #FFFFFF !important;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.35);
}

.btn-outline {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-secondary);
}
.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF !important;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #DC2626;
  border-color: #DC2626;
}

.btn-success {
  background: var(--success);
  color: #FFFFFF !important;
  border-color: var(--success);
}
.btn-success:hover {
  background: #16A34A;
  border-color: #16A34A;
}

.btn-warning {
  background: var(--warning);
  color: #FFFFFF !important;
  border-color: var(--warning);
}
.btn-warning:hover {
  background: #D97706;
  border-color: #D97706;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===========================================================
   Forms & Inputs
   =========================================================== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control,
.form-select {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: all var(--transition-fast);
  outline: none;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-control::placeholder {
  color: var(--text-muted);
}
.form-control:disabled {
  background: var(--bg-body);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Standardized Dropdown Box (Listening Style) */
select.form-control,
select.form-select,
.form-select,
.filter-select,
select.filter-select {
  appearance: none !important;
  -webkit-appearance: none !important;
  background-color: var(--bg-card, #ffffff);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  padding: 7px 28px 7px 12px;
  font-size: 12px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  color: var(--text-secondary, #334155);
  outline: none;
  cursor: pointer;
  height: 35px;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
}

select.form-control:focus,
select.form-select:focus,
.form-select:focus,
.filter-select:focus,
select.filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] select.form-control,
[data-theme="dark"] select.form-select,
[data-theme="dark"] .form-select,
[data-theme="dark"] .filter-select,
[data-theme="dark"] select.filter-select {
  background-color: var(--bg-card);
  border-color: var(--border);
  color: var(--text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
}

/* Common filter input & button helpers matching Listening style */
.filter-input {
  padding: 7px 12px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
  color: var(--text-secondary);
  outline: none;
  height: 35px;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.filter-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .filter-input {
  background-color: var(--bg-card);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-filter {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s ease;
  text-decoration: none;
  height: 35px;
  line-height: 1;
}
.btn-filter:hover {
  border-color: var(--border-strong);
  color: var(--primary);
  background: var(--primary-bg);
}
.btn-filter.btn-filter-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}
.btn-filter.btn-filter-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #ffffff;
}

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

/* Password input wrapper */
.password-wrapper {
  position: relative;
}
.password-wrapper .form-control {
  padding-right: 42px;
}
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.password-toggle:hover {
  color: var(--text-primary);
}

/* Custom Checkbox */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ===========================================================
   Tables
   =========================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-subtle);
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* User & Fanpage Cell in Table */
.user-cell {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  min-width: 240px;
}

.user-cell-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

.user-cell-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: block;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  background: var(--primary-bg);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.avatar.avatar-xs { width: 24px; height: 24px; font-size: 0.6875rem; }
.avatar.avatar-sm { width: 40px; height: 40px; font-size: 0.8125rem; }
.avatar.avatar-md { width: 48px; height: 48px; font-size: 1rem; }
.avatar.avatar-lg { width: 64px; height: 64px; font-size: 1.25rem; }
.avatar.avatar-xl { width: 80px; height: 80px; font-size: 1.5rem; }

.user-cell-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.35;
}

.user-cell-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.user-cell-name:hover {
  color: var(--primary);
}

.user-cell-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: monospace;
}


/* ===========================================================
   Badges & Pills
   =========================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.2;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-purple  { background: var(--purple-bg);  color: var(--purple); }
.badge-pink    { background: var(--pink-bg);    color: var(--pink); }
.badge-neutral { background: var(--bg-body);    color: var(--text-secondary); border: 1px solid var(--border-color); }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
}

/* ===========================================================
   Tabs & Filter Tabs (AutoCampaign SaaS Underline Style)
   =========================================================== */
.tab-navigation,
.tabs,
.filter-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  padding: 0;
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-item,
.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  outline: none !important;
  font-family: inherit;
  border-radius: 0;
}

.tab-item:hover,
.filter-tab:hover {
  color: var(--primary);
  background: transparent !important;
}

.tab-item.active,
.filter-tab.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary) !important;
  background: transparent !important;
}

.tab-item.active .badge,
.filter-tab.active .badge {
  background: var(--primary-bg);
  color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.15s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Pill Tabs */
.tabs-pills {
  border-bottom: none;
  background: var(--bg-body);
  padding: 4px;
  border-radius: var(--radius-lg);
  display: inline-flex;
}
.tabs-pills .tab-item {
  border-radius: var(--radius-md);
  border-bottom: none !important;
  padding: 6px 14px;
}
.tabs-pills .tab-item.active {
  background: var(--bg-card) !important;
  box-shadow: var(--shadow-sm);
}

/* ===========================================================
   Alerts
   =========================================================== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: #166534; border-color: #BBF7D0; }
.alert-danger  { background: var(--danger-bg);  color: #991B1B; border-color: #FECACA; }
.alert-warning { background: var(--warning-bg); color: #92400E; border-color: #FDE68A; }
.alert-info    { background: var(--info-bg);    color: #155E75; border-color: #A5F3FC; }

[data-theme="dark"] .alert-success { color: #86EFAC; border-color: rgba(34, 197, 94, 0.25); }
[data-theme="dark"] .alert-danger  { color: #FCA5A5; border-color: rgba(239, 68, 68, 0.25); }
[data-theme="dark"] .alert-warning { color: #FDE047; border-color: rgba(245, 158, 11, 0.25); }
[data-theme="dark"] .alert-info    { color: #67E8F9; border-color: rgba(6, 182, 212, 0.25); }

/* ===========================================================
   Modals & Popups
   =========================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition-base);
}
.modal-overlay.show {
  display: flex;
  opacity: 1;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-box.modal-lg { max-width: 760px; }
.modal-box.modal-xl { max-width: 980px; }

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Custom Alert & Toast System */
.custom-alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.custom-alert-overlay.show { display: flex; }

.custom-alert-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 400px;
  padding: 28px 24px;
  text-align: center;
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.custom-alert-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 16px;
}
.custom-alert-icon.success { background: var(--success-bg); color: var(--success); }
.custom-alert-icon.error   { background: var(--danger-bg);  color: var(--danger); }
.custom-alert-icon.warning { background: var(--warning-bg); color: var(--warning); }
.custom-alert-icon.info    { background: var(--info-bg);    color: var(--info); }

.custom-alert-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.custom-alert-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}
.custom-alert-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.custom-alert-btn:hover {
  background: var(--primary-dark);
}

#toastContainer {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 48px);
  pointer-events: none;
}

.custom-toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  animation: toastSlideIn 0.25s ease;
  transition: all 0.25s ease;
}
.custom-toast.hide {
  opacity: 0;
  transform: translateX(100%);
}

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

/* ===========================================================
   Auth Pages (Login / Register / Pending)
   =========================================================== */
.auth-page {
  background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 50%, #C7D2FE 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
}
[data-theme="dark"] .auth-page {
  background: linear-gradient(135deg, #0F172A 0%, #1E1B4B 50%, #0F172A 100%);
}

.auth-theme-toggle {
  position: absolute;
  top: 24px;
  right: 24px;
}

.auth-container {
  width: 100%;
  max-width: 440px;
}

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  padding: 36px 32px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.auth-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary) 0%, #4338CA 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.auth-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.auth-title {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-subtitle {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.auth-footer a {
  color: var(--primary);
  font-weight: 600;
}

/* ===========================================================
   Charts, Donut, Progress & Data Visuals
   =========================================================== */
.chart-placeholder {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
  min-height: 240px;
}

/* Audience bar visual */
.audience-bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.audience-bar-label {
  width: 90px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audience-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-body);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.audience-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width 0.6s ease;
}
.audience-bar-val {
  width: 50px;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===========================================================
   Grid & Layout Utilities
   =========================================================== */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.justify-between, .justify-content-between { justify-content: space-between !important; }
.justify-center, .justify-content-center { justify-content: center !important; }
.justify-end, .justify-content-end { justify-content: flex-end !important; }
.border-top { border-top: 1px solid var(--border-color) !important; }
.flex-1 { flex: 1; }

/* --- Modern Pagination Component & CI4 Pager System --- */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-card, #ffffff);
  border-top: 1px solid var(--border-color, #e2e8f0);
  flex-wrap: wrap;
  gap: 12px;
}
.pagination-info {
  font-size: 0.8125rem;
  color: var(--text-muted, #64748b);
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination-info strong {
  color: var(--text-primary, #0f172a);
  font-weight: 600;
}

/* Container wrappers: div.pagination, nav */
div.pagination {
  display: inline-flex !important;
  align-items: center !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
}

div.pagination > nav,
nav[aria-label="Page navigation"],
nav[aria-label="Pagination"],
nav[aria-label="Phân trang"] {
  display: inline-flex !important;
  align-items: center !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Pagination List (ul / ol) */
.pagination,
ul.pagination,
ol.pagination,
.pagination-list {
  display: flex !important;
  align-items: center !important;
  gap: 5px !important;
  list-style: none !important;
  list-style-type: none !important;
  margin: 0 !important;
  padding: 0 !important;
  flex-wrap: wrap !important;
}

/* Pagination Items (li) */
.pagination li,
ul.pagination li,
ol.pagination li,
.pagination-item {
  display: inline-flex !important;
  list-style: none !important;
  list-style-type: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Pagination Links & Buttons (a / span) */
.pagination li a,
.pagination li span,
ul.pagination li a,
ul.pagination li span,
.pagination-link {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 34px !important;
  height: 34px !important;
  padding: 0 10px !important;
  font-size: 0.8125rem !important;
  font-weight: 600 !important;
  color: var(--text-secondary, #475569) !important;
  background: var(--bg-card, #ffffff) !important;
  border: 1px solid var(--border-color, #e2e8f0) !important;
  border-radius: var(--radius-sm, 8px) !important;
  text-decoration: none !important;
  transition: all var(--transition-fast, 150ms ease) !important;
  user-select: none !important;
  line-height: 1 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
}

/* Hover State */
.pagination li a:hover:not(.disabled),
ul.pagination li a:hover:not(.disabled),
.pagination-link:hover:not(.disabled):not(.active) {
  background: var(--bg-hover) !important;
  border-color: var(--border-strong) !important;
  color: var(--primary) !important;
}

/* Active Page State */
.pagination li.active a,
.pagination li.active span,
ul.pagination li.active a,
ul.pagination li.active span,
.pagination-link.active,
.pagination-item.active .pagination-link {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.35) !important;
  cursor: default !important;
}

/* Disabled State */
.pagination li.disabled a,
.pagination li.disabled span,
ul.pagination li.disabled a,
ul.pagination li.disabled span,
.pagination-link.disabled,
.pagination-item.disabled .pagination-link {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  background: var(--bg-hover, #f8fafc) !important;
  color: var(--text-muted, #94a3b8) !important;
  border-color: var(--border-color, #e2e8f0) !important;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 34px;
  font-size: 0.8125rem;
  color: var(--text-muted, #94a3b8);
  user-select: none;
}

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }

.m-0 { margin: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-5 { margin-bottom: 20px !important; }
.mb-6 { margin-bottom: 24px !important; }

.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-5 { margin-top: 20px !important; }
.mt-6 { margin-top: 24px !important; }

.p-0 { padding: 0 !important; }
.w-100 { width: 100% !important; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.text-start { text-align: left !important; }

/* ===========================================================
   Cross-Browser Responsive Design
   =========================================================== */
@media (max-width: 1200px) {
  .metrics-grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 101;
    width: 280px !important;
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0 !important;
    width: 100% !important;
  }
  .header {
    left: 0 !important;
    padding: 0 16px;
  }
  .mobile-menu-toggle {
    display: flex;
  }
  .sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }
  .sidebar-collapsed .sidebar.show {
    transform: translateX(0);
  }
  .sidebar-collapsed .app-main {
    margin-left: 0 !important;
    width: 100% !important;
  }
  .sidebar-collapsed .header {
    left: 0 !important;
  }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .metrics-grid-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .app-content {
    padding: 16px;
  }
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  .metrics-grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }
  .user-info {
    display: none;
  }
  .breadcrumb {
    display: none;
  }
}

@media (max-width: 480px) {
  .metrics-grid-6 {
    grid-template-columns: 1fr;
  }
  .page-title {
    font-size: 1.125rem;
  }
  .stat-value {
    font-size: 1.375rem;
  }
  .auth-card {
    padding: 24px 20px;
  }
  .modal-body,
  .modal-header,
  .modal-footer {
    padding: 16px;
  }
}

@media print {
  .sidebar, .header, .sidebar-overlay, .theme-toggle {
    display: none !important;
  }
  .app-main {
    margin-left: 0 !important;
    width: 100% !important;
  }
  .app-content {
    margin-top: 0 !important;
    padding: 0 !important;
  }
}

/* Line Clamp Utilities */
.line-clamp-1 {
  display: -webkit-box !important;
  -webkit-line-clamp: 1 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  word-break: break-word !important;
}

.line-clamp-2 {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  word-break: break-word !important;
  line-height: 1.4 !important;
  max-height: calc(1.4em * 2) !important;
}

/* Export CSV Button Style */
.btn-download-csv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff !important;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.25);
  transition: all 0.15s ease;
  cursor: pointer;
}

.btn-download-csv:hover {
  background: linear-gradient(135deg, #047857, #059669);
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

/* Post Detail Side-by-side Media & Content Grid */
.post-media-content-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .post-media-content-grid {
    grid-template-columns: 1fr;
  }
}

.post-content-box {
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 18px 20px;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  border: 1px solid var(--border);
  min-height: 190px;
  height: calc(100% - 28px);
  word-break: break-word;
  overflow-y: auto;
}

/* ============================================================
   Advanced Filters Component (Compact Modern Grid)
   ============================================================ */
.adv-filter-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  margin-bottom: 20px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.adv-filter-header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: var(--bg-card, #fff);
  transition: background 0.15s ease;
}

.adv-filter-header:hover {
  background: var(--bg-subtle, #f8fafc);
}

.adv-filter-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-primary, #0f172a);
}

.adv-filter-body {
  padding: 14px 18px;
  background: var(--bg-card, #fff);
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.adv-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.adv-filter-field {
  position: relative;
  width: 100%;
}

.adv-filter-control {
  height: 35px !important;
  padding: 5px 10px !important;
  border-radius: 8px !important;
  font-size: 0.8125rem !important;
  border: 1px solid var(--border-color, #e2e8f0) !important;
  background: var(--bg-subtle, #f8fafc) !important;
  color: var(--text-primary, #0f172a) !important;
  width: 100% !important;
  box-sizing: border-box !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
  outline: none !important;
}

.adv-filter-control:focus {
  border-color: var(--primary, #6366f1) !important;
  background: var(--bg-card, #fff) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12) !important;
}

.adv-filter-control::placeholder {
  color: var(--text-muted, #94a3b8);
  font-size: 0.8125rem;
}

.adv-filter-range {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.adv-filter-range .adv-filter-control {
  flex: 1;
  min-width: 0;
}

.adv-filter-range-sep {
  color: var(--text-muted, #94a3b8);
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
  user-select: none;
}

.adv-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 35px;
}

.adv-filter-btn-submit {
  flex: 1;
  height: 35px;
  border-radius: 8px;
  background: #4f46e5;
  border: 1px solid #4f46e5;
  color: #fff;
  font-weight: 600;
  font-size: 0.8125rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  padding: 0 12px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.adv-filter-btn-submit:hover {
  background: #4338ca;
  border-color: #4338ca;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
  transform: translateY(-1px);
}

.adv-filter-btn-reset {
  height: 35px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  color: var(--text-secondary, #475569);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.adv-filter-btn-reset:hover {
  background: var(--bg-subtle, #f8fafc);
  color: var(--text-primary, #0f172a);
  border-color: #cbd5e1;
}

/* Responsive Grid */
@media (max-width: 1200px) {
  .adv-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .adv-filter-body {
    padding: 12px 14px;
  }
  .adv-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}

@media (max-width: 520px) {
  .adv-filter-grid {
    grid-template-columns: 1fr;
  }
}
