@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800&display=swap');

:root {
  --bg: #f8fafc;
  /* พื้นหลังนวล */
  --surface: #ffffff;
  /* พื้นผิวหลัก */
  --text: #1f2937;
  /* ตัวอักษรเข้ม อ่านสบาย */
  --muted: #6b7280;
  /* ตัวอักษรรอง */
  --border: #e5e7eb;
  /* เส้นแบ่งบางๆ */
  --accent: #6C63FF;
  /* อินดิโก้-ม่วง นุ่มทันสมัย */
  --accent-weak: #EEF2FF;
  /* เฉดอ่อนของ accent */
  --shadow: 0 10px 30px rgba(0, 0, 0, .06);
  --radius: 14px;
  --radius-sm: 10px;
  --t: 240ms cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Base
   -------------------------------------------------- */
html,
body {
  height: 100%;
}

body {
  font-family: 'Sarabun', sans-serif !important;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

p {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
}

a,
a:hover,
a:focus {
  color: inherit;
  text-decoration: none;
  transition: color var(--t), background-color var(--t), border-color var(--t), transform var(--t), box-shadow var(--t);
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid rgba(108, 99, 255, .35);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Navbar
   -------------------------------------------------- */
.navbar {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin: 0 0 22px 0;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.navbar-btn {
  box-shadow: none;
  outline: none !important;
  border: none;
}

.navbar-collapse a {
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 9999px;
  padding: .45rem .85rem;
  font-weight: 600;
}

.navbar-collapse a:hover {
  background: var(--accent-weak);
  border-color: var(--accent-weak);
  color: #6C63FF;
  transform: translateY(-1px);
}

.navbar-nav>.active>a {
  color: #fff;
  background: #6C63FF;
  border-color: #6C63FF;
  border-radius: 9999px;
  padding: .45rem .85rem;
  box-shadow: 0 6px 18px rgba(108, 99, 255, .25);
}

/* Wrapper
   -------------------------------------------------- */
.wrapper {
  display: flex;
  align-items: stretch;
}

/* Sidebar
   -------------------------------------------------- */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  width: 300px;
  min-width: 255px;
  max-width: 300px;
  background: var(--surface);
  color: var(--text);
  border-right: 1px solid var(--border);
  transition: width var(--t), transform var(--t), box-shadow var(--t), background-color var(--t);
  will-change: width, transform;
  scrollbar-gutter: stable both-edges;
}

#sidebar::-webkit-scrollbar {
  width: 8px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: #e6e8ee;
  border-radius: 9999px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: #d9dbe3;
}

#sidebar.active {
  min-width: 200px;
  max-width: 200px;
}

#sidebar .sidebar-header {
  padding: 18px 18px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

#sidebar .sidebar-header h3,
#sidebar .sidebar-header h5,
#sidebar .sidebar-header h6 {
  color: var(--text);
  margin: 0;
}

#sidebar .sidebar-header strong {
  display: none;
  font-size: 1.3rem;
  color: #6C63FF;
}

/* กลุ่มเมนู */
#sidebar ul.components {
  padding: 10px 12px 18px;
  border-bottom: 0;
}

#sidebar ul li {
  list-style: none;
}

#sidebar ul li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: .75rem .9rem;
  font-size: 1rem;
  color: var(--muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
  position: relative;
  /* แถบซ้ายเล็ก ๆ ตอนโฟกัส/โฮเวอร์ */
}

#sidebar ul li a::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 60%;
  background: #6C63FF;
  border-radius: 2px;
  transition: width var(--t);
  opacity: .12;
}

#sidebar ul li a:hover {
  background: var(--accent-weak);
  color: #6C63FF;
  transform: translateX(4px);
}

#sidebar ul li a:hover::before {
  width: 3px;
}

#sidebar ul li a i {
  margin-right: 0;
  font-size: 1.05em;
}

#sidebar ul li.active>a {
  color: #fff;
  background: #6C63FF;
  box-shadow: 0 10px 22px rgba(108, 99, 255, .28);
}

#sidebar ul li.active>a::before {
  width: 0;
}

#sidebar a[aria-expanded="true"] {
  color: #6C63FF;
  background: #fff;
}

/* Dropdown / Submenu */
a[data-toggle="collapse"] {
  position: relative;
}

.dropdown-toggle::after {
  display: block;
  content: "";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-50%) rotate(-45deg);
  transition: transform var(--t);
  opacity: .7;
}

[aria-expanded="true"].dropdown-toggle::after {
  transform: translateY(-50%) rotate(45deg);
}

ul ul a {
  font-size: .95em !important;
  padding: .6rem .75rem .6rem 34px !important;
  background: transparent;
  border-left: 2px solid var(--accent-weak);
  margin-left: 8px;
  border-radius: 8px;
}

/* CTA (ถ้ามี) */
ul.CTAs {
  padding: 16px;
}

ul.CTAs a {
  text-align: left;
  font-size: .95em !important;
  display: block;
  border-radius: 10px;
  margin-bottom: 6px;
}

a.download {
  background: #fff;
  color: #6C63FF;
}

a.article,
a.article:hover {
  background: #6C63FF !important;
  color: #fff !important;
}

/* Content
   -------------------------------------------------- */
