/**
 * Pavo Admin - Mega Menu Responsive Styles
 * Copyright (c) 2025 RefineThemes
 * Makes mega menu responsive for all devices
 */

/* ============================================
   MEGA MENU RESPONSIVE STYLES
   ============================================ */

/* Base Mega Menu Styles */
.mega-menu {
  position: fixed !important;
  top: 60px !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  background: #fff;
  box-shadow: 0 14px 18px 0 rgba(0, 0, 0, 0.2), 0 16px 20px 0 rgba(0, 0, 0, 0.19);
  z-index: 9999 !important;
  padding: 0px;
  max-height: 80vh;
  overflow-y: auto;
  margin: 0 !important;
}

.mega-menu .row {
  margin: 0;
  width: 100%;
}

/* Override any sidebar margin/padding that might push mega menu */
.main-content .navbar .mega-menu {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Ensure mega menu is not affected by sidebar */
body.sidebar-flat-menu .mega-menu,
body.compact-sidebar .mega-menu,
body.push-sidebar .mega-menu {
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
}

.mega-menu h6 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

/* Mega Menu Button - Always Visible */
#mega-menu-btn {
  display: inline-block !important;
  padding: 8px 15px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#mega-menu-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

/* ============================================
   DESKTOP (1200px and above)
   ============================================ */
@media (min-width: 1200px) {
  .mega-menu {
    padding: 10px;
    max-width: 100%;
    left: 0 !important;
    right: 0 !important;
  }
  
  .mega-menu .col-xxl-3,
  .mega-menu .col-xl-3 {
    border-right: 1px solid #eee;
  }
  
  .mega-menu .col-xxl-3:last-child,
  .mega-menu .col-xl-3:last-child {
    border-right: none;
  }
  
  .mega-menu .row {
    max-width: 100%;
    margin: 0 auto;
  }
}

/* ============================================
   LAPTOP (992px - 1199px)
   ============================================ */
@media (min-width: 992px) and (max-width: 1199px) {
  .mega-menu {
    padding: 20px;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }
  
  .mega-menu .row {
    width: 100%;
    margin: 0;
  }
  
  .mega-menu .col-xxl-3,
  .mega-menu .col-xl-3,
  .mega-menu .col-md-3 {
    flex: 0 0 50%;
    max-width: 50%;
    margin-bottom: 20px;
    padding: 0 15px;
  }
  
  .mega-menu .col-xxl-3:nth-child(odd),
  .mega-menu .col-xl-3:nth-child(odd),
  .mega-menu .col-md-3:nth-child(odd) {
    border-right: 1px solid #eee;
  }
}

/* ============================================
   TABLET (768px - 991px)
   ============================================ */
@media (min-width: 768px) and (max-width: 991px) {
  #mega-menu-btn {
    display: inline-block !important;
  }
  
  .mega-menu {
    display: none !important;
    padding: 20px 15px;
    max-height: 70vh;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    position: fixed !important;
    top: 60px !important;
  }
  
  .mega-menu.active {
    display: block !important;
  }
  
  .mega-menu .row {
    width: 100%;
    margin: 0;
  }
  
  .mega-menu .col-xxl-3,
  .mega-menu .col-xl-3,
  .mega-menu .col-md-3 {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: 20px;
    padding: 15px;
    border-right: none !important;
    border-bottom: 1px solid #eee;
  }
  
  .mega-menu .col-xxl-3:last-child,
  .mega-menu .col-xl-3:last-child,
  .mega-menu .col-md-3:last-child {
    border-bottom: none;
  }
  
  .mega-menu .dropdown-menu {
    position: static !important;
    display: block !important;
    float: none;
    border: none;
    box-shadow: none;
    padding: 10px 0;
  }
  
  .mega-menu .resource-links {
    margin-bottom: 10px;
  }
  
  .mega-menu .notifications .dropdown-messages {
    max-height: 200px;
    overflow-y: auto;
  }
}

/* ============================================
   MOBILE (576px - 767px)
   ============================================ */
@media (min-width: 576px) and (max-width: 767px) {
  #mega-menu-btn {
    display: inline-block !important;
    font-size: 12px;
    padding: 6px 12px;
  }
  
  .mega-menu {
    display: none !important;
    padding: 15px 10px;
    max-height: 60vh;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    position: fixed !important;
    top: 60px !important;
  }
  
  .mega-menu.active {
    display: block !important;
  }
  
  .mega-menu .row {
    width: 100%;
    margin: 0;
  }
  
  .mega-menu .row {
    flex-direction: column;
  }
  
  .mega-menu .col-xxl-3,
  .mega-menu .col-xl-3,
  .mega-menu .col-md-3 {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: 15px;
    padding: 12px;
    border-right: none !important;
    border-bottom: 1px solid #eee;
  }
  
  .mega-menu h6 {
    font-size: 13px;
    margin-bottom: 10px;
  }
  
  .mega-menu .dropdown-menu {
    position: static !important;
    display: block !important;
    float: none;
    border: none;
    box-shadow: none;
    padding: 8px 0;
  }
  
  .mega-menu .dropdown-item {
    padding: 8px 10px;
    font-size: 13px;
  }
  
  .mega-menu .resource-links {
    flex: 0 0 33.333%;
    max-width: 33.333%;
    margin-bottom: 10px;
  }
  
  .mega-menu .resource-links img {
    max-width: 30px;
  }
  
  .mega-menu .resource-links p {
    font-size: 11px;
  }
  
  .mega-menu .notifications .dropdown-messages {
    max-height: 150px;
    overflow-y: auto;
  }
  
  .mega-menu .dropdown-messages-box {
    padding: 8px;
  }
  
  .mega-menu .img-circle {
    width: 30px;
    height: 30px;
  }
}

