/* ===== CSS COLOR VARIABLES ===== */
:root {
  /* Sidebar Variables */
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 70px;
  --header-height: 70px;
}

/* ===== ADMIN LAYOUT ===== */
.admin-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ===== MOBILE OVERLAY ===== */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* ===== SIDEBAR STYLES ===== */
.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-dark);
  color: var(--text-white);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  transition: all 0.3s ease;
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.admin-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.admin-sidebar.collapsed .logo-text {
  display: none;
}

.sidebar-menu {
  padding: 20px 0;
}

.menu-item {
  padding: 0 10px;
  margin-bottom: 5px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.3s ease;
  position: relative;
  min-height: 44px; /* Minimum touch target */
}

.menu-link:hover,
.menu-link.active {
  background: var(--bg-primary);
  color: var(--text-white);
}

.menu-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.menu-text {
  font-size: 0.9rem;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}

.admin-sidebar.collapsed .menu-text {
  display: none;
}

/* ===== MAIN DROPDOWN STYLES ===== */
.main-dropdown {
  margin-bottom: 5px;
  position: relative;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.3s ease;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: "Poppins", sans-serif;
  min-height: 44px; /* Minimum touch target */
}

.dropdown-toggle:hover {
  background: var(--bg-primary);
  color: var(--text-white);
}

.dropdown-toggle.active {
  background: var(--bg-primary);
  color: var(--text-white);
}

.dropdown-toggle i:first-child {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.dropdown-toggle .menu-text {
  flex: 1;
}

.dropdown-toggle::after {
  content: "\f078";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  transition: transform 0.3s ease;
  font-size: 0.8rem;
}

.dropdown-toggle.active::after {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: relative;
  background: var(--bg-darker);
  border-radius: 8px;
  margin-top: 5px;
  padding: 8px 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  z-index: 1001;
}

.dropdown-menu.show {
  max-height: 500px;
  overflow-y: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.3s ease;
  font-size: 0.85rem;
  margin: 2px 8px;
  min-height: 40px; /* Minimum touch target */
}

.dropdown-item:hover {
  background: var(--bg-primary);
  color: var(--text-white);
  padding-left: 20px;
}

/* Override Bootstrap's active state for dropdown-item */
.dropdown-item.active,
.dropdown-item:active {
  color: var(--text-white) !important;
  text-decoration: none;
  background-color: var(--bg-primary) !important;
}

.dropdown-item i {
  font-size: 0.9rem;
  width: 20px;
  text-align: center;
}

/* ===== NESTED DROPDOWN (कार्य/उपक्रम) ===== */
.nested-dropdown {
  position: relative;
  margin: 5px 0;
}

.nested-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 15px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.3s ease;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: "Poppins", sans-serif;
  margin: 2px 8px;
  min-height: 40px; /* Minimum touch target */
}

.nested-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-white);
}

.nested-toggle i:first-child {
  font-size: 0.9rem;
  width: 20px;
  text-align: center;
}

.nested-toggle::after {
  content: "\f078";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  transition: transform 0.3s ease;
  font-size: 0.7rem;
  margin-left: auto;
  padding-left: 10px;
}

.nested-toggle.active::after {
  transform: rotate(180deg);
}

.nested-menu {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  margin: 5px 15px;
  padding: 5px 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nested-menu.show {
  max-height: 500px;
  overflow-y: auto;
}

.nested-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 15px 8px 25px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.3s ease;
  font-size: 0.8rem;
  margin: 1px 5px;
  min-height: 36px; /* Minimum touch target */
}

.nested-item:hover {
  background: var(--bg-primary);
  color: var(--text-white);
  padding-left: 30px;
}

/* Override Bootstrap's active state for nested-item */
.nested-item.active,
.nested-item:active {
  color: var(--text-white) !important;
  background-color: var(--bg-primary) !important;
}

.nested-item i {
  font-size: 0.8rem;
  width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 20px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.admin-sidebar.collapsed .menu-item {
  display: flex;
  justify-content: center;
}

.admin-sidebar.collapsed .menu-link {
  justify-content: center;
  padding: 12px;
}

/* Hide dropdown menu when sidebar is collapsed */
.admin-sidebar.collapsed .dropdown-menu,
.admin-sidebar.collapsed .nested-menu {
  display: none;
}

/* ===== MAIN CONTENT AREA ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
  min-height: 100vh;
}

.admin-sidebar.collapsed + .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* ===== NAVBAR STYLES ===== */
.admin-navbar {
  background: var(--bg-white);
  height: var(--header-height);
  border-bottom: 1px solid var(--bg-neutral);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 25px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 5px;
  transition: all 0.3s ease;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-primary-light);
  color: var(--bg-primary);
}

.sidebar-toggle-btn:active {
  transform: scale(0.95);
}

.page-title h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 992px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

  .admin-sidebar.show {
    transform: translateX(0);
  }

  .admin-sidebar.collapsed {
    transform: translateX(-100%);
  }

  .admin-sidebar.collapsed.show {
    transform: translateX(0);
    width: var(--sidebar-width);
  }

  .main-content {
    margin-left: 0 !important;
  }
}

/* ===== TOUCH DEVICE STYLES ===== */
@media (hover: none) {
  .menu-link:active,
  .dropdown-toggle:active,
  .nested-toggle:active,
  .dropdown-item:active,
  .nested-item:active {
    background: var(--bg-primary);
    color: var(--text-white);
  }

  .sidebar-toggle-btn:active {
    background: var(--bg-primary-light);
  }
}