#content {
  background: var(--surface);
  width: calc(100% - 300px);
  min-height: 100vh;
  position: absolute;
  top: 0;
  right: 0;
  padding: 24px;
  transition: width var(--t), padding var(--t);
  border-left: 0;
  box-shadow: none;
  border-radius: 0;
}

#content.active {
  width: calc(100% - 200px);
}

#content.active h6 {
  display: block;
  color: #fff;
  background: #6C63FF;
  border: 10px solid #6C63FF;
  border-radius: 12px;
  font-weight: 700;
}

/* เส้นแบ่ง/องค์ประกอบเสริม */
.line {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  border: 0;
  margin: 32px 0;
}

/* ปุ่มขึ้นบนสุด */
#myBtn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 24px;
  z-index: 99;
  font-size: 14px;
  border: none;
  outline: none;
  background-color: #6C63FF;
  color: white;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 9999px;
  opacity: 0.95;
  box-shadow: 0 10px 22px rgba(108, 99, 255, .28);
  transition: transform var(--t), box-shadow var(--t), opacity var(--t);
}

#myBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(108, 99, 255, .34);
  opacity: 1;
}

/* Footer & small text */
#footer {
  position: relative;
  bottom: 0;
  font-size: 13px;
  text-align: center;
  color: var(--muted);
  z-index: 0;
}

/* Toggle Button (ซ่อนบนเดสก์ท็อป, โชว์บนจอเล็ก)
   -------------------------------------------------- */
#sidebarCollapse {
  display: none !important;
}

@media (max-width:768px) {
  #sidebarCollapse {
    display: inline-block !important;
  }

  .sidebar-header .row {
    display: none;
  }
}

/* ตัวเลขผลรวม */
#numAnsResult {
  font-size: 15px;
}

/* Responsive
   -------------------------------------------------- */
@media (max-width: 768px) {
  #content {
    width: 100%;
    min-height: 100vh;
    padding: 20px;
    position: absolute;
    top: 0;
    right: 0;
  }

  #sidebar {
    width: 115px;
    min-width: 115px;
    max-width: 115px;
    transform: translateX(-115px);
    text-align: left;
    box-shadow: none;
  }

  #sidebar.active {
    transform: translateX(0);
  }

  #sidebar .sidebar-header h3,
  #sidebar .sidebar-header h5,
  #sidebar .sidebar-header h6,
  #sidebar .CTAs {
    display: none;
  }

  #sidebar .sidebar-header strong {
    display: block;
  }

  #sidebar ul li a {
    padding: 20px 10px;
    justify-content: left;
  }

  #sidebar ul li a span {
    font-size: .85em;
  }

  #sidebar ul li a i {
    display: block;
    font-size: 1.25em;
  }

  #sidebar ul ul a {
    padding: 10px !important;
  }

  .dropdown-toggle::after {
    top: auto;
    bottom: 10px;
    right: 50%;
    transform: translateX(50%) rotate(-45deg);
  }
}

/* Extra polish: active/hover elevation for cards/boxes inside #content */
#content .card,
#content .panel,
#content .box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: box-shadow var(--t), transform var(--t), border-color var(--t);
}

#content .card:hover,
#content .panel:hover,
#content .box:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: #e0e3ea;
}


/* ========== Minimal White, ชัด & ทันสมัย ========== */
:root {
  --brand-bg: #ffffff;
  --brand-title: #0f172a;
  /* เกือบดำ อ่านชัด */
  --brand-sub: #64748b;
  /* slate-500 อ่อนกว่าให้ต่างชั้น */
  --brand-border: rgba(0, 0, 0, .06);
  --brand-border-hover: rgba(0, 0, 0, .12);
  --brand-ring: #e5e7eb;
  /* โฟกัสเค้าโครง */
}

/* การ์ดขาวบนพื้นขาวให้เด้งขึ้นแบบมืออาชีพ */
.brand-card {
  background: var(--brand-bg);
  padding: .75rem 1rem;
}

.brand-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--brand-ring);
}

/* โลโก้ “ไม่เล็กเกินไป” ปรับตามหน้าจออัตโนมัติ */
.brand-logo {
  display: block;
  width: clamp(52px, 6vw, 100px);
  height: clamp(52px, 6vw, 90px);
  border-radius: 12px;
  background: #fff;
}

/* ไทโปใหญ่ขึ้น ชัดขึ้น และต่างระดับกันชัดเจน */
.brand-title {
  color: var(--brand-title);
  font-weight: 700;
  font-size: clamp(1.25rem, 2.4vw, 1.5rem);
  /* 20–24px */
  line-height: 1.15;
  letter-spacing: .2px;
}

.brand-subtitle {
  color: var(--brand-sub);
  font-weight: 500;
  font-size: clamp(.95rem, 1.2vw, 1.05rem);
  /* 15–17px */
  line-height: 1.25;
  margin-top: .15rem;
  letter-spacing: .15px;
}

/* เลย์เอาต์แน่นขึ้นบนจอเล็ก */
@media (max-width: 576px) {
  .brand-card {
    padding: .6rem .8rem;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
  }
}


/* ========== Sidebar Brand (Modern, Animated, Minimal White) ========== */

/* Keyframe Animations */
@keyframes brandPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 12px rgba(108, 99, 255, 0.15); }
  50% { transform: scale(1.02); box-shadow: 0 8px 24px rgba(108, 99, 255, 0.25); }
}