/* ============================================
   SMALL MOBILE (320px - 575px)
   ============================================ */
@media (max-width: 575px) {
  #mega-menu-btn {
    display: inline-block !important;
    font-size: 11px;
    padding: 5px 10px;
  }
  
  #mega-menu-btn .small {
    font-size: 10px;
  }
  
  .mega-menu {
    display: none !important;
    padding: 10px 8px;
    max-height: 50vh;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    font-size: 12px;
    position: fixed !important;
    top: 60px !important;
  }
  
  .mega-menu.active {
    display: block !important;
  }
  
  .mega-menu .row {
    width: 100%;
    margin: 0;
  }
  
  .mega-menu .row {
    flex-direction: column;
  }
  
  .mega-menu .col-xxl-3,
  .mega-menu .col-xl-3,
  .mega-menu .col-md-3 {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: 12px;
    padding: 10px;
    border-right: none !important;
    border-bottom: 1px solid #eee;
  }
  
  .mega-menu .col-xxl-3:last-child,
  .mega-menu .col-xl-3:last-child,
  .mega-menu .col-md-3:last-child {
    border-bottom: none;
    margin-bottom: 0;
  }
  
  .mega-menu h6 {
    font-size: 12px;
    margin-bottom: 8px;
    padding-bottom: 6px;
  }
  
  .mega-menu .dropdown-menu {
    position: static !important;
    display: block !important;
    float: none;
    border: none;
    box-shadow: none;
    padding: 6px 0;
  }
  
  .mega-menu .dropdown-item {
    padding: 6px 8px;
    font-size: 12px;
  }
  
  .mega-menu .resource-links {
    flex: 0 0 50%;
    max-width: 50%;
    margin-bottom: 8px;
  }
  
  .mega-menu .resource-links img {
    max-width: 25px;
  }
  
  .mega-menu .resource-links p {
    font-size: 10px;
    margin-top: 3px;
  }
  
  .mega-menu .notifications .dropdown-messages {
    max-height: 120px;
    overflow-y: auto;
  }
  
  .mega-menu .dropdown-messages-box {
    padding: 6px;
  }
  
  .mega-menu .img-circle {
    width: 25px;
    height: 25px;
  }
  
  .mega-menu .media-body {
    font-size: 11px;
  }
  
  .mega-menu .media-body small {
    font-size: 10px;
  }
  
  .mega-menu .float-end {
    float: none !important;
    display: block;
    margin-top: 3px;
  }
}

/* ============================================
   DARK THEME SUPPORT
   ============================================ */
.dark-theme .mega-menu {
  background-color: rgba(45, 53, 60, 0.98);
  color: #fff;
}

.dark-theme .mega-menu h6 {
  color: #fff;
  border-bottom-color: #444;
}

.dark-theme .mega-menu .col-xxl-3,
.dark-theme .mega-menu .col-xl-3,
.dark-theme .mega-menu .col-md-3 {
  border-color: #444 !important;
}

.dark-theme .mega-menu .dropdown-menu {
  background-color: transparent;
  color: #fff;
}

.dark-theme .mega-menu .dropdown-item {
  color: #ddd;
}

.dark-theme .mega-menu .dropdown-item:hover,
.dark-theme .mega-menu .dropdown-item:focus {
  background-color: #424d57;
  color: #fff;
}

.dark-theme .mega-menu .text-dark {
  color: #fff !important;
}

.dark-theme .mega-menu .text-muted {
  color: #aaa !important;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
.mega-menu::-webkit-scrollbar {
  width: 6px;
}

.mega-menu::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.mega-menu::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.mega-menu::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.dark-theme .mega-menu::-webkit-scrollbar-track {
  background: #2d353c;
}

.dark-theme .mega-menu::-webkit-scrollbar-thumb {
  background: #555;
}

.dark-theme .mega-menu::-webkit-scrollbar-thumb:hover {
  background: #777;
}

/* ============================================
   SIDEBAR ADJUSTMENTS
   ============================================ */
/* When sidebar is visible on desktop */
@media (min-width: 992px) {
  body:not(.compact-sidebar) .mega-menu {
    position: relative !important;
    left: -220px !important;
    right: -220px !important;
    width:100vw !important;
    top: -2px !important;
    margin-left: 0px !important;
  }
  
  body.compact-sidebar .mega-menu {
    left: 70px !important;
    width: calc(100% - 70px) !important;
  }
}

/* On mobile/tablet, always full width */
@media (max-width: 991px) {
  .mega-menu {
    left: 0 !important;
    width: 100% !important;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
#mega-menu-btn:focus {
  outline: 2px solid #6c5ce7;
  outline-offset: 2px;
}

.mega-menu .dropdown-item:focus {
  outline: 2px solid #6c5ce7;
  outline-offset: -2px;
}

/* ============================================
   ANIMATIONS
   ============================================ */
.mega-menu {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  #mega-menu-btn,
  .mega-menu {
    display: none !important;
  }
}