/* Custom active state without using Bootstrap variables */
.active {
  background-color: var(--bg-primary) !important;
  color: var(--text-white) !important;
}

/* ===== UPDATED SIDEBAR HEADER WITH CIRCULAR IMAGE ===== */
.sidebar-header {
  padding: 15px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  height: auto;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 1002;
  background: var(--bg-dark);
  backdrop-filter: blur(5px);
}

.logo-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 5%;
}

.logo-img-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.logo-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  background: var(--bg-primary);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  /* Ensure complete visibility */
  overflow: hidden;
  /* Remove any borders/padding */
  border: none;
  padding: 0;
  margin: 0;
}

/* Ensure image inside takes full circle */
.logo-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.logo-text-container {
  width: 100%;
  text-align: center;
  padding: 5px 0;
}

.logo-text {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-white);
  white-space: normal;
  display: block;
  letter-spacing: 0.5px;
  line-height: 1.3;
  padding: 0 5px;
  max-width: 100%;
  overflow-wrap: break-word;
}

/* When sidebar is collapsed */
.admin-sidebar.collapsed .logo-container {
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.admin-sidebar.collapsed .logo-img {
  width: 60px;
  height: 60px;
}

.admin-sidebar.collapsed .logo-text-container {
  display: none;
}

/* Sidebar menu adjustment for fixed header */
.sidebar-menu {
  padding-top: 10px;
  padding-bottom: 20px;
  overflow-y: auto;
  height: calc(100vh - var(--header-height) - 70px);
  margin-top: 0;
}

/* Mobile responsive */
@media (max-width: 992px) {
  .logo-img {
    width: 90px;
    height: 90px;
  }

  .logo-text {
    font-size: 0.95rem;
  }

  .sidebar-header {
    position: sticky;
    top: 0;
  }
}

@media (max-width: 768px) {
  .logo-img {
    width: 80px;
    height: 80px;
  }

  .sidebar-menu {
    height: calc(100vh - var(--header-height) - 60px);
  }
  .sidebar-footer {
    display: none;
  }
}

@media (max-width: 576px) {
  .sidebar-header {
    padding: 12px 8px;
  }

  .logo-img {
    width: 70px;
    height: 70px;
  }

  .logo-text {
    font-size: 0.9rem;
  }

  .logo-container {
    gap: 8px;
  }

  .sidebar-menu {
    height: calc(100vh - var(--header-height) - 50px);
  }

  .sidebar-footer {
    display: none;
  }
}

/* For touch devices */
@media (hover: none) {
  .logo-img:active {
    transform: scale(0.95);
    transition: transform 0.2s ease;
  }
}

/* Hover effect for desktop */
@media (hover: hover) {
  .logo-img:hover {
    transform: scale(1.05);
    transition: transform 0.3s ease;
  }
}

/* Sidebar footer adjustment */
.sidebar-footer {
  position: sticky;
  bottom: 0;
  background: var(--bg-dark);
  padding: 15px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1001;
}

/* Ensure scrollable area */
.admin-sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ===== NESTED DROPDOWN (कार्य/उपक्रम) FIX ===== */
.nested-menu {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  margin: 5px 15px;
  padding: 0; /* Change from 5px 0 to 0 */
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  opacity: 0; /* Add this */
  visibility: hidden; /* Add this */
}

.nested-menu.show {
  max-height: 500px;
  overflow-y: auto;
  padding: 5px 0; /* Add this */
  opacity: 1; /* Add this */
  visibility: visible; /* Add this */
}

/* ===== DROPDOWN MENU FIX ===== */
.dropdown-menu {
  position: relative;
  background: var(--bg-darker);
  border-radius: 8px;
  margin-top: 5px;
  padding: 0; /* Change from 8px 0 to 0 */
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  opacity: 0; /* Add this */
  visibility: hidden; /* Add this */
}

.dropdown-menu.show {
  max-height: 500px;
  overflow-y: auto;
  padding: 8px 0; /* Add this */
  opacity: 1; /* Add this */
  visibility: visible; /* Add this */
}

/* ===== HIDE DROPDOWN ARROWS AND CENTER BARS ICON WHEN SIDEBAR COLLAPSED ===== */

/* 1. Hide dropdown arrows when sidebar is collapsed */
.admin-sidebar.collapsed .dropdown-toggle::after {
  display: none !important;
}

.admin-sidebar.collapsed .nested-toggle::after {
  display: none !important;
}

/* 2. Center the bars icon when sidebar is collapsed */
.admin-sidebar.collapsed .dropdown-toggle i.fa-bars {
  margin: 0 auto !important;
  display: block !important;
  text-align: center;
  position: static !important;
  transform: none !important;
}

/* 3. Center the button content */
.admin-sidebar.collapsed .dropdown-toggle {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 12px 0 !important;
  width: 100%;
}

/* 4. Remove gap and ensure proper centering */
.admin-sidebar.collapsed .dropdown-toggle {
  gap: 0 !important;
}

/* 5. Specifically target the सर्व मेनू dropdown button */
.admin-sidebar.collapsed button#mainDropdownToggle {
  justify-content: center !important;
}

/* 6. Ensure the icon container is properly centered */
.admin-sidebar.collapsed .dropdown-toggle i:first-child {
  margin: 0 !important;
  float: none !important;
  position: static !important;
}

.dropdown-menu {
  display: none;
}

.dropdown-menu.show {
  display: block;
}

.nested-menu {
  display: none;
  padding-left: 15px;
}

.nested-menu.show {
  display: block;
}