@keyframes brandGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0); }
  50% { box-shadow: 0 0 20px 4px rgba(108, 99, 255, 0.2); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes floatUp {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand-header {
  --gap: 14px;
  --logo: 54px;
  --title: 1rem;
  --overline: 0.875rem;
  
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(108, 99, 255, 0.08);
  background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.95) 100%);
  position: relative;
  overflow: hidden;
  transition: background 0.3s ease, border-color 0.3s ease;
}

/* Subtle gradient overlay for depth */
.brand-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(108,99,255,0.02) 0%, transparent 60%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.brand-header:hover::before {
  opacity: 1;
}

/* Logo Link Container */
.brand-logo-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 16px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand-logo-link:hover {
  transform: scale(1.05);
}

.brand-logo-link:active {
  transform: scale(0.98);
}

/* Logo Image */
.brand-logo {
  width: var(--logo);
  height: var(--logo);
  border-radius: 14px;
  object-fit: contain;
  display: block;
  background: white;
  box-shadow: 
    0 4px 12px rgba(108, 99, 255, 0.12),
    0 1px 3px rgba(0, 0, 0, 0.06),
    inset 0 0 0 1px rgba(108, 99, 255, 0.08);
  transition: 
    box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    filter 0.3s ease;
}

.brand-logo-link:hover .brand-logo {
  box-shadow: 
    0 8px 24px rgba(108, 99, 255, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.08),
    inset 0 0 0 1px rgba(108, 99, 255, 0.15);
  animation: brandGlow 2s ease-in-out infinite;
}

.brand-logo-link:focus-visible .brand-logo {
  outline: 2px solid #6C63FF;
  outline-offset: 3px;
}

/* Brand Text Container */
.brand-text {
  flex: 1;
  min-width: 0;
  line-height: 1.2;
  animation: fadeSlideIn 0.5s ease-out;
  transition: transform 0.3s ease;
}

.brand-header:hover .brand-text {
  animation: floatUp 3s ease-in-out infinite;
}

/* Brand Overline (Subtitle) */
.brand-overline {
  font-weight: 500;
  font-size: var(--overline);
  color: #64748b;
  margin: 0 0 3px 0;
  letter-spacing: 0.02em;
  opacity: 0.9;
  transition: color 0.3s ease, opacity 0.3s ease;
}

.brand-header:hover .brand-overline {
  color: #6C63FF;
  opacity: 1;
}

/* Brand Title Container */
.brand-title {
  font-weight: 700;
  font-size: var(--title);
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.3;
}

/* Primary Title Part (NCD Clinic) */
.brand-title-primary {
  color: #1e293b;
  transition: all 0.3s ease;
  position: relative;
}

.brand-header:hover .brand-title-primary {
  color: #6C63FF;
}

/* Secondary Title Part (Plus Online) */
.brand-title-secondary {
  color: #6C63FF;
  font-weight: 600;
  background: #000000;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  transition: all 0.3s ease;
}


/* Compact Logo (Collapsed Mode) */
.brand-compact {
  display: none;
  position: relative;
  border-radius: 12px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand-compact:hover {
  transform: scale(1.08) rotate(3deg);
}

.brand-compact:active {
  transform: scale(0.95);
}

.brand-compact .brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

/* Collapsed Sidebar Mode */
#sidebar.is-collapsed .brand-text,
#sidebar.is-collapsed .brand-logo-link {
  opacity: 0;
  visibility: hidden;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease, width 0.3s ease;
}

#sidebar.is-collapsed .brand-compact {
  display: flex;
  justify-content: center;
  margin: 0 auto;
}

#sidebar.is-collapsed .brand-header {
  justify-content: center;
  padding: 14px 10px;
}

/* Expand on hover when collapsed */
#sidebar.is-collapsed:hover .brand-text,
#sidebar.is-collapsed:hover .brand-logo-link {
  opacity: 1;
  visibility: visible;
  width: auto;
}

#sidebar.is-collapsed:hover .brand-compact {
  display: none;
}

#sidebar.is-collapsed:hover .brand-header {
  justify-content: flex-start;
  padding: 16px 16px 14px;
}

/* Large Screen Optimizations */
@media (min-width: 1200px) {
  .brand-header {
    --logo: 60px;
    --title: 1.125rem;
    --overline: 0.9375rem;
    padding: 18px 18px 16px;
  }
}

/* Dark mode for brand header removed - keeping light theme only */

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .brand-logo,
  .brand-logo-link,
  .brand-text,
  .brand-compact,
  .brand-title-primary,
  .brand-title-secondary,
  .brand-title-secondary::after,
  .brand-header::before {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   SIDEBAR UPGRADE - Modern Minimal White Theme
   ============================================================ */

/* --- Design Tokens (Sidebar Specific) --- */
:root {
  /* Sidebar dimensions */
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 72px;
  --sidebar-mobile-width: 280px;
  
  /* Colors */
  --sidebar-bg: #ffffff;
  --sidebar-border: #e5e7eb;
  --sidebar-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --sidebar-shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.10);
  
  /* Nav item colors */
  --nav-text: #64748b;
  --nav-text-hover: #6C63FF;
  --nav-bg-hover: rgba(108, 99, 255, 0.06);
  --nav-bg-active: #6C63FF;
  --nav-text-active: #ffffff;
  --nav-indicator: #6C63FF;
  
  /* Transitions */
  --sidebar-transition: 280ms cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-fast: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Base Sidebar Upgrade --- */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: var(--sidebar-shadow);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width var(--sidebar-transition),
              min-width var(--sidebar-transition),
              max-width var(--sidebar-transition),
              transform var(--sidebar-transition),
              box-shadow var(--sidebar-transition);
}

