/* =========================================================================
   KPSTA ADMIN — Premium Modern UI
   Zero hardcoded styles. All design lives here.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* =========================================================================
   DESIGN TOKENS
   ========================================================================= */
:root {
  --sidebar-bg: #1a1d2e;
  --sidebar-text: rgba(255, 255, 255, 0.55);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.08));
  --sidebar-active-text: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.05);

  --page-bg: #f5f6fa;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.08);
  --primary-glow: rgba(99, 102, 241, 0.25);
  --secondary: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --text-dark: #1e1e2d;
  --text-body: #5e6278;
  --text-muted: #a1a5b7;

  --card-bg: #ffffff;
  --border: #e8e8ed;

  --sidebar-w: 260px;
  --sidebar-rail-w: 76px;
  --topbar-h: 60px;

  --r: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-focus: 0 0 0 4px var(--primary-glow);

  --ease: 0.15s ease;
}

/* =========================================================================
   GLOBAL
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
  background: var(--page-bg) !important;
  color: var(--text-dark);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
a:hover { text-decoration: none; color: inherit; }

/* =========================================================================
   LOGIN PAGE
   ========================================================================= */
.login-page-modern {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1d2e 0%, #2d2b55 100%);
}

.modern-login-box {
  background: var(--card-bg);
  width: 100%;
  max-width: 420px;
  padding: 40px;
  border-radius: var(--r-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}

.modern-login-logo { margin-bottom: 28px; }
.modern-login-logo img { width: 72px; height: 72px; border-radius: 50%; box-shadow: var(--shadow-md); }
.modern-login-logo h1 { font-size: 22px; font-weight: 700; margin: 14px 0 0; color: var(--text-dark); }

.modern-form-group { margin-bottom: 20px; text-align: left; }
.modern-form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-body); margin-bottom: 6px; }

.modern-input {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-dark);
  background: var(--page-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  transition: var(--ease);
}
.modern-input:focus { outline: none; background: #fff; border-color: var(--primary); box-shadow: var(--shadow-focus); }

.modern-btn-primary {
  display: block;
  width: 100%;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  transition: var(--ease);
}
.modern-btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px var(--primary-glow); transform: translateY(-1px); }

.login-error-msg { color: var(--danger); background: #fef2f2; padding: 12px 16px; border-radius: var(--r); font-size: 13px; margin-bottom: 20px; border-left: 3px solid var(--danger); }

.modern-flex-between { display: flex; align-items: center; justify-content: space-between; }
.modern-checkbox-label { display: flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-body); }
.modern-link { font-size: 13px; color: var(--primary); font-weight: 500; }
.modern-link:hover { text-decoration: underline; }

/* =========================================================================
   LAYOUT
   ========================================================================= */
.modern-wrapper { display: flex; min-height: 100vh; }

/* ---- SIDEBAR ---- */
.modern-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  overflow: hidden;
  transition: transform var(--ease), width var(--ease);
}

.modern-sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.modern-brand { display: flex; align-items: center; gap: 12px; overflow: hidden; }
.modern-sidebar-header img { width: 36px; height: 36px; border-radius: 50%; background: #fff; padding: 2px; flex-shrink: 0; }
.modern-sidebar-header span { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: 0.2px; white-space: nowrap; }

/* Section labels between menu groups */
.modern-menu-section {
  margin: 18px 10px 6px !important;
  padding: 0 16px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}
.modern-menu-section:first-child { margin-top: 4px !important; }

.modern-sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  margin: 0;
  list-style: none;
}
.modern-sidebar-menu::-webkit-scrollbar { width: 3px; }
.modern-sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.modern-sidebar-menu li { margin: 2px 10px; }

.modern-sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s ease;
  letter-spacing: 0.01em;
}
.modern-sidebar-menu a i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: inherit;
  opacity: 0.8;
}

.modern-sidebar-menu a:hover,
.modern-sidebar-menu li.active > a {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-active-text);
}
.modern-sidebar-menu li.active > a {
  background: var(--primary);
  color: #fff;
}
.modern-sidebar-menu a:hover i,
.modern-sidebar-menu li.active > a i { opacity: 1; }

/* Treeview */
.modern-sidebar-menu .modern-caret {
  margin-left: auto;
  font-size: 13px !important;
  width: auto !important;
  opacity: 0.5;
  transition: transform 0.18s ease;
}
.modern-sidebar-menu .treeview.menu-open > a .modern-caret { transform: rotate(-90deg); }

.modern-sidebar-menu .treeview-menu {
  list-style: none;
  padding: 4px 0 4px 32px;
  margin: 0;
  display: none;
}
.modern-sidebar-menu .treeview-menu li { margin: 0; }
.modern-sidebar-menu .treeview-menu a { font-size: 13px; padding: 8px 16px; color: rgba(255,255,255,0.45); }
.modern-sidebar-menu .treeview-menu a:hover { color: #fff; }
.modern-sidebar-menu .treeview-menu a i { font-size: 7px; width: 14px; }

/* ---- MAIN ---- */
.modern-main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--ease);
  background: var(--page-bg);
}

/* ---- TOPBAR ---- */
.modern-topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 900;
}
.modern-topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.modern-topbar-right { display: flex; align-items: center; min-width: 0; }

.modern-topbar-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--text-dark);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modern-toggle-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--r);
  transition: var(--ease);
  line-height: 1;
}
.modern-toggle-btn:hover { color: var(--primary); background: var(--primary-light); }

.modern-user-menu {
  display: flex;
  align-items: center;
  gap: 2px;
}
.modern-user-menu a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  border-radius: 6px;
  transition: var(--ease);
}
.modern-user-menu a i { font-size: 15px; color: var(--text-muted); }
.modern-user-menu a:hover { background: var(--primary-light); color: var(--primary); }
.modern-user-menu a:hover i { color: var(--primary); }

