/* ============================================================
   ROOT VARIABLES
   ------------------------------------------------------------
   Global CSS variables for layout, transitions, and theming.
   JS updates --theme-color dynamically.
============================================================ */
:root {
  --sidebar-width-expanded: 260px;
  --sidebar-width-collapsed: 64px;
  --transition-fast: all 0.3s ease;
  --glass-bg: rgba(255, 255, 255, 0.18);
  --glass-border: rgba(255, 255, 255, 0.35);
  --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
  --theme-color: #4f46e5; /* Default theme color */
}

/* ============================================================
   BODY BACKGROUND (Animated Gradient)
============================================================ */
@property --bg-pos {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}

body {
  font-family: "Inter", "Roboto", system-ui, sans-serif;
  background: linear-gradient(120deg,
    #ff6b6b, #feca57, #ff9ff3, #54a0ff,
    #5f27cd, #1dd1a1, #ff6b6b);
  background-size: 400% 400%;
  animation: gradientShift 18s ease infinite;
  margin: 0;
  min-height: 100vh;
}

/* ============================================================
   APP WRAPPER
============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  padding-bottom: 40px;
}

/* ============================================================
   SIDEBAR (Fully Theme-Aware)
============================================================ */
.sidebar {
  width: var(--sidebar-width-expanded);
  background-color: var(--theme-color) !important;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  transition: background-color 0.35s ease, width 0.35s ease;
  position: fixed;
  top: 0;
  bottom: 40px;
  z-index: 1030;
}

.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar-header {
  padding: 1rem;
  text-align: center;
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  cursor: pointer;
  border: 2px solid #ffffff;
  transition: border-color 0.35s ease;
}

.sidebar-username {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.sidebar-username-static {
  font-size: 0.75rem;
  opacity: 0.8;
}

.sidebar.collapsed .sidebar-username,
.sidebar.collapsed .sidebar-username-static {
  display: none;
}

/* Sidebar Menu */
.sidebar-menu {
  flex: 1;
  padding: 0.5rem 0;
}

.sidebar-menu-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  color: #e5e5e5;
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background-color 0.3s ease, border-left-color 0.3s ease;
}

.sidebar-menu-item i {
  font-size: 1.1rem;
  margin-right: 0.75rem;
}

.sidebar-menu-item:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-left-color: #ffffff;
}

.sidebar-menu-item.active {
  background-color: rgba(255, 255, 255, 0.25);
  border-left-color: #ffffff;
}

/* ============================================================
   THEME SWATCHES (Premium)
============================================================ */
.sidebar-theme {
  padding: 0.75rem 1rem 1rem;
}

.theme-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.25rem;
}

.theme-swatch {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition: all 0.25s ease;
}

.theme-swatch:hover {
  transform: scale(1.15);
}

.theme-swatch.active {
  border: 3px solid #ffffff;
  transform: scale(1.2);
}

/* ============================================================
   TOP NAVIGATION (Fully Theme-Aware)
============================================================ */
.topnav {
  position: fixed;
  left: var(--sidebar-width-expanded);
  right: 0;
  top: 0;
  height: 56px;
  background-color: var(--theme-color) !important;
  color: #ffffff;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  z-index: 1040;
  transition: background-color 0.35s ease, left 0.35s ease;
}

.sidebar.collapsed + .main-content-wrapper .topnav {
  left: var(--sidebar-width-collapsed);
}

.topnav-company {
  font-weight: 600;
}

/* ------------------------------------------------------------
   TOPNAV LAYOUT — COMPANY NAME • CENTER SEARCH • RIGHT USER AREA
------------------------------------------------------------ */

/* Company name spacing */
.topnav-company {
  margin-right: 1.5rem; /* space between company name and search bar */
}

/* Centered Search Bar (always centered in topnav) */
.topnav-search {
  flex: 1;                     /* takes available center space */
  display: flex;
  justify-content: center;     /* centers search bar */
  align-items: center;
}

/* Search bar width control (< 1/3 of topnav) */
.topnav-search .input-group {
  width: 100%;
  max-width: 360px;            /* ensures it never grows too wide */
}

/* Search bar styling */
.topnav .input-group-text,
.topnav #globalSearch {
  background-color: rgba(0, 0, 0, 0.15);
  color: #ffffff;
}

/* Right Section (Notification + User Menu) */
.topnav-user {
  display: flex;
  align-items: center;
  gap: 1.5rem;                 /* spacing between bell and user photo */
  margin-left: 1.5rem;         /* spacing from search bar */
}

/* Notification Bell */
.notification-bell {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.notification-bell i {
  color: #ffffff;
  font-size: 1.2rem;
  transition: color 0.35s ease;
}

/* User Photo Dropdown */
.topnav-user-photo {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 2px solid #ffffff;
  cursor: pointer;
  transition: border-color 0.35s ease;
}

/* ============================================================
   MAIN CONTENT
============================================================ */
.main-content-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width-expanded);
  transition: margin-left 0.35s ease;
}

.sidebar.collapsed + .main-content-wrapper {
  margin-left: var(--sidebar-width-collapsed);
}

.main-content {
  padding: 72px 1.5rem 1.5rem;
}

/* Glassmorphism Cards */
.glass-card {
  background: var(--glass-bg);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(16px);
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  padding: 1.5rem;
}

/* ============================================================
   FOOTER (Fully Theme-Aware)
============================================================ */
.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40px;
  background-color: var(--theme-color) !important;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  z-index: 1050;
  transition: background-color 0.35s ease;
}

/* ============================================================
   RESPONSIVE BEHAVIOR
============================================================ */
@media (max-width: 767.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: 240px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topnav {
    left: 0;
  }

  .main-content-wrapper {
    margin-left: 0;
  }
}

/* ============================================================
   GRADIENT ANIMATION
============================================================ */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ============================================================
   POPUP NOTIFICATION
============================================================ */
.color-popup {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 9999;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.color-popup.fade-out {
  opacity: 0;
  transform: translateY(-10px);
}