/* --- Collapsed State (Desktop Icon-Only) --- */
#sidebar.is-collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
  max-width: var(--sidebar-collapsed-width);
}

#sidebar.is-collapsed .sidebar-header .brand-text,
#sidebar.is-collapsed .sidebar-header .brand-logo-link {
  opacity: 0;
  visibility: hidden;
  width: 0;
  overflow: hidden;
}

#sidebar.is-collapsed .sidebar-header .brand-compact {
  display: flex;
  justify-content: center;
}

#sidebar.is-collapsed .sidebar-header {
  justify-content: center;
  padding: 12px 8px;
  --gap: 14;
  height: 124px;
}

#sidebar.is-collapsed ul.components {
  padding: 10px 8px;
}

#sidebar.is-collapsed ul li a {
  justify-content: center;
  padding: 14px 8px;
  flex-direction: column;
  gap: 4px;
}

#sidebar.is-collapsed ul li a span,
#sidebar.is-collapsed ul li a .nav-label {
  display: none;
}

#sidebar.is-collapsed ul li a i {
  font-size: 1.25em;
  margin: 0;
}

/* Hide submenus in collapsed */
#sidebar.is-collapsed ul ul {
  display: none !important;
}

#sidebar.is-collapsed .sidebar-search,
#sidebar.is-collapsed .sidebar-section-title {
  display: none;
}

#sidebar.is-collapsed .dropdown-toggle::after {
  display: none;
}

/* Expand on hover (collapsed) */
#sidebar.is-collapsed:hover {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  box-shadow: var(--sidebar-shadow-elevated);
}

#sidebar.is-collapsed:hover .brand-text,
#sidebar.is-collapsed:hover .brand-logo-link {
  opacity: 1;
  visibility: visible;
  width: auto;
}

#sidebar.is-collapsed:hover .brand-compact {
  display: none;
}

#sidebar.is-collapsed:hover .sidebar-header {
  justify-content: flex-start;
  padding: 12px 14px;
}

#sidebar.is-collapsed:hover ul.components {
  padding: 10px 12px 18px;
}

#sidebar.is-collapsed:hover ul li a {
  justify-content: flex-start;
  padding: .75rem .9rem;
  flex-direction: row;
  gap: 12px;
}

#sidebar.is-collapsed:hover ul li a span,
#sidebar.is-collapsed:hover ul li a .nav-label {
  display: inline;
}

#sidebar.is-collapsed:hover ul li a i {
  font-size: 1.05em;
}

#sidebar.is-collapsed:hover .sidebar-search,
#sidebar.is-collapsed:hover .sidebar-section-title {
  display: block;
}

#sidebar.is-collapsed:hover .dropdown-toggle::after {
  display: block;
}

/* Content adjustment for collapsed sidebar */
#content {
  width: calc(100% - var(--sidebar-width));
  transition: width var(--sidebar-transition), margin-left var(--sidebar-transition);
}

body.sidebar-collapsed #content {
  width: calc(100% - var(--sidebar-collapsed-width));
}

/* --- Sidebar Header Improvements --- */
#sidebar .sidebar-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
  flex-shrink: 0;
}

#sidebar .sidebar-header .brand-logo {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform var(--sidebar-fast), box-shadow var(--sidebar-fast);
}

#sidebar .sidebar-header .brand-logo:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* --- Sidebar Search Box --- */
.sidebar-search {
  padding: 12px 14px 8px;
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--sidebar-border);
  border-radius: 10px;
  font-size: 0.9rem;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 12px center;
  transition: border-color var(--sidebar-fast), box-shadow var(--sidebar-fast), background-color var(--sidebar-fast);
  color: var(--text);
}

.sidebar-search input:focus {
  outline: none;
  border-color: #6C63FF;
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
  background-color: #fff;
}

.sidebar-search input::placeholder {
  color: #94a3b8;
}

/* --- Nav Items Enhanced --- */
#sidebar ul.components {
  padding: 8px 12px 16px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar ul li {
  margin-bottom: 2px;
}

#sidebar ul li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--nav-text);
  border-radius: 10px;
  text-decoration: none;
  position: relative;
  transition: background-color var(--sidebar-fast),
              color var(--sidebar-fast),
              transform var(--sidebar-fast),
              box-shadow var(--sidebar-fast);
}

#sidebar ul li a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--nav-indicator);
  border-radius: 0 3px 3px 0;
  transition: height var(--sidebar-fast);
}

#sidebar ul li a:hover {
  background: var(--nav-bg-hover);
  color: var(--nav-text-hover);
  transform: translateX(2px);
}

#sidebar ul li a:hover::before {
  height: 50%;
}

#sidebar ul li a i {
  width: 20px;
  text-align: center;
  font-size: 1.1em;
  flex-shrink: 0;
  transition: transform var(--sidebar-fast);
}