/* "View page" jump straight to the public page this screen feeds */
.modern-user-menu a.modern-topbar-cta {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.modern-user-menu a.modern-topbar-cta i { color: var(--primary); }
.modern-user-menu a.modern-topbar-cta:hover { background: var(--primary); color: #fff; }
.modern-user-menu a.modern-topbar-cta:hover i { color: #fff; }

.modern-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modern-user-chip i { color: var(--text-muted); font-size: 14px; }

.modern-user-menu a.modern-logout:hover { background: #fef2f2; color: var(--danger); }
.modern-user-menu a.modern-logout:hover i { color: var(--danger); }

/* Backdrop behind the off canvas sidebar on small screens */
.modern-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 34, 0.5);
  z-index: 999;
}

/* ---- PAGE BODY ---- */
.modern-page-body { padding: 28px; flex: 1; }

.modern-page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 24px;
  color: var(--text-dark);
}

/* ---- FOOTER ---- */
.modern-footer {
  padding: 16px 28px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.modern-footer a { color: var(--primary); font-weight: 600; }

/* =========================================================================
   DASHBOARD
   ========================================================================= */
.modern-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.modern-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}
.modern-stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.modern-stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.modern-stat-info h3 { font-size: 28px; font-weight: 700; margin: 0; color: var(--text-dark); line-height: 1; }
.modern-stat-info p { margin: 6px 0 0; font-size: 13px; color: var(--text-muted); font-weight: 500; }

.bg-primary-soft { background: var(--primary-light); color: var(--primary); }
.bg-success-soft { background: rgba(16, 185, 129, 0.08); color: var(--secondary); }
.bg-warning-soft { background: rgba(245, 158, 11, 0.08); color: var(--warning); }
.bg-danger-soft  { background: rgba(239, 68, 68, 0.08); color: var(--danger); }
.bg-info-soft    { background: rgba(59, 130, 246, 0.08); color: var(--info); }
.bg-purple-soft  { background: rgba(139, 92, 246, 0.08); color: #8b5cf6; }

/* Stat cards link through to the screen that owns the number */
a.modern-stat-card { color: inherit; }
a.modern-stat-card:hover { border-color: var(--primary); }

/* Dashboard two column split */
.modern-dash-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.modern-dash-side { display: flex; flex-direction: column; }
@media (max-width: 991px) {
  .modern-dash-columns { grid-template-columns: minmax(0, 1fr); }
}

.modern-card-hint { font-size: 13px; color: var(--text-muted); }

/* Manage & preview list */
.modern-section-list { list-style: none; margin: 16px 0 0; padding: 0; }
.modern-section-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 8px;
  transition: var(--ease);
}
.modern-section-list li:last-child { margin-bottom: 0; }
.modern-section-list li:hover { border-color: var(--primary); background: var(--primary-light); }

.modern-section-main {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-dark);
  min-width: 0;
  flex: 1;
}
.modern-section-main i { color: var(--text-muted); width: 18px; text-align: center; }
.modern-section-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modern-section-list li:hover .modern-section-main,
.modern-section-list li:hover .modern-section-main i { color: var(--primary); }

.modern-section-view {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--border);
}
.modern-section-view:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.modern-section-view.is-muted { color: var(--text-muted); background: transparent; border-style: dashed; }

/* Active term */
.modern-term-value { font-size: 24px; font-weight: 700; color: var(--text-dark); margin: 0 0 6px; }

