:root {
  --primary-color: #1a56db;
  /* Bright Blue */
  --sidebar-bg: #0f172a;
  /* Dark Blue/Navy */
  --sidebar-text: #94a3b8;
  /* Slate 400 */
  --sidebar-active-bg: #1d4ed8;
  --sidebar-active-text: #ffffff;
  --bg-light: #f8fafc;
  /* Slate 50 */
  --card-bg: #ffffff;
  --text-dark: #1e293b;
  /* Slate 800 */
  --text-muted: #64748b;
  /* Slate 500 */
  --success-color: #10b981;
  /* Emerald 500 */
  --success-bg: #d1fae5;
  /* Emerald 100 */
  --warning-color: #f59e0b;
  /* Amber 500 */
  --warning-bg: #fef3c7;
  /* Amber 100 */
  --border-color: #e2e8f0;
  /* Slate 200 */
  --header-height: 70px;
  --sidebar-width: 250px;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Allow scrolling inside main-content only */

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-dark);
}

/* Layout Utilities */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}


/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 0 20px 30px;
  color: white;
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 600;
}

.sidebar-brand .logo-icon {
  width: 32px;
  height: 32px;
  background-color: #3b82f6;
  /* Lighter blue icon bg */
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-weight: bold;
}

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

.sidebar-nav-item {
  margin-bottom: 5px;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: white;
}

.sidebar-nav-link.active {
  background-color: var(--primary-color);
  color: white;
}

.sidebar-nav-link i {
  margin-right: 12px;
  font-size: 1.1rem;
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
}

/* Header Styles */
.top-header {
  height: var(--header-height);
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-title-area {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 100;
}

.header-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-dark);
}

.role-pills {
  display: flex;
  background-color: var(--bg-light);
  border-radius: 20px;
  padding: 4px;
  margin-left: 30px;
  border: 1px solid var(--border-color);
}

.role-pill {
  padding: 4px 16px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
}

.role-pill.active {
  background-color: white;
  color: var(--text-dark);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-user-area {
  display: flex;
  align-items: center;
}

.notification-icon {
  color: var(--text-muted);
  margin-right: 20px;
  font-size: 1.2rem;
  position: relative;
  cursor: pointer;
}

.notification-dot {
  position: absolute;
  top: 0;
  right: -2px;
  width: 8px;
  height: 8px;
  background-color: #ef4444;
  /* Red dot */
  border-radius: 50%;
  border: 2px solid white;
}

.user-profile {
  display: flex;
  align-items: center;
}

.user-info {
  text-align: right;
  margin-right: 12px;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
  line-height: 1.2;
}

.user-role {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #e2e8f0;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
}

/* Page Content */
.page-content {
  padding: 20px 24px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Dashboard Cards */
.dash-card {
  background-color: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.dash-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.dash-card-title {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0;
}

.dash-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* Specific Card Icon Colors */
.icon-blue {
  background-color: #eff6ff;
  color: #3b82f6;
}

.icon-purple {
  background-color: #faf5ff;
  color: #a855f7;
}

.icon-green {
  background-color: #f0fdf4;
  color: #22c55e;
}

.icon-orange {
  background-color: #fff7ed;
  color: #f97316;
}

.dash-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 8px 0;
}

.dash-card-meta {
  display: flex;
  align-items: center;
  margin-top: auto;
}

.badge-trend {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.badge-trend i {
  margin-right: 4px;
}

.trend-up {
  background-color: var(--success-bg);
  color: var(--success-color);
}

.trend-down {
  background-color: #fee2e2;
  color: #ef4444;
}

.meta-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 8px;
  /* space if after a badge, or acts as standard text */
  margin-bottom: 0px;
}

/* ============================================================
   SIDEBAR OVERLAY (mobile backdrop)
   ============================================================ */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

body.sidebar-open .sidebar-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Close button inside sidebar (only visible on mobile) */
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  margin-left: auto;
}

.sidebar-close-btn:hover {
  color: white;
}

/* Sidebar brand row layout for close button */
.sidebar-brand-row {
  display: flex;
  align-items: center;
  padding: 0 20px 30px;
}

.sidebar-brand-row .sidebar-brand {
  padding: 0;
  flex: 1;
}

/* Hamburger toggle button */
.sidebar-toggle-btn {
  background: none;
  border: none;
  padding: 8px 12px 8px 4px;
  margin-right: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
  /* Prevent overlap issues on mobile */
  position: relative;
  z-index: 1050;
  touch-action: manipulation;
  /* removes 300ms mobile click delay */
}

.sidebar-toggle-btn:hover,
.sidebar-toggle-btn:focus {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--text-dark);
  outline: none;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* ---- MOBILE (< 768px) ---- */
@media (max-width: 767.98px) {

  /* Sidebar: slide off-screen by default */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 200;
    width: var(--sidebar-width);
  }

  /* Sidebar: slide in when body has class 'sidebar-open' */
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }

  /* Show close button inside sidebar on mobile */
  .sidebar-close-btn {
    display: block;
  }

  /* Main content takes full width on mobile */
  .main-content {
    margin-left: 0;
  }

  /* Hamburger icon always visible on mobile */
  #sidebarToggle {
    display: inline-block !important;
  }

  /* Top header: reduce padding on mobile */
  .top-header {
    padding: 0 16px;
    height: auto;
    min-height: var(--header-height);
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Page content: reduce padding on mobile */
  .page-content {
    padding: 16px;
    overflow-y: auto;
  }

  /* On mobile the page wrapper flows naturally (page-content scrolls) */
  .so-page-wrapper {
    height: auto;
  }

  .so-tab-area {
    flex: none;
  }

  .so-tab-panel.active {
    display: block;
  }

  /* Header title: smaller font on mobile */
  .header-title {
    font-size: 1rem;
  }

  /* User info (name/role text) hidden on mobile */
  .user-info {
    display: none !important;
  }

  /* Role pills hidden on mobile (already has d-none d-md-flex) */
  .role-pills {
    display: none !important;
  }

  /* Dashboard cards: full width on mobile */
  .dash-card-value {
    font-size: 1.6rem;
  }
}