#sidebar ul li a:hover i {
  transform: scale(1.1);
}

/* Active state */
#sidebar ul li.active > a,
#sidebar ul li a.active {
  background: var(--nav-bg-active);
  color: var(--nav-text-active);
  box-shadow: 0 4px 14px rgba(108, 99, 255, 0.3);
  font-weight: 600;
}

#sidebar ul li.active > a::before,
#sidebar ul li a.active::before {
  height: 0;
}

#sidebar ul li.active > a:hover,
#sidebar ul li a.active:hover {
  transform: translateX(0);
  box-shadow: 0 6px 18px rgba(108, 99, 255, 0.35);
}

/* Focus visible for accessibility */
#sidebar ul li a:focus-visible {
  outline: 2px solid #6C63FF;
  outline-offset: 2px;
  border-radius: 10px;
}

/* --- Submenus / Accordion --- */
#sidebar ul ul {
  padding-left: 0;
  margin-left: 18px;
  border-left: 2px solid var(--accent-weak);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height var(--sidebar-transition),
              opacity var(--sidebar-transition),
              padding var(--sidebar-transition);
}

#sidebar ul ul.show,
#sidebar ul ul.collapse.show {
  max-height: 500px;
  opacity: 1;
  padding: 6px 0;
}

#sidebar ul ul li a {
  padding: 9px 14px 9px 16px;
  font-size: 0.9rem;
  font-weight: 400;
  border-radius: 8px;
}

#sidebar ul ul li a::before {
  left: -18px;
}

/* Dropdown toggle chevron */
#sidebar .dropdown-toggle::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-50%) rotate(-45deg);
  transition: transform var(--sidebar-fast);
  opacity: 0.6;
}

#sidebar [aria-expanded="true"].dropdown-toggle::after {
  transform: translateY(-50%) rotate(45deg);
}

/* --- Section Dividers & Titles --- */
.sidebar-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, var(--sidebar-border) 50%, transparent 95%);
  margin: 12px 0;
  border: none;
}

.sidebar-section-title {
  padding: 16px 14px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  pointer-events: none;
}

/* --- User Profile Card --- */
.sidebar-user-card {
  padding: 14px;
  border-top: 1px solid var(--sidebar-border);
  background: #f8fafc;
  flex-shrink: 0;
  margin-top: auto;
}

.sidebar-user-card .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--sidebar-border);
  cursor: pointer;
  transition: border-color var(--sidebar-fast), box-shadow var(--sidebar-fast);
}

.sidebar-user-card .user-info:hover {
  border-color: #d1d5db;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.sidebar-user-card .user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--accent-weak);
  flex-shrink: 0;
}

.sidebar-user-card .user-details {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sidebar-user-card .user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.3;
}

.sidebar-user-card .user-role {
  font-size: 0.75rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.sidebar-user-card .user-dropdown-icon {
  color: #94a3b8;
  font-size: 0.75rem;
  transition: transform var(--sidebar-fast);
}

.sidebar-user-card .user-info[aria-expanded="true"] .user-dropdown-icon {
  transform: rotate(180deg);
}

/* User dropdown menu */
.sidebar-user-card .user-dropdown {
  margin-top: 8px;
  background: #fff;
  border: 1px solid var(--sidebar-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  max-height: 0;
  opacity: 0;
  transition: max-height var(--sidebar-transition), opacity var(--sidebar-transition);
}

.sidebar-user-card .user-dropdown.show {
  max-height: 200px;
  opacity: 1;
}

.sidebar-user-card .user-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--nav-text);
  text-decoration: none;
  transition: background-color var(--sidebar-fast), color var(--sidebar-fast);
}

.sidebar-user-card .user-dropdown a:hover {
  background: var(--nav-bg-hover);
  color: var(--nav-text-hover);
}

.sidebar-user-card .user-dropdown a i {
  width: 18px;
  text-align: center;
}

.sidebar-user-card .user-dropdown .logout-link {
  border-top: 1px solid var(--sidebar-border);
  color: #ef4444;
}

.sidebar-user-card .user-dropdown .logout-link:hover {
  background: #fef2f2;
  color: #dc2626;
}

/* Collapsed user card */
#sidebar.is-collapsed .sidebar-user-card .user-details,
#sidebar.is-collapsed .sidebar-user-card .user-dropdown-icon {
  display: none;
}

#sidebar.is-collapsed .sidebar-user-card .user-info {
  justify-content: center;
  padding: 8px;
}

#sidebar.is-collapsed .sidebar-user-card .user-dropdown {
  display: none;
}

#sidebar.is-collapsed:hover .sidebar-user-card .user-details,
#sidebar.is-collapsed:hover .sidebar-user-card .user-dropdown-icon {
  display: block;
}

#sidebar.is-collapsed:hover .sidebar-user-card .user-info {
  justify-content: flex-start;
  padding: 10px 12px;
}

#sidebar.is-collapsed:hover .sidebar-user-card .user-dropdown {
  display: block;
}

/* --- Tooltips (Collapsed Mode) --- */
#sidebar.is-collapsed ul li a[data-tooltip] {
  position: relative;
}

#sidebar.is-collapsed ul li a[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  background: #1f2937;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1050;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: opacity var(--sidebar-fast), transform var(--sidebar-fast), visibility var(--sidebar-fast);
}