/* Recent list */
.modern-recent-list { list-style: none; margin: 0; padding: 0; }
.modern-recent-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13.5px;
}
.modern-recent-list li:last-child { border-bottom: none; padding-bottom: 0; }
.modern-recent-title {
  color: var(--text-dark);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modern-pill {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
}
.modern-pill.is-live { background: rgba(16, 185, 129, 0.12); color: var(--secondary); }
.modern-pill.is-draft { background: rgba(245, 158, 11, 0.14); color: var(--warning); }

/* Modern Card */
.modern-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}
.modern-card-header { padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modern-card-title { font-size: 17px; font-weight: 700; margin: 0; color: var(--text-dark); }
.modern-card-body { padding: 24px; color: var(--text-body); line-height: 1.7; font-size: 14px; }
.modern-card-body p { margin: 0 0 12px; }
.modern-card-body p:last-child { margin-bottom: 0; }

/* =========================================================================
   BOOTSTRAP / ADMINLTE OVERRIDES
   ========================================================================= */

/* Content wrapper */
.content-wrapper {
  background: transparent !important;
  min-height: auto !important;
  padding: 0 !important;
  margin-left: 0 !important;
}
.content-header { padding: 0 0 12px !important; }
.content-header .page-header { margin: 0; padding: 0; border: none; }
.content-header h3 { font-size: 22px; font-weight: 700; color: var(--text-dark); margin: 0; }
.content { padding: 0 !important; }

/* Box */
.box {
  background: var(--card-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow) !important;
  margin-bottom: 20px !important;
  overflow: hidden;            /* keep the rounded corners clipping the header */
}
.box-header {
  padding: 16px 24px !important;
  border-bottom: 1px solid var(--border) !important;
  background: var(--card-bg) !important;
}
.box-header.with-border { border-bottom: 1px solid var(--border) !important; }
.box-title { font-weight: 700 !important; font-size: 17px !important; color: var(--text-dark) !important; }
.box-body { padding: 24px !important; }
.box-footer {
  padding: 16px 24px !important;
  background: #fafbfc !important;
  border-top: 1px solid var(--border) !important;
}

/* Tables */
.table { font-size: 14px; margin-bottom: 0; }
.table > thead > tr > th {
  border-bottom: none !important;
  font-weight: 600;
  color: #ffffff;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px !important;
  background: var(--primary) !important;
  white-space: nowrap;
}
.table > tbody > tr > td {
  border-top: 1px solid var(--border) !important;
  vertical-align: middle !important;
  color: var(--text-dark);
  padding: 14px 16px !important;
  font-size: 14px;
}
.table > tbody > tr:hover > td { background: var(--primary-light) !important; }
.table > tbody > tr:last-child > td { border-bottom: none !important; }

/* Shrink columns to give space for Email/Data */
.table td.td-publish,
.table td:has(.btn-group.publish), 
.table td.td-actions,
.table td:has(.modern-actions),
.table td:has(.btn-edit) {
  width: 1%;
  white-space: nowrap;
}

/* =========================================================================
   TOGGLE SWITCH (replaces two-button publish)
   ========================================================================= */
.btn-group.publish,
.btn-group.publish[data-toggle="buttons"] {
    position: relative !important;
    width: 48px !important;
    height: 26px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    min-height: 26px !important;
    max-height: 26px !important;
    border-radius: 13px !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    display: inline-block !important;
    vertical-align: middle !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}
.btn-group.publish label.btn,
.btn-group.publish[data-toggle="buttons"] label.btn,
.btn-group.publish[data-toggle="buttons"] label.btn.active {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    font-size: 0 !important;
    color: transparent !important;
    border-radius: 13px !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
}
.btn-group.publish label span { display: none !important; }

.btn-group.publish label.active,
.btn-group.publish[data-toggle="buttons"] label.btn.active {
    display: block !important;
    z-index: 1 !important;
    transition: background-color 0.3s ease !important;
}
.btn-group.publish label:not(.active),
.btn-group.publish[data-toggle="buttons"] label.btn:not(.active) {
    display: block !important;
    z-index: 2 !important;
    background: transparent !important;
    cursor: pointer !important;
}
.btn-group.publish label.active[data-active-class="success"],
.btn-group.publish[data-toggle="buttons"] label.btn.active[data-active-class="success"] {
    background-color: #10b981 !important;
    background: #10b981 !important;
}
.btn-group.publish label.active[data-active-class="success"]::after,
.btn-group.publish[data-toggle="buttons"] label.btn.active[data-active-class="success"]::after {
    content: '' !important;
    position: absolute !important;
    top: 2px !important;
    left: 2px !important;
    width: 22px !important;
    height: 22px !important;
    background: #fff !important;
    border-radius: 50% !important;
    transform: translateX(22px) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}
.btn-group.publish label.active[data-active-class="danger"],
.btn-group.publish[data-toggle="buttons"] label.btn.active[data-active-class="danger"] {
    background-color: #cbd5e1 !important;
    background: #cbd5e1 !important;
}
.btn-group.publish label.active[data-active-class="danger"]::after,
.btn-group.publish[data-toggle="buttons"] label.btn.active[data-active-class="danger"]::after {
    content: '' !important;
    position: absolute !important;
    top: 2px !important;
    left: 2px !important;
    width: 22px !important;
    height: 22px !important;
    background: #fff !important;
    border-radius: 50% !important;
    transform: translateX(0) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}
.btn-group.publish label i.fa-spinner {
    font-size: 11px !important;
    color: #64748b !important;
    position: absolute !important;
    top: 7px !important;
    left: 7px !important;
    z-index: 3 !important;
}

/* =========================================================================
   ACTION BUTTONS (ICON ONLY)
   ========================================================================= */
.table .modern-actions .btn,
.table .btn-edit, 
.table .btn-delete, 
.table .btn-view {
    padding: 6px !important;
    font-size: 0 !important;
    border-radius: 6px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 4px;
}
.table .modern-actions .btn:last-child,
.table .btn-view { margin-right: 0; }

.table .modern-actions .btn i,
.table .btn-edit i, 
.table .btn-delete i, 
.table .btn-view i {
    font-size: 14px !important;
    margin: 0 !important;
}

/* Buttons */
.btn {
  border-radius: var(--r) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  padding: 8px 16px !important;
  transition: all 0.15s ease !important;
  border: 1.5px solid transparent !important;
  letter-spacing: 0.01em;
}
.btn-primary, .btn-info {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  box-shadow: 0 1px 3px var(--primary-glow) !important;
}
.btn-primary:hover, .btn-info:hover {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  box-shadow: 0 4px 12px var(--primary-glow) !important;
  transform: translateY(-1px);
}
.btn-default {
  background: var(--card-bg) !important;
  border-color: var(--border) !important;
  color: var(--text-body) !important;
}
.btn-default:hover {
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  background: var(--primary-light) !important;
}
.btn-danger {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
  box-shadow: 0 1px 3px rgba(239,68,68,0.25) !important;
}
.btn-danger:hover { box-shadow: 0 4px 12px rgba(239,68,68,0.3) !important; transform: translateY(-1px); }
.btn-success {
  background: var(--secondary) !important;
  border-color: var(--secondary) !important;
  color: #fff !important;
}

/* Btn-group joined */
.btn-group > .btn { border-radius: 0 !important; }
.btn-group > .btn:first-child { border-top-left-radius: var(--r) !important; border-bottom-left-radius: var(--r) !important; }
.btn-group > .btn:last-child,
.btn-group > .dropdown-toggle { border-top-right-radius: var(--r) !important; border-bottom-right-radius: var(--r) !important; }
.btn-group > .btn:only-child { border-radius: var(--r) !important; }
.btn-group > .btn + .btn, .btn-group > .btn-group { margin-left: -1px; }
.btn-group .btn-group > .btn { border-radius: 0 !important; }
.btn-group .btn-group:last-child > .btn { border-top-right-radius: var(--r) !important; border-bottom-right-radius: var(--r) !important; }

@media (min-width: 769px) {
  .table-responsive { overflow: visible !important; }
}

.box-body .alert.col-md-offset-3 {
  float: none !important;
  margin-left: auto !important;
  margin-right: auto !important;
  display: block;
  max-width: 600px;
}

/* Form controls */
.form-group { margin-bottom: 20px !important; }
.form-control {
  border-radius: var(--r) !important;
  padding: 10px 14px !important;
  height: auto !important;
  border: 1.5px solid var(--border) !important;
  box-shadow: none !important;
  font-size: 14px !important;
  font-family: inherit !important;
  color: var(--text-dark) !important;
  background: #f8fafc !important;
  transition: all 0.2s ease !important;
}
.form-control:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px var(--primary-light) !important;
  background: #fff !important;
  outline: none !important;
}
.form-control::placeholder { color: var(--text-muted) !important; font-weight: 400; }
textarea.form-control { min-height: 100px; resize: vertical; line-height: 1.6; }
select.form-control { cursor: pointer; appearance: auto; height: 44px !important; }

/* select2 widgets should match the height and border of the native controls */
.select2-container .select2-selection--single {
  height: 44px !important;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--r) !important;
  background: #f8fafc !important;
}
.select2-container .select2-selection--single .select2-selection__rendered {
  line-height: 41px !important;
  padding-left: 14px !important;
  color: var(--text-dark) !important;
}
.select2-container .select2-selection--single .select2-selection__arrow {
  height: 42px !important;
}
.select2-container--open .select2-selection--single {
  border-color: var(--primary) !important;
  background: #fff !important;
}
.select2-container { width: 100% !important; }

/* Form labels in content areas */
.form-group label,
.control-label {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #475569 !important;
  margin-bottom: 8px !important;
  display: block;
  letter-spacing: 0.01em;
}