/* ---- TABLET (768px – 1023px) ---- */
@media (min-width: 768px) and (max-width: 1023.98px) {

  /* Show sidebar always; hide hamburger */
  .sidebar {
    transform: none !important;
    transition: none;
  }

  #sidebarToggle {
    display: none !important;
  }

  .top-header {
    padding: 0 20px;
  }

  .page-content {
    padding: 20px;
    overflow: hidden;
  }
}

/* ---- DESKTOP (>= 1024px) ---- */
@media (min-width: 1024px) {

  /* Sidebar always visible on desktop; no overlay needed */
  .sidebar {
    transform: none !important;
    transition: none;
  }

  #sidebarToggle {
    display: none !important;
  }
}

/* Segmented Control / Button Group */
.segmented-control {
    display: inline-flex;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    background-color: #fff;
    align-items: stretch;
    height: 38px;
    box-sizing: border-box;
}

.segment-btn {
    border: none;
    background: transparent;
    padding: 0 16px;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    border-right: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.segment-btn:last-child {
    border-right: none;
}

.segment-btn:hover {
    background-color: #f8f9fa;
}

.segment-btn.active {
    background-color: #f0f4ff;
    color: #5c6ac4;
    font-weight: 500;
}

/* ============================================================
   GLOBAL LOADER OVERLAY
   ============================================================ */
#global-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6); /* Dark backdrop */
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

#global-loader-overlay.active {
    visibility: visible;
    opacity: 1;
}

/* Custom segmented spinner matching attachment (24 spokes) */
.custom-spinner {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
}
.custom-spinner div {
    transform-origin: 40px 40px;
    animation: custom-spinner 1.2s linear infinite;
}
.custom-spinner div:after {
    content: " ";
    display: block;
    position: absolute;
    top: 5px;
    left: 38px;
    width: 4px;
    height: 16px;
    border-radius: 20%;
    background: #fff;
}
.custom-spinner div:nth-child(1) { transform: rotate(0deg); animation-delay: -1.15s; }
.custom-spinner div:nth-child(2) { transform: rotate(15deg); animation-delay: -1.1s; }
.custom-spinner div:nth-child(3) { transform: rotate(30deg); animation-delay: -1.05s; }
.custom-spinner div:nth-child(4) { transform: rotate(45deg); animation-delay: -1.0s; }
.custom-spinner div:nth-child(5) { transform: rotate(60deg); animation-delay: -0.95s; }
.custom-spinner div:nth-child(6) { transform: rotate(75deg); animation-delay: -0.9s; }
.custom-spinner div:nth-child(7) { transform: rotate(90deg); animation-delay: -0.85s; }
.custom-spinner div:nth-child(8) { transform: rotate(105deg); animation-delay: -0.8s; }
.custom-spinner div:nth-child(9) { transform: rotate(120deg); animation-delay: -0.75s; }
.custom-spinner div:nth-child(10) { transform: rotate(135deg); animation-delay: -0.7s; }
.custom-spinner div:nth-child(11) { transform: rotate(150deg); animation-delay: -0.65s; }
.custom-spinner div:nth-child(12) { transform: rotate(165deg); animation-delay: -0.6s; }
.custom-spinner div:nth-child(13) { transform: rotate(180deg); animation-delay: -0.55s; }
.custom-spinner div:nth-child(14) { transform: rotate(195deg); animation-delay: -0.5s; }
.custom-spinner div:nth-child(15) { transform: rotate(210deg); animation-delay: -0.45s; }
.custom-spinner div:nth-child(16) { transform: rotate(225deg); animation-delay: -0.4s; }
.custom-spinner div:nth-child(17) { transform: rotate(240deg); animation-delay: -0.35s; }
.custom-spinner div:nth-child(18) { transform: rotate(255deg); animation-delay: -0.3s; }
.custom-spinner div:nth-child(19) { transform: rotate(270deg); animation-delay: -0.25s; }
.custom-spinner div:nth-child(20) { transform: rotate(285deg); animation-delay: -0.2s; }
.custom-spinner div:nth-child(21) { transform: rotate(300deg); animation-delay: -0.15s; }
.custom-spinner div:nth-child(22) { transform: rotate(315deg); animation-delay: -0.1s; }
.custom-spinner div:nth-child(23) { transform: rotate(330deg); animation-delay: -0.05s; }
.custom-spinner div:nth-child(24) { transform: rotate(345deg); animation-delay: 0s; }

@keyframes custom-spinner {
    0% { opacity: 1; }
    100% { opacity: 0; }
}