#sidebar.is-collapsed ul li a[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) scale(1);
}

/* Don't show tooltips when sidebar is expanded on hover */
#sidebar.is-collapsed:hover ul li a[data-tooltip]::after {
  opacity: 0;
  visibility: hidden;
}

/* --- Mobile Drawer Mode --- */
@media (max-width: 991px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-mobile-width);
    min-width: var(--sidebar-mobile-width);
    max-width: var(--sidebar-mobile-width);
    transform: translateX(-100%);
    z-index: 1050;
    box-shadow: none;
  }

  #sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--sidebar-shadow-elevated);
  }

  /* Content full width on mobile */
  #content {
    width: 100%;
    margin-left: 0;
  }

  body.sidebar-collapsed #content {
    width: 100%;
  }

  /* Sidebar backdrop overlay */
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1045;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--sidebar-transition), visibility var(--sidebar-transition);
    backdrop-filter: blur(2px);
  }

  .sidebar-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
  }

  /* Mobile hamburger improvements */
  #sidebarCollapse {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 10px;
    background: #f1f5f9;
    border: 1px solid var(--sidebar-border);
    color: var(--text);
    transition: background-color var(--sidebar-fast), border-color var(--sidebar-fast), transform var(--sidebar-fast);
  }

  #sidebarCollapse:hover {
    background: #e2e8f0;
    border-color: #d1d5db;
    transform: scale(1.02);
  }

  #sidebarCollapse:focus-visible {
    outline: 2px solid #6C63FF;
    outline-offset: 2px;
  }

  #sidebarCollapse i {
    font-size: 1.1rem;
  }

  /* Hide collapsed mode features on mobile */
  #sidebar.is-collapsed {
    width: var(--sidebar-mobile-width);
    min-width: var(--sidebar-mobile-width);
    max-width: var(--sidebar-mobile-width);
  }

  #sidebar.is-collapsed .brand-text,
  #sidebar.is-collapsed .brand-logo-link {
    opacity: 1;
    visibility: visible;
    width: auto;
  }

  #sidebar.is-collapsed ul li a span,
  #sidebar.is-collapsed ul li a .nav-label {
    display: inline;
  }
}

/* --- Desktop Toggle Button --- */
@media (min-width: 992px) {
  #sidebarCollapse {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--sidebar-border);
    color: var(--text);
    transition: background-color var(--sidebar-fast), border-color var(--sidebar-fast), transform var(--sidebar-fast);
  }

  #sidebarCollapse:hover {
    background: #f1f5f9;
    border-color: #d1d5db;
  }

  #sidebarCollapse:focus-visible {
    outline: 2px solid #6C63FF;
    outline-offset: 2px;
  }

  #sidebarCollapse i {
    transition: transform var(--sidebar-transition);
  }

  body.sidebar-collapsed #sidebarCollapse i {
    transform: rotate(180deg);
  }
}

/* --- Filter Hidden State (for search) --- */
#sidebar ul li.filter-hidden {
  display: none !important;
}

/* --- Prefers Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  #sidebar,
  #sidebar *,
  #content,
  .sidebar-backdrop {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* --- Scrollbar styling (already exists but enhance) --- */
#sidebar::-webkit-scrollbar {
  width: 6px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 10px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}

/* --- Fix legacy .active toggle class conflict --- */
#sidebar.active {
  /* Override legacy behavior for mobile - use is-open instead */
  transform: translateX(0);
}

@media (min-width: 992px) {
  #sidebar.active {
    /* On desktop, .active was used for partial collapse - now use is-collapsed */
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
  }
}

/* ========================================================================
   BRAND CARD MODERN - Minimal White & Purple
   ======================================================================== */

.brand-card-modern {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 12px;
  text-decoration: none;
  transition: opacity 0.3s ease;
}

.brand-card-modern:hover {
  opacity: 0.85;
}

.brand-card-modern:focus-visible {
  outline: 2px solid #6C63FF;
  outline-offset: 2px;
}

/* Logo */
.brand-logo-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo-img {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
  border: 2px solid rgba(108, 99, 255, 0.15);
  transition: border-color 0.3s ease, transform 0.3s ease;
}

.brand-logo-ring {
  display: none;
}

.brand-card-modern:hover .brand-logo-img {
  border-color: #6C63FF;
  transform: scale(1.02);
}

/* Text */
.brand-text-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.brand-overline-modern {
  font-size: 0.8rem;
  font-weight: 500;
  color: #6C63FF;
  letter-spacing: 0.01em;
}

/* Brand Name - All Purple */
.brand-name-modern {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.25;
  color: #6C63FF;
}

.brand-ncd {
  color: #6C63FF;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-clinic {
  color: #6C63FF;
  font-weight: 700;
}

.brand-plus {
  color: #6C63FF;
  font-weight: 700;
}

.brand-online {
  color: #8B82FF;
  font-weight: 500;
  font-size: 0.9em;
}