/* Modals — premium look */
.modal-dialog {
  margin: 30px auto !important;
}
.modal-content {
  border-radius: var(--r-xl) !important;
  border: none !important;
  box-shadow: 0 24px 80px rgba(0,0,0,0.15) !important;
  overflow: hidden;
  background: #ffffff !important;
  /* Keep the header and footer pinned so Save/Cancel stay reachable */
  display: flex !important;
  flex-direction: column !important;
  max-height: calc(100vh - 60px) !important;
}
.modal-header,
.modal-footer {
  flex: 0 0 auto;
}
/* The admin forms wrap header/body/footer in a <form>, so the flex chain has to
   pass through it or the body never shrinks and the dialog runs off-screen. */
.modal-content > form,
.modal-content-form > form {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
}
.modal-header {
  border-bottom: 1px solid #f1f5f9 !important;
  padding: 24px 28px !important;
  background: #ffffff !important;
}
.modal-header .modal-title {
  font-size: 20px !important;
  font-weight: 700 !important;
  color: #1e293b !important;
  margin: 0;
}
.modal-header .close {
  font-size: 24px;
  opacity: 0.4;
  transition: var(--ease);
  margin-top: -4px !important;
}
.modal-header .close:hover { opacity: 0.8; color: var(--danger); }
.modal-body {
  padding: 28px !important;
  font-size: 14px;
  color: var(--text-body);
  background: #ffffff !important;
  /* Tall forms scroll inside the dialog instead of running off-screen */
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  min-height: 0 !important;
}
.modal-footer {
  border-top: 1px solid #f1f5f9 !important;
  padding: 20px 28px !important;
  background: #f8fafc !important;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.modal-footer .btn { margin: 0 !important; }
.modal-backdrop.in { opacity: 0.6 !important; background: #0f172a !important; }

/* Tablet Modal Adaptations */
@media (min-width: 769px) and (max-width: 991px) {
  .modal-dialog {
    margin: 20px auto !important;
    width: 92% !important;
    max-width: 700px !important;
  }
  .modal-content {
    max-height: calc(100vh - 40px) !important;
  }
}

/* Mobile Full-Screen Touch Sheet Modal */
@media (max-width: 768px) {
  .modal {
    padding: 0 !important;
    overflow-y: hidden !important;
  }
  .modal-dialog {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    padding: 0 !important;
  }
  .modal-content {
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
  }
  .modal-header {
    padding: 16px 18px !important;
    background: #ffffff !important;
    border-bottom: 1.5px solid var(--border) !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 1060 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }
  .modal-header .modal-title {
    font-size: 18px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
  }
  .modal-header .close {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background: #f1f5f9 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 22px !important;
    opacity: 0.8 !important;
    margin: 0 !important;
    line-height: 1 !important;
  }
  .modal-body {
    padding: 20px 18px 28px !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
  }
  .modal-footer {
    padding: 12px 18px !important;
    background: #ffffff !important;
    border-top: 1.5px solid var(--border) !important;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.06) !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 1060 !important;
  }
  .modal-footer .btn {
    flex: 1 1 50% !important;
    min-height: 48px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    margin: 0 !important;
  }
}

/* Alerts */
.alert {
  border-radius: var(--r) !important;
  border: none !important;
  font-size: 14px;
  padding: 14px 18px !important;
}
.alert-warning { background: #fffbeb !important; color: #92400e !important; border-left: 3px solid var(--warning) !important; }
.alert-danger { background: #fef2f2 !important; color: #991b1b !important; border-left: 3px solid var(--danger) !important; }
.alert-success { background: #f0fdf4 !important; color: #166534 !important; border-left: 3px solid var(--secondary) !important; }
.alert-info { background: #eff6ff !important; color: #1e40af !important; border-left: 3px solid var(--info) !important; }

/* Pagination */
.pagination > li > a {
  border-radius: var(--r) !important;
  margin: 0 3px;
  font-size: 13px;
  color: var(--text-body);
  border-color: var(--border);
  padding: 6px 12px;
}
.pagination > .active > a { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }

/* Dropdowns */
.dropdown-menu {
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--border) !important;
  padding: 6px !important;
  animation: dropdownFade 0.15s ease;
}
@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.dropdown-menu > li > a {
  border-radius: 6px;
  padding: 9px 14px !important;
  font-size: 13px;
  color: var(--text-body) !important;
  transition: var(--ease);
}
.dropdown-menu > li > a:hover { background: var(--primary-light) !important; color: var(--primary) !important; }

/* Labels */
.label { border-radius: 4px !important; font-weight: 600; font-size: 11px; padding: 3px 8px !important; }

/* Input groups */
.input-group .form-control { border-radius: 0 !important; }
.input-group .form-control:first-child,
.input-group-btn:first-child > .btn { border-top-left-radius: var(--r) !important; border-bottom-left-radius: var(--r) !important; }
.input-group .form-control:last-child,
.input-group-btn:last-child > .btn { border-top-right-radius: var(--r) !important; border-bottom-right-radius: var(--r) !important; }

/* Toolbar */
.std-toolbar { display: inline-flex; }

/* ---- Highlighted Primary "New" / "Add" Buttons in Toolbar ---- */
.std-toolbar [data-id="new"],
.toolbar [data-id="new"],
.toolbar a[data-target="#modal"][data-id="new"],
.toolbar a.btn-default[data-toggle="modal"] {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  font-size: 13.5px !important;
  padding: 8px 16px !important;
  border-radius: var(--r) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  box-shadow: 0 2px 8px var(--primary-glow) !important;
  transition: all 0.2s ease !important;
}
.std-toolbar [data-id="new"]:hover,
.toolbar [data-id="new"]:hover,
.toolbar a.btn-default[data-toggle="modal"]:hover {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--primary-glow) !important;
}
.std-toolbar [data-id="new"] i,
.toolbar [data-id="new"] i,
.toolbar a.btn-default[data-toggle="modal"] i {
  color: #ffffff !important;
  font-size: 13px !important;
}
/* Ensure the word "New" or text is NEVER hidden on mobile or tablet */
.std-toolbar [data-id="new"] .hidden-xs,
.std-toolbar [data-id="new"] .hidden-sm,
.toolbar [data-id="new"] .hidden-xs,
.toolbar [data-id="new"] .hidden-sm {
  display: inline !important;
  font-weight: 700 !important;
}

/* Floating Action Button (FAB) for Mobile Quick Content Add */
.mobile-fab-add {
  display: none;
}
@media (max-width: 768px) {
  .mobile-fab-add {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 22px;
    right: 18px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 6px 22px var(--primary-glow);
    z-index: 950;
    cursor: pointer;
    font-size: 22px;
    transition: transform 0.18s ease, background 0.18s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-fab-add:active {
    transform: scale(0.92);
    background: var(--primary-hover);
  }
  body.modal-open .mobile-fab-add {
    display: none !important;
  }
}

/* File input fixing native overlapping */
.btn-file {
  position: relative;
  overflow: hidden;
}
.btn-file input[type="file"] {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 100%;
  min-height: 100%;
  font-size: 100px;
  text-align: right;
  opacity: 0;
  outline: none;
  background: white;
  cursor: inherit;
  display: block;
}

/* Toggle buttons / Radio inside btn-group */
.btn-group[data-toggle="buttons"] .btn {
  padding: 8px 20px !important;
  font-weight: 600 !important;
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  color: #64748b !important;
  transition: all 0.2s ease !important;
}
.btn-group[data-toggle="buttons"]:not(.publish) .btn:hover {
  background: #e2e8f0 !important;
  color: #475569 !important;
}
.btn-group[data-toggle="buttons"]:not(.publish) .btn.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px var(--primary-glow) !important;
}
.btn-group[data-toggle="buttons"]:not(.publish) .btn.active[data-active-class="danger"] {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3) !important;
}
.btn-group[data-toggle="buttons"]:not(.publish) .btn.active[data-active-class="success"] {
  background: var(--secondary) !important;
  border-color: var(--secondary) !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3) !important;
}

/* Checkbox / Radio */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--primary);
}

