@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-rgb: 79, 70, 229;
  --bg: #f8faff;
  --surface: #ffffff;
  --surface-card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0284c7;
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.03), 0 1px 2px rgba(15, 23, 42, 0.02);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.06), 0 4px 8px -2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 18px 38px -8px rgba(15, 23, 42, 0.1), 0 8px 16px -4px rgba(15, 23, 42, 0.04);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 9999px;
  --sidebar-w: 270px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* =========================================================
   SIDEBAR ARCHITECTURE (Desktop & Mobile Offcanvas)
   ========================================================= */
.sidebar,
.admin-sidebar,
.member-sidebar {
  width: var(--sidebar-w) !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  background: #0f172a;
  color: #fff;
  z-index: 1100 !important;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden !important;
}

.sidebar .brand,
.admin-sidebar-brand {
  flex: 0 0 auto !important;
  padding: 24px 20px 18px !important;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.brand-icon-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.brand-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #ffffff;
  margin: 0;
}

.brand-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(var(--primary-rgb), 0.25);
  color: #a5b4fc;
  margin-top: 3px;
}

.sidebar-scroll-container,
.admin-sidebar-nav,
.member-sidebar .sidebar-nav {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 18px 14px 4rem !important;
  display: flex !important;
  flex-direction: column !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-scroll-container::-webkit-scrollbar,
.admin-sidebar-nav::-webkit-scrollbar,
.member-sidebar .sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.sidebar-scroll-container::-webkit-scrollbar-thumb,
.admin-sidebar-nav::-webkit-scrollbar-thumb,
.member-sidebar .sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.38);
  margin: 18px 8px 8px;
}

.sidebar .nav-link,
.admin-sidebar .nav-link,
.member-sidebar .nav-link {
  display: flex !important;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.72) !important;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 14px !important;
  margin-bottom: 3px;
  border-radius: 12px !important;
  transition: all 0.2s ease;
  position: relative;
  text-decoration: none;
}

.sidebar .nav-link i,
.admin-sidebar .nav-link i,
.member-sidebar .nav-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  opacity: 0.85;
  transition: transform 0.2s ease;
}

.sidebar .nav-link:hover,
.admin-sidebar .nav-link:hover,
.member-sidebar .nav-link:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
  transform: translateX(3px);
}

.sidebar .nav-link:hover i,
.admin-sidebar .nav-link:hover i,
.member-sidebar .nav-link:hover i {
  opacity: 1;
  transform: scale(1.1);
}

.sidebar .nav-link.active,
.admin-sidebar .nav-link.active,
.member-sidebar .nav-link.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.32) !important;
  font-weight: 700;
}

.sidebar .nav-link.active i,
.admin-sidebar .nav-link.active i,
.member-sidebar .nav-link.active i {
  opacity: 1;
  color: #ffffff !important;
}

.sidebar .nav-badge,
.admin-sidebar .nav-badge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.sidebar-user-footer {
  flex: 0 0 auto !important;
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* =========================================================
   MAIN CONTENT & TOPBAR ARCHITECTURE
   ========================================================= */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 28px 36px 48px;
  min-height: 100vh;
  transition: all 0.28s ease;
}

.app-topbar {
  position: sticky;
  top: 14px;
  z-index: 1020;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  margin-bottom: 28px;
  transition: all 0.2s ease;
}

.topbar-role-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.03em;
}

.topbar-role-badge.badge-admin {
  background: #fdf2f8;
  color: #be185d;
  border: 1px solid #fbcfe8;
}

.topbar-role-badge.badge-member {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.topbar-date {
  font-size: 0.85rem;
  font-weight: 600;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  flex: 0 0 auto;
}

.topbar-user-pill {
  padding: 5px 12px 5px 6px;
  border-radius: var(--radius-pill);
  background: #ffffff;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  color: var(--text);
}

.topbar-user-pill:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.user-pill-name {
  font-size: 0.88rem;
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   PAGE HEADER & CARDS
   ========================================================= */
.page-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.card-modern,
.glass-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-modern:hover {
  box-shadow: var(--shadow-md);
}

/* Stat Cards */
.stat-card {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(var(--primary-rgb), 0.3);
}

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), rgba(var(--primary-rgb), 0.03));
  color: var(--primary);
  font-size: 1.35rem;
  border: 1px solid rgba(var(--primary-rgb), 0.15);
  box-shadow: 0 6px 14px rgba(var(--primary-rgb), 0.1);
}

.stat-card small.text-muted {
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  font-weight: 700;
  text-transform: uppercase;
}

/* Counter & Mask Toggle */
.dashboard-counter-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.dashboard-counter-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
}

.dashboard-counter-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary);
  border: 0;
  font-size: 0.85rem;
  transition: all 0.18s ease;
  cursor: pointer;
}

.dashboard-counter-toggle:hover {
  background: rgba(var(--primary-rgb), 0.18);
  transform: scale(1.08);
}

/* =========================================================
   MODERN BADGES
   ========================================================= */
.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  line-height: 1;
}

.badge-soft::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-soft.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.badge-soft.success::before {
  background: #10b981;
}

.badge-soft.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.badge-soft.warning::before {
  background: #f59e0b;
}

.badge-soft.danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.badge-soft.danger::before {
  background: #ef4444;
}

.badge-soft.info {
  background: #f0f9ff;
  color: #075985;
  border: 1px solid #bae6fd;
}
.badge-soft.info::before {
  background: #0284c7;
}