/* Arrow - Hidden for minimal look */
.brand-arrow {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .brand-card-modern {
    gap: 10px;
    padding: 6px 8px;
  }
  
  .brand-logo-img {
    width: 48px;
    height: 48px;
    border-radius: 10px;
  }
  
  .brand-overline-modern {
    font-size: 0.7rem;
  }
  
  .brand-name-modern {
    font-size: 1rem;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .brand-card-modern {
    gap: 8px;
    padding: 4px 6px;
  }
  
  .brand-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
  }
  
  .brand-name-modern {
    font-size: 0.9rem;
    gap: 3px;
  }
  
  .brand-online {
    display: none;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .brand-card-modern,
  .brand-logo-img {
    transition: none !important;
  }
}

/* ============================================================
   TOP MENU / NAVBAR - Modern Minimal White & Purple Theme
   ============================================================ */

/* --- Design Tokens for Navbar --- */
:root {
  --navbar-bg: rgba(255, 255, 255, 0.92);
  --navbar-bg-solid: #ffffff;
  --navbar-border: rgba(108, 99, 255, 0.08);
  --navbar-shadow: 0 4px 24px rgba(108, 99, 255, 0.06);
  --navbar-shadow-scrolled: 0 8px 32px rgba(108, 99, 255, 0.12);
  --navbar-radius: 16px;
  
  --nav-link-color: #475569;
  --nav-link-hover-color: #6C63FF;
  --nav-link-hover-bg: rgba(108, 99, 255, 0.06);
  --nav-link-active-bg: linear-gradient(135deg, #6C63FF 0%, #8B82FF 100%);
  --nav-link-active-shadow: 0 4px 16px rgba(108, 99, 255, 0.35);
  
  --btn-login-gradient: linear-gradient(135deg, #6C63FF 0%, #8B82FF 100%);
  --btn-logout-gradient: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  
  --navbar-transition: 280ms cubic-bezier(0.4, 0, 0.2, 1);
  --navbar-fast: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Base Navbar Styles --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  padding: 12px 20px;
  background: var(--navbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--navbar-border);
  border-radius: var(--navbar-radius);
  margin: 12px 12px 20px 12px;
  box-shadow: var(--navbar-shadow);
  transition: background var(--navbar-transition),
              box-shadow var(--navbar-transition),
              border-color var(--navbar-transition),
              transform var(--navbar-transition);
}

/* Scrolled state - more solid */
.navbar.is-scrolled {
  background: var(--navbar-bg-solid);
  box-shadow: var(--navbar-shadow-scrolled);
  border-color: rgba(108, 99, 255, 0.12);
}

/* Subtle gradient line at bottom */
.navbar::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #6C63FF, transparent);
  border-radius: 2px;
  transition: width var(--navbar-transition);
}

.navbar:hover::after {
  width: 60%;
}

/* --- Navigation Links Container --- */
.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- Navigation Link Items --- */
.navbar-nav .nav-item {
  position: relative;
}

.navbar-nav .nav-link {
  position: relative;
  display: flex;
  align-items: center;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--nav-link-color);
  text-decoration: none;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: transparent;
  transition: color var(--navbar-fast),
              background-color var(--navbar-fast),
              border-color var(--navbar-fast),
              transform var(--navbar-fast),
              box-shadow var(--navbar-fast);
  overflow: hidden;
}

/* Hover effect with subtle background */
.navbar-nav .nav-link:hover {
  color: var(--nav-link-hover-color);
  background: var(--nav-link-hover-bg);
  border-color: rgba(108, 99, 255, 0.1);
  transform: translateY(-1px);
}

/* Animated underline on hover */
.navbar-nav .nav-link::before {
  content: "";
  position: absolute;
  bottom: 6px;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #6C63FF, #8B82FF);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: width var(--navbar-fast);
}

.navbar-nav .nav-link:hover::before {
  width: calc(100% - 28px);
}

/* Active state - Purple pill */
.navbar-nav > .nav-item.active > .nav-link,
.navbar-nav .nav-link.active {
  color: #ffffff;
  background: var(--nav-link-active-bg);
  border-color: transparent;
  box-shadow: var(--nav-link-active-shadow);
  font-weight: 600;
}

.navbar-nav > .nav-item.active > .nav-link::before,
.navbar-nav .nav-link.active::before {
  display: none;
}

.navbar-nav > .nav-item.active > .nav-link:hover,
.navbar-nav .nav-link.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
}

/* Focus visible for accessibility */
.navbar-nav .nav-link:focus-visible {
  outline: 2px solid #6C63FF;
  outline-offset: 2px;
}

/* --- Navbar Buttons (Login/Logout) --- */
.navbar .btn {
  position: relative;
  padding: 10px 22px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  transition: transform var(--navbar-fast),
              box-shadow var(--navbar-fast),
              filter var(--navbar-fast);
  overflow: hidden;
}

/* Login Button - Purple Gradient */
.navbar .btn-success {
  background: var(--btn-login-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(108, 99, 255, 0.3);
}

.navbar .btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
  filter: brightness(1.05);
}

.navbar .btn-success:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

/* Subtle pulse animation for CTA */
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(108, 99, 255, 0.3); }
  50% { box-shadow: 0 4px 20px rgba(108, 99, 255, 0.5); }
}

.navbar .btn-success {
  animation: btnPulse 3s ease-in-out infinite;
}

.navbar .btn-success:hover {
  animation: none;
}