/* =========================================================================
   SIDEBAR STATES
   ========================================================================= */

/* ---- Desktop: collapsed icon rail ----
   The sidebar keeps its icons so navigation stays usable while collapsed,
   and expands back on hover. */
@media (min-width: 992px) {
  .modern-wrapper.sidebar-collapsed .modern-sidebar { width: var(--sidebar-rail-w); }
  .modern-wrapper.sidebar-collapsed .modern-main-content { margin-left: var(--sidebar-rail-w); }

  .modern-wrapper.sidebar-collapsed .modern-sidebar-header { padding: 0; justify-content: center; }
  .modern-wrapper.sidebar-collapsed .modern-brand span,
  .modern-wrapper.sidebar-collapsed .modern-sidebar-menu > li > a > span,
  .modern-wrapper.sidebar-collapsed .modern-caret,
  .modern-wrapper.sidebar-collapsed .modern-menu-section span { display: none; }

  .modern-wrapper.sidebar-collapsed .modern-menu-section {
    height: 1px;
    margin: 12px 18px !important;
    padding: 0;
    background: var(--sidebar-border);
  }

  .modern-wrapper.sidebar-collapsed .modern-sidebar-menu > li > a {
    justify-content: center;
    padding: 12px 0;
  }
  .modern-wrapper.sidebar-collapsed .modern-sidebar-menu > li > a > i { font-size: 18px; }
  .modern-wrapper.sidebar-collapsed .modern-sidebar-menu .treeview-menu { display: none !important; }

  /* Peek back to full width while the pointer is over the rail */
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover { width: var(--sidebar-w); box-shadow: var(--shadow-lg); }
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover .modern-sidebar-header { padding: 0 20px; justify-content: flex-start; }
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover .modern-brand span,
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover .modern-sidebar-menu > li > a > span,
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover .modern-caret { display: inline; }
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover .modern-menu-section {
    height: auto;
    margin: 18px 10px 6px !important;
    padding: 0 16px;
    background: none;
  }
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover .modern-menu-section span { display: block; }
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover .modern-sidebar-menu > li > a { justify-content: flex-start; padding: 10px 16px; }
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover .modern-sidebar-menu > li > a > i { font-size: 16px; }
  .modern-wrapper.sidebar-collapsed .modern-sidebar:hover .modern-sidebar-menu .treeview.menu-open > .treeview-menu { display: block !important; }
}

/* Avoids a flash of the expanded sidebar before the script restores state */
html.pre-collapsed .modern-sidebar { width: var(--sidebar-rail-w); }
html.pre-collapsed .modern-main-content { margin-left: var(--sidebar-rail-w); }

/* =========================================================================
   RESPONSIVE (Mobile & Tablet)
   ========================================================================= */
@media (max-width: 991px) {
  .modern-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    box-shadow: var(--shadow-lg);
  }
  .modern-wrapper.sidebar-open .modern-sidebar { transform: translateX(0); }
  .modern-wrapper.sidebar-open .modern-sidebar-backdrop { display: block; }

  html.pre-collapsed .modern-sidebar { width: var(--sidebar-w); }
  html.pre-collapsed .modern-main-content,
  .modern-main-content { margin-left: 0 !important; }

  .modern-page-body { padding: 16px; }
  .modern-topbar { padding: 0 14px; }
  .modern-topbar-title { font-size: 15px; }

  /* Keep the topbar actions usable on narrow screens */
  .modern-user-menu a span { display: none; }
  .modern-user-menu a { padding: 8px 10px; }
  .modern-user-chip { max-width: 110px; margin-left: 4px; padding: 6px 10px; }
}