.badge-soft.secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}
.badge-soft.secondary::before {
  background: #64748b;
}

/* =========================================================
   TABLES & DATATABLES
   ========================================================= */
.table-modern {
  margin-bottom: 0;
  width: 100%;
}

.table-modern thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  padding: 14px 14px;
  font-weight: 700;
  white-space: nowrap;
}

.table-modern td {
  vertical-align: middle;
  padding: 15px 14px;
  border-color: #f1f5f9;
  font-size: 0.88rem;
}

.table-modern tbody tr {
  transition: background 0.15s ease;
}

.table-modern tbody tr:hover {
  background: #f8fafc;
}

.table-responsive {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #ffffff;
}

/* DataTables Styling */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 0.88rem;
  outline: none;
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 14px;
}

.dataTables_wrapper .pagination .page-link {
  border-radius: 10px;
  margin: 0 3px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  padding: 6px 12px;
}

.dataTables_wrapper .pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.3);
}

/* =========================================================
   BUTTONS & FORMS
   ========================================================= */
.btn {
  font-weight: 600;
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 0.88rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  border: none;
  color: #fff;
  box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.25);
}

.btn-primary:hover {
  filter: brightness(1.06);
  color: #fff;
  box-shadow: 0 8px 22px rgba(var(--primary-rgb), 0.35);
  transform: translateY(-1px);
}

.btn-soft {
  background: rgba(var(--primary-rgb), 0.09);
  color: var(--primary);
  border: 1px solid rgba(var(--primary-rgb), 0.15);
}

.btn-soft:hover {
  background: rgba(var(--primary-rgb), 0.16);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-icon:hover {
  background: #f8fafc;
  color: var(--primary);
  border-color: rgba(var(--primary-rgb), 0.3);
}

.form-control,
.form-select {
  border-radius: 12px;
  padding: 0.72rem 0.95rem;
  border: 1px solid #cbd5e1;
  font-size: 0.9rem;
  background-color: #ffffff;
  color: var(--text);
  transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.14);
  outline: none;
}

.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: #334155;
}

/* =========================================================
   MODALS
   ========================================================= */
.modal-content {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  background: #f8fafc;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: #f8fafc;
}

/* =========================================================
   MOBILE & RESPONSIVE BEHAVIOR
   ========================================================= */
.sidebar-toggle {
  display: none !important;
}

.topbar-menu-toggle {
  cursor: pointer;
}

.sidebar-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease;
}

.sidebar-close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

body.sidebar-open {
  overflow: hidden;
}

@media (min-width: 992px) {
  .sidebar-toggle,
  .sidebar-close,
  .sidebar-backdrop {
    display: none !important;
  }
}

@media (max-width: 991.98px) {
  .sidebar,
  .admin-sidebar,
  .member-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: min(84vw, 300px) !important;
    max-width: 300px !important;
    height: 100vh !important;
    height: 100dvh !important;
    transform: translateX(-105%) !important;
    z-index: 1200 !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35) !important;
  }

  body.sidebar-open .sidebar,
  body.sidebar-open .admin-sidebar,
  body.sidebar-open .member-sidebar {
    transform: translateX(0) !important;
  }

  body.sidebar-open .sidebar-backdrop {
    display: block !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 14px 14px calc(80px + env(safe-area-inset-bottom, 10px)) !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  body {
    padding-bottom: calc(75px + env(safe-area-inset-bottom, 10px));
  }

  .app-topbar {
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 20px;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* =========================================================
   NATIVE APP STYLE MOBILE BOTTOM NAVIGATION BAR
   ========================================================= */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 991.98px) {
  .mobile-bottom-nav {
    display: block !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1045 !important;
    background: rgba(255, 255, 255, 0.94) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border-top: 1px solid rgba(226, 232, 240, 0.9) !important;
    box-shadow: 0 -4px 25px rgba(15, 23, 42, 0.08) !important;
    padding-bottom: env(safe-area-inset-bottom, 4px);
  }

  .mobile-bottom-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 64px;
    max-width: 540px;
    margin: 0 auto;
    padding: 0 4px;
    position: relative;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    color: #64748b;
    text-decoration: none !important;
    background: transparent;
    border: none;
    padding: 4px 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    position: relative;
    cursor: pointer;
  }

  .mobile-nav-item:hover,
  .mobile-nav-item:focus {
    color: var(--primary);
  }

  .mobile-nav-item.active {
    color: var(--primary) !important;
  }

  .mobile-nav-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 28px;
    border-radius: 14px;
    font-size: 1.15rem;
    transition: all 0.22s ease;
  }

  .mobile-nav-item.active .mobile-nav-icon-wrap {
    background: rgba(var(--primary-rgb), 0.12);
    transform: translateY(-2px);
  }

  .mobile-nav-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1;
    transition: color 0.2s ease;
  }

  .mobile-nav-item.active .mobile-nav-label {
    font-weight: 700;
  }

  .mobile-nav-center-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
  }

  .mobile-nav-fab {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), rgba(var(--primary-rgb), 0.85));
    color: #ffffff !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border: 3px solid #ffffff;
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), 0.42);
    margin-top: -26px;
    margin-bottom: 2px;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    text-decoration: none !important;
  }

  .mobile-nav-fab:hover,
  .mobile-nav-fab:active {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 24px rgba(var(--primary-rgb), 0.55);
  }

  .mobile-nav-center-wrap .mobile-nav-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary);
  }

  .mobile-nav-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    line-height: 17px;
    text-align: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  }
}