/* Logout Button - Orange/Warning Gradient */
.navbar .btn-warning {
  background: var(--btn-logout-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.navbar .btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
  filter: brightness(1.05);
}

.navbar .btn-warning:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* Button focus */
.navbar .btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* --- Sidebar Toggle Button Enhancement --- */
#sidebarCollapse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(108, 99, 255, 0.08);
  border: 1px solid rgba(108, 99, 255, 0.12);
  border-radius: 10px;
  color: #6C63FF;
  transition: background var(--navbar-fast),
              border-color var(--navbar-fast),
              transform var(--navbar-fast),
              box-shadow var(--navbar-fast);
}

#sidebarCollapse:hover {
  background: rgba(108, 99, 255, 0.12);
  border-color: rgba(108, 99, 255, 0.2);
  transform: scale(1.05);
}

#sidebarCollapse:active {
  transform: scale(0.98);
}

#sidebarCollapse i {
  font-size: 1rem;
  transition: transform var(--navbar-transition);
}

body.sidebar-collapsed #sidebarCollapse i {
  transform: rotate(180deg);
}

/* --- Mobile Menu Toggle Button --- */
.navbar .btn-dark,
.navbar button.btn-dark,
.navbar .container-fluid > .btn-dark {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  height: 44px !important;
  padding: 0 !important;
  background: linear-gradient(135deg, #6C63FF 0%, #8B82FF 100%) !important;
  border: none !important;
  border-radius: 10px !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.25);
  transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 180ms cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.navbar .btn-dark:hover,
.navbar button.btn-dark:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(108, 99, 255, 0.35);
  background: linear-gradient(135deg, #5B54E6 0%, #7A73FF 100%) !important;
}

.navbar .btn-dark:active,
.navbar button.btn-dark:active {
  transform: scale(0.95);
}

.navbar .btn-dark i,
.navbar button.btn-dark i {
  font-size: 1.2rem !important;
  color: #ffffff !important;
}

/* --- Responsive Styles --- */

/* Tablet & Below */
@media (max-width: 991px) {
  .navbar {
    padding: 10px 16px;
    margin: 8px;
    border-radius: 14px;
  }
  
  .navbar .btn-dark,
  .navbar button.btn-dark,
  .navbar .container-fluid > .btn-dark {
    display: flex !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
  }
  
  /* Mobile Menu Dropdown */
  .navbar-collapse {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--navbar-bg-solid);
    border: 1px solid var(--navbar-border);
    border-radius: 16px;
    box-shadow: var(--navbar-shadow-scrolled);
    padding: 16px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: max-height var(--navbar-transition),
                opacity var(--navbar-transition),
                transform var(--navbar-transition);
  }
  
  .navbar-collapse.show {
    max-height: 500px;
    opacity: 1;
    transform: translateY(0);
  }
  
  .navbar-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  
  .navbar-nav .nav-link {
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 1rem;
  }
  
  .navbar-nav .nav-link::before {
    display: none;
  }
  
  /* Staggered animation for menu items */
  .navbar-collapse.show .nav-item {
    animation: slideInRight 0.3s ease-out forwards;
    opacity: 0;
  }
  
  @keyframes slideInRight {
    from {
      opacity: 0;
      transform: translateX(-16px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }
  
  .navbar-collapse.show .nav-item:nth-child(1) { animation-delay: 0.05s; }
  .navbar-collapse.show .nav-item:nth-child(2) { animation-delay: 0.1s; }
  .navbar-collapse.show .nav-item:nth-child(3) { animation-delay: 0.15s; }
  .navbar-collapse.show .nav-item:nth-child(4) { animation-delay: 0.2s; }
  .navbar-collapse.show .nav-item:nth-child(5) { animation-delay: 0.25s; }
  .navbar-collapse.show .nav-item:nth-child(6) { animation-delay: 0.3s; }
  
  /* Mobile buttons */
  .navbar .d-flex {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(108, 99, 255, 0.1);
  }
  
  .navbar .btn {
    width: 100%;
    justify-content: center;
    padding: 14px 24px;
    font-size: 1rem;
    border-radius: 12px;
  }
}

/* Small Mobile */
@media (max-width: 576px) {
  .navbar {
    padding: 10px 14px;
    margin: 8px;
    border-radius: 14px;
  }
  
  /* Keep brand text visible on mobile - match reference */
  .brand-text-wrapper {
    display: flex;
  }
  
  .brand-card-modern {
    padding: 6px 8px;
    gap: 10px;
  }
  
  .brand-logo-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(108, 99, 255, 0.15);
  }
  
  .brand-overline-modern {
    font-size: 0.75rem;
  }
  
  .brand-name-modern {
    font-size: 0.95rem;
    gap: 4px;
  }
  
  .brand-online {
    display: inline;
    font-size: 0.85em;
  }
  
  .navbar-collapse {
    padding: 12px;
    border-radius: 14px;
  }
  
  .navbar-nav .nav-link {
    padding: 12px 16px;
  }
}

/* Dark mode removed - keeping light theme only */

/* --- Reduced Motion Support --- */
@media (prefers-reduced-motion: reduce) {
  .navbar,
  .navbar::after,
  .navbar-nav .nav-link,
  .navbar-nav .nav-link::before,
  .navbar .btn,
  #sidebarCollapse,
  .navbar-collapse,
  .navbar-collapse .nav-item {
    transition: none !important;
    animation: none !important;
  }
}