@media (max-width: 768px) {
  .page-header {
    margin: 0 0 16px 0 !important;
    padding: 0 !important;
  }
  .page-header .box-layout {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
  }
  .page-header .box-layout > [class*="col-"] {
    width: auto !important;
    flex: 0 1 auto !important;
  }
  .page-header .box-layout > [class*="col-"]:first-child {
    flex: 1 1 auto !important;
    min-width: 0;
  }
  .page-header h3 {
    font-size: 18px !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .page-header .toolbar {
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
  }
  .page-header .std-toolbar [data-id="new"] {
    padding: 8px 14px !important;
    font-size: 13.5px !important;
    white-space: nowrap !important;
  }

  /* Form controls touch optimization */
  .form-group {
    margin-bottom: 18px !important;
  }
  .form-group label,
  .control-label {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    margin-bottom: 6px !important;
  }
  .form-control,
  input.form-control,
  select.form-control {
    min-height: 46px !important;
    font-size: 16px !important; /* Prevents auto-zoom in mobile Safari */
    padding: 10px 14px !important;
    border-radius: 8px !important;
  }
  .input-group-addon {
    min-height: 46px !important;
    padding: 10px 14px !important;
    font-size: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .input-group.date {
    display: flex !important;
    align-items: stretch !important;
    width: 100% !important;
  }
  .input-group.date .form-control {
    flex: 1 1 auto !important;
  }

  /* Segmented buttons (Upload type / Published / Status) */
  .btn-group[data-toggle="buttons"],
  .upload-type-toggle {
    display: flex !important;
    width: 100% !important;
    margin: 4px 0 10px !important;
    border-radius: 8px !important;
  }
  .btn-group[data-toggle="buttons"] .btn,
  .upload-type-toggle .btn {
    flex: 1 1 50% !important;
    min-height: 46px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    padding: 10px 14px !important;
  }

  /* File upload button & caption */
  .file-caption-main {
    display: flex !important;
    width: 100% !important;
    min-height: 46px !important;
  }
  .file-caption-main > .file-caption {
    min-height: 46px !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    flex: 1 1 auto !important;
  }
  .file-caption-main > .input-group-btn > .btn-file {
    min-height: 46px !important;
    padding: 10px 18px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  /* Select2 Mobile Friendly */
  .select2-container .select2-selection--single,
  .select2-container .select2-selection--multiple {
    min-height: 46px !important;
    border-radius: 8px !important;
    font-size: 15px !important;
    padding: 4px 8px !important;
  }
  .select2-container--default .select2-selection--multiple .select2-selection__choice {
    padding: 4px 10px !important;
    font-size: 13px !important;
    border-radius: 6px !important;
    margin-top: 4px !important;
  }
  .select2-dropdown {
    z-index: 1080 !important;
    font-size: 15px !important;
    border-radius: 10px !important;
  }
  .select2-results__option {
    padding: 12px 16px !important;
    font-size: 14px !important;
  }

  /* Datepicker popup inside modals */
  .datepicker.dropdown-menu {
    z-index: 1090 !important;
    padding: 12px !important;
    border-radius: 12px !important;
    box-shadow: 0 12px 36px rgba(0,0,0,0.18) !important;
    border: 1px solid var(--border) !important;
  }
  .datepicker table tr td,
  .datepicker table tr th {
    width: 38px !important;
    height: 38px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
  }
  .datepicker table tr td.active,
  .datepicker table tr td.active:hover {
    background-color: var(--primary) !important;
    background-image: none !important;
  }

  /* Table action buttons & touch - icon only, no text bleed */
  .table .modern-actions .btn,
  .table .btn-edit,
  .table .btn-delete,
  .table .btn-view {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    margin-right: 6px !important;
    font-size: 0 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
  }
  .table .modern-actions .btn i,
  .table .btn-edit i,
  .table .btn-delete i,
  .table .btn-view i {
    font-size: 14px !important;
    margin: 0 !important;
  }
  .table td, .table th {
    padding: 12px 14px !important;
  }

  /* Delete confirmation dialog */
  #delete .modal-dialog {
    margin: 24px auto !important;
    width: 92% !important;
    max-width: 380px !important;
    height: auto !important;
    min-height: auto !important;
  }
  #delete .modal-content {
    min-height: auto !important;
    height: auto !important;
    border-radius: var(--r-xl) !important;
  }
  #delete .modal-body {
    padding: 24px !important;
    display: flex !important;
    gap: 12px !important;
  }
  #delete .modal-body .btn {
    flex: 1 !important;
    min-height: 46px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
  }
}

@media (max-width: 480px) {
  .modern-user-chip { display: none; }
  .modern-topbar-title { font-size: 14px; }
}

/* =========================================================================
   MODERN TABLE COMPONENTS (TRENDING UI)
   ========================================================================= */

/* Table Avatars */
.modern-avatar-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modern-avatar-group img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.modern-avatar-text {
  font-weight: 600;
  color: var(--text-dark);
}

/* Modern Checkbox (Standalone) */
.modern-table-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0 !important;
}

/* (Removed old modern-status-toggle and modern-actions block in favor of new unified toggle switch and icon styles) */

/* ==========================================================================
   ADMIN TOOLBAR / PAGE HEADER LAYOUT
   ==========================================================================
   The admin views wrap their header and search rows in `.box-layout`, whose
   children are floated Bootstrap `col-*` columns. `.box-layout` itself is not
   defined in any stylesheet (it never was, including in the original build),
   so the float parent collapsed to height 0 and the title, the New button and
   the search row all piled onto each other. Making it a flex row gives it a
   real height and lets the helper classes beside it (`va-m`, `toolbar`) do
   what their names imply.
   ========================================================================== */
.box-layout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

/* Floats are ignored on flex items, so the Bootstrap columns inside stop
   collapsing; drop their gutters and let them size to content instead. */
.box-layout > [class*="col-"] {
  float: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  width: auto !important;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* First column holds the page title and takes the slack; the toolbar column
   hugs the right edge. */
.box-layout > [class*="col-"]:first-child { flex: 1 1 auto; }
.box-layout > [class*="col-"]:last-child { flex: 0 0 auto; margin-left: auto; }
.box-layout > [class*="col-"]:only-child { flex: 1 1 100%; }

.box-layout .pull-left,
.box-layout .pull-right { float: none !important; }

.va-m { vertical-align: middle; }

.toolbar { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.toolbar.text-right { text-align: right; }

/* An empty spacer div sits between the title and the toolbar in several views */
.box-layout .col-xs-2.text-right:empty { display: none; }
.box-layout .clearfix { display: none; }

/* ---- search input group ------------------------------------------------ */
/* Bootstrap 3 renders `.input-group` as a table; the surrounding flex context
   left the help button detached from the field. */
.box-header .input-group,
.box-layout .input-group {
  display: flex;
  align-items: stretch;
  width: auto;
  max-width: 100%;
  float: none !important;
  margin: 0 !important;
}

.box-header .input-group > .form-control,
.box-layout .input-group > .form-control {
  width: auto;
  flex: 1 1 240px;
  min-width: 160px;
}

.box-header .input-group .input-group-btn,
.box-layout .input-group .input-group-btn {
  display: flex;
  width: auto;
  font-size: inherit;
  white-space: nowrap;
}

/* Keep the segments visually welded together */
.box-header .input-group > .form-control,
.box-header .input-group .input-group-btn > .btn {
  margin: 0 !important;
}
.box-header .input-group .input-group-btn:not(:last-child) > .btn { margin-right: -1px !important; }
.box-header .input-group .input-group-btn:not(:first-child) > .btn { margin-left: -1px !important; }

.no-margin { margin: 0 !important; }

/* Weld the search control into one unit. The generic `.btn` rule sets a
   radius with !important, so the *inner* corners of each segment stayed
   rounded and the group read as three separate pills — square them off
   explicitly and only round the two outer ends. */
.box-header .input-group > .form-control,
.box-layout .input-group > .form-control {
  border-radius: 0 !important;
}
.box-header .input-group .input-group-btn:first-child > .btn,
.box-layout .input-group .input-group-btn:first-child > .btn {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-top-left-radius: var(--r) !important;
  border-bottom-left-radius: var(--r) !important;
}
.box-header .input-group .input-group-btn:last-child > .btn,
.box-layout .input-group .input-group-btn:last-child > .btn {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  border-top-right-radius: var(--r) !important;
  border-bottom-right-radius: var(--r) !important;
}
/* When the field itself is the first/last element in the group */
.box-header .input-group > .form-control:first-child {
  border-top-left-radius: var(--r) !important;
  border-bottom-left-radius: var(--r) !important;
}
.box-header .input-group > .form-control:last-child {
  border-top-right-radius: var(--r) !important;
  border-bottom-right-radius: var(--r) !important;
}
/* Share one continuous border colour across the welded segments.
   Scoped to the neutral buttons only — applying it to every button in the
   group blanked out .btn-primary search buttons (white icon on white). */
.box-header .input-group .input-group-btn > .btn-default {
  border-color: var(--border) !important;
  background: #fff !important;
}

/* The category filter / select2 sitting next to the search box.
   These four control types were rendering at 42 / 36 / 44 / 38px on four
   different baselines; pin them to one height so the row reads as a row. */
.box-header .form-inline .select2-container,
.box-header .form-inline > .form-control {
  margin-left: 10px;
  vertical-align: middle;
}

.box-header .input-group,
.box-header .input-group > .form-control,
.box-header .input-group .input-group-btn > .btn,
.box-header .form-inline > .form-control,
.box-header select.form-control,
.box-header .select2-container .select2-selection--single,
.box-header .btn-danger,
.box-header .btn-delete-all {
  height: 42px !important;
  min-height: 42px !important;
  align-self: center;
}

.box-header .select2-container { height: 42px !important; }
.box-header .select2-container .select2-selection--single .select2-selection__rendered {
  line-height: 40px !important;
}
.box-header .select2-container .select2-selection--single .select2-selection__arrow {
  height: 40px !important;
}

/* Keep every control on the same baseline regardless of wrapper.
   The category filter lives in a *nested* `col-md-6` inside the search
   column, so it kept Bootstrap's float and gutters and sat 10px high. */
.box-header .box-layout > [class*="col-"] {
  align-items: center;
}

.box-header .form-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.box-header .form-inline > [class*="col-"],
.box-header .form-inline > .form-group {
  float: none !important;
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  display: flex;
  align-items: center;
}

.box-header .form-inline .form-group { min-width: 260px; flex: 1 1 260px; max-width: 420px; }
.box-header .form-inline .select2-container { margin-left: 0; }

/* ---- box header row ---------------------------------------------------- */
.box-header.with-border .box-layout {
  justify-content: space-between;
  row-gap: 10px;
}

/* Bulk-delete and other trailing actions align right without floating */
.box-header .box-layout .btn-delete-all,
.box-header .box-layout .pull-right {
  margin-left: auto;
}

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 767px) {
  .box-layout { gap: 10px; }
  .box-layout > [class*="col-"] { flex: 1 1 100% !important; margin-left: 0 !important; }
  .toolbar { justify-content: flex-start; }
  .box-header .input-group { width: 100%; }
}

/* ---- Mobile App Table Card Model (Single Reusable Model) ----------------
   Eliminate sideways scrolling completely. Tables transform into responsive,
   touch-friendly mobile cards with clear typography, badges, and action bars. */
.modern-main-content {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.box-body { max-width: 100%; min-width: 0; }

.box-body > .table,
.box-body > form > .table,
.box-body .table-responsive,
#table-content {
  width: 100%;
}

@media (min-width: 768px) {
  .box-body > .table,
  .box-body > form > .table,
  .box-body .table-responsive,
  #table-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 767px) {
  .content-wrapper,
  .modern-content { overflow-x: hidden; }

  .box-header .box-layout,
  .box-header .form-inline { width: 100%; }

  .box-header .form-inline > [class*="col-"],
  .box-header .form-inline > .form-group,
  .box-header .input-group { width: 100% !important; flex: 1 1 100% !important; }

  .box-header .form-inline .form-group { min-width: 0; }

  .page-header .box-layout > [class*="col-"]:last-child { margin-left: 0; }

  /* Table container - zero sideways scroll */
  .box-body > .table,
  .box-body > form > .table,
  .box-body .table-responsive,
  #table-content {
    overflow-x: visible !important;
    width: 100% !important;
    display: block !important;
  }

  /* Table structure */
  .box-body table.table,
  #table-content table.table,
  .table-responsive table.table {
    display: block !important;
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Hide traditional column header row */
  .box-body table.table > thead,
  #table-content table.table > thead,
  .table-responsive table.table > thead {
    display: none !important;
  }

  /* Rows list */
  .box-body table.table > tbody,
  #table-content table.table > tbody,
  .table-responsive table.table > tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  /* Each row is a mobile card */
  .box-body table.table > tbody > tr,
  #table-content table.table > tbody > tr,
  .table-responsive table.table > tbody > tr {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    background: #ffffff !important;
    border-radius: 12px !important;
    border: 1px solid var(--border, #e8e8ed) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02) !important;
    padding: 14px 16px !important;
    margin-bottom: 0 !important;
    position: relative !important;
    gap: 6px 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Reset all cell defaults inside mobile card */
  .box-body table.table > tbody > tr > td,
  #table-content table.table > tbody > tr > td,
  .table-responsive table.table > tbody > tr > td {
    display: flex !important;
    align-items: center !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
    min-height: 0 !important;
  }

  /* Checkbox / ID / Position */
  .table td.td-select,
  .table td:has(input[type="checkbox"]),
  .table td.col-md-1:first-child,
  .table td:first-child:has(.text-center) {
    order: 1 !important;
    flex: 0 0 auto !important;
    width: auto !important;
    margin-right: 4px !important;
  }
  .table td input[type="checkbox"].list-checkbox {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
  }

  /* Date */
  .table td.td-date,
  .table td:nth-child(2):not(.text-ellipsis):not(.td-title) {
    order: 2 !important;
    flex: 0 0 auto !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: var(--text-muted, #71717a) !important;
  }

  /* Badges & Upload Types (PDF, URL, Category tags) */
  .table td.td-badge,
  .table td:has(.btn-xs),
  .table td:has(.label) {
    order: 3 !important;
    flex: 0 0 auto !important;
    gap: 4px !important;
  }
  .table td .btn-xs,
  .table td .label {
    font-size: 11px !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    text-transform: uppercase !important;
    font-weight: 700 !important;
  }

  /* Publish toggle switch - right aligned in header row */
  .table td.td-publish,
  .table td:has(.btn-group.publish) {
    order: 4 !important;
    margin-left: auto !important;
    flex: 0 0 48px !important;
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 26px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Title / Description - full width prominent text */
  .table td.td-title,
  .table td.text-ellipsis {
    order: 10 !important;
    flex: 1 1 100% !important;
    width: 100% !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: 14.5px !important;
    font-weight: 600 !important;
    line-height: 1.45 !important;
    color: var(--text-dark, #1e1e2d) !important;
    margin: 4px 0 6px 0 !important;
    word-break: break-word !important;
  }

  /* Secondary metadata */
  .table td.td-meta {
    order: 12 !important;
    flex: 1 1 100% !important;
    font-size: 12px !important;
    color: var(--text-muted, #a1a5b7) !important;
    word-break: break-all !important;
  }

  /* Action buttons row */
  .table td.td-actions,
  .table td:has(.modern-actions),
  .table td:has(.btn-edit),
  .table td:last-child {
    order: 20 !important;
    flex: 1 1 100% !important;
    width: 100% !important;
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    border-top: 1px dashed #f0f0f4 !important;
    padding-top: 10px !important;
    margin-top: 4px !important;
  }

  .table .modern-actions {
    display: flex !important;
    gap: 8px !important;
    align-items: center !important;
    justify-content: flex-end !important;
    width: 100% !important;
  }
}

/* ------------------------------------------------------------------ *
 * Row select checkbox (clean centered cell; the old input-group box
 * rendered as a half-open rectangle)
 * ------------------------------------------------------------------ */
table .list-checkbox,
table .list-checkbox-all { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }
table td .text-center { min-width: 34px; }

/* ------------------------------------------------------------------ *
 * File upload field in the Add/Edit popups
 *
 * The kv-fileinput markup is a Bootstrap-3 table `.input-group`; inside a
 * modal that table layout drifts, so the caption and Browse render as two
 * detached boxes. Force a flat flex row so they weld into one control, and
 * show Remove (as a compact X) only when a file is present.
 * ------------------------------------------------------------------ */
.file-caption-main {
  display: flex !important;
  align-items: stretch;
  width: 100%;
}
.file-caption-main > .file-caption {
  flex: 1 1 auto;
  display: flex !important;
  align-items: center;
  min-width: 0;                                   /* let it shrink instead of overflowing */
  height: 44px;
  margin: 0 !important;
  border: 1.5px solid var(--border) !important;
  border-right: none !important;
  border-radius: var(--r) 0 0 var(--r) !important;
  background: #f8fafc !important;
}
.file-caption-main > .file-caption .file-caption-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  color: var(--text-body);
}
.file-caption-main > .input-group-btn {
  display: flex !important;
  flex: 0 0 auto;
  width: auto !important;
}
.file-caption-main > .input-group-btn > .btn {
  height: 44px;
  display: inline-flex;
  align-items: center;
  margin: 0 !important;
  border-radius: 0 !important;
}
/* the last visible button (Browse, or Remove when Browse is somehow hidden)
   closes the right edge */
.file-caption-main > .input-group-btn > .btn-file {
  border-radius: 0 var(--r) var(--r) 0 !important;
}
.file-caption-main .fileinput-remove-button .glyphicon-trash { margin: 0; }
.file-caption-main .fileinput-remove-button span { display: none; }     /* keep the trash icon as a compact X, drop the word */
.file-input-new .fileinput-remove-button { display: none !important; }  /* no file yet -> no Remove */

/* ================================================================== *
 * Global admin polish: identifiable card shadow, rounded + striped
 * tables. Applies to every .box and every list table site-wide.
 * ================================================================== */

/* 1. Make the main card stand off the page background */
.box {
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.08),
              0 1px 3px rgba(16, 24, 40, 0.06) !important;
}

/* 2. Round the table itself (separate borders so the corners can clip) */
.box-body .table,
#table-content .table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  overflow: hidden !important;
}
/* table-bordered draws left/right cell borders that double up under
   separate-collapse; drop them, keep the horizontal row lines */
.box-body .table.table-bordered > thead > tr > th,
.box-body .table.table-bordered > tbody > tr > td,
#table-content .table.table-bordered > thead > tr > th,
#table-content .table.table-bordered > tbody > tr > td {
  border-left: none !important;
  border-right: none !important;
}
/* clip the four corners (header top, last row bottom) */
.box-body .table > thead > tr:first-child > th:first-child,
#table-content .table > thead > tr:first-child > th:first-child { border-top-left-radius: var(--r-lg) !important; }
.box-body .table > thead > tr:first-child > th:last-child,
#table-content .table > thead > tr:first-child > th:last-child { border-top-right-radius: var(--r-lg) !important; }
.box-body .table > tbody > tr:last-child > td:first-child,
#table-content .table > tbody > tr:last-child > td:first-child { border-bottom-left-radius: var(--r-lg) !important; }
.box-body .table > tbody > tr:last-child > td:last-child,
#table-content .table > tbody > tr:last-child > td:last-child { border-bottom-right-radius: var(--r-lg) !important; }

/* 3. Zebra striping (hover still wins) */
.box-body .table > tbody > tr:nth-child(even) > td,
#table-content .table > tbody > tr:nth-child(even) > td { background: #f6f8fb !important; }
.box-body .table > tbody > tr:nth-child(odd) > td,
#table-content .table > tbody > tr:nth-child(odd) > td { background: #ffffff !important; }
.box-body .table > tbody > tr:hover > td,
#table-content .table > tbody > tr:hover > td { background: var(--primary-light) !important; }

/* Previous Positions Expandable Arrow */
.prev-positions-toggle {
  transition: all 0.2s ease !important;
  font-family: inherit !important;
}
.prev-positions-toggle:hover {
  background: #e2e8f0 !important;
  border-color: #94a3b8 !important;
  color: #0f172a !important;
}
.prev-positions-toggle[aria-expanded="true"] .prev-pos-arrow,
.prev-positions-toggle.expanded .prev-pos-arrow {
  transform: rotate(90deg) !important;
}
.prev-pos-arrow {
  display: inline-block !important;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.prev-positions-drawer {
  transition: height 0.25s ease !important;
}
