/* ============================================
   File: modern-sidebar-fixes.css
   Deskripsi: Centralized Sidebar and Layout Styles
   ============================================ */

/* ============== BASE ============== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* ============== LAYOUT WRAPPER ============== */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============== LAYOUT PAGE (MAIN CONTENT) ============== */
.layout-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left 0.28s ease-in-out;
  margin-top: -67px;
}

@media (min-width: 1200px) {
  .layout-page:not(.sidebar-collapsed-content):not(.sidebar-expanded-content) {
    margin-left: -140px;
  }
  .layout-page.sidebar-collapsed-content {
    margin-left: -140px !important;
  }
  .layout-page.sidebar-expanded-content {
    margin-left: 90px !important;
  }
}

@media (max-width: 1199.98px) {
  .layout-page {
    margin-left: 0;
  }
}

.content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.container-fluid-full {
  width: 100%;
  padding: 0.25rem;
  flex: 1;
}

.layout-navbar {
  position: sticky;
  margin-bottom: 20px;
  top: 0;
  z-index: 999;
}

.content-footer {
  margin-top: auto;
}

.layout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}

.layout-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* ============== MOBILE TOGGLER (FLOATING HAMBURGER) ============== */
.menu-mobile-toggler {
  position: fixed;
  bottom: 2rem;
  left: 2rem; 
  z-index: 9999;
  display: none;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Smooth slide */
}

/* State when menu is open - slide to the right */
.menu-mobile-toggler.moved {
  transform: translateX(300px); /* Adjusted to move further right */
}

.menu-mobile-toggler .mobile-toggle-btn svg {
  transition: transform 0.3s ease; /* Smooth rotation */
}

.menu-mobile-toggler.moved .mobile-toggle-btn svg {
  transform: rotate(90deg); /* Rotate 90 degrees when active */
}


.mobile-toggle-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #00bcd4; /* Cyan SIGAP */
  border: none;
  box-shadow: 0 4px 15px rgba(0, 188, 212, 0.5);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
}

.mobile-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 188, 212, 0.7);
  background: #00acc1;
}

.mobile-toggle-btn:active {
  transform: scale(0.95);
}

.mobile-toggle-btn svg {
  width: 28px;
  height: 28px;
  stroke: white;
  stroke-width: 2.5;
}

/* Show floating button on mobile */
@media (max-width: 1199.98px) {
  .menu-mobile-toggler {
    display: flex !important;
  }
}

/* Hide floating button on desktop */
@media (min-width: 1200px) {
  .menu-mobile-toggler {
    display: none !important;
  }
}

/* ============== SIDEBAR BASE ============== */
#layout-menu {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  width: 70px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  z-index: 1100;
  box-shadow: 2px 0 15px rgba(0, 0, 0, 0.08);
  border-right: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Mobile: hidden by default */
@media (max-width: 1199.98px) {
  #layout-menu {
    width: 280px;
    transform: translateX(-100%);
  }
  #layout-menu.show {
    transform: translateX(0);
    box-shadow: 5px 0 25px rgba(0,0,0,0.2);
  }
}

/* ============== DESKTOP COLLAPSED STATE ============== */
@media (min-width: 1200px) {
  #layout-menu:not(.sidebar-expanded-js) {
    width: 70px;
    overflow: hidden;
  }

  #layout-menu:not(.sidebar-expanded-js) .menu-text,
  #layout-menu:not(.sidebar-expanded-js) .app-brand-text {
    display: none !important;
  }

  #layout-menu:not(.sidebar-expanded-js) .menu-link {
    width: 54px;
    margin: 0 auto;
    padding: 0 !important;
    border-radius: 0.375rem !important;
  }

  #layout-menu:not(.sidebar-expanded-js) .menu-link .menu-icon {
    width: 54px;
    height: 54px;
    background: transparent;
    border-radius: 0.375rem;
  }
  
  #layout-menu:not(.sidebar-expanded-js) .app-brand {
    justify-content: center;
    padding: 1.25rem 0;
  }

  #layout-menu:not(.sidebar-expanded-js) .app-brand-logo {
    margin: 0;
  }

  #layout-menu:not(.sidebar-expanded-js) .menu-inner {
    padding: 0.5rem 0;
  }

  #layout-menu:not(.sidebar-expanded-js) .menu-item {
    width: 100%;
    padding: 0;
  }

  #layout-menu:not(.sidebar-expanded-js) .user-profile-section {
    padding: 0.5rem;
  }
  
  #layout-menu:not(.sidebar-expanded-js) .user-profile-card {
    padding: 0;
    border-radius: 0.375rem;
    justify-content: center;
  }
  
  #layout-menu:not(.sidebar-expanded-js) .user-info {
    display: none !important;
  }
  
  #layout-menu:not(.sidebar-expanded-js) .user-avatar {
    margin: 0;
  }
  
  #layout-menu:not(.sidebar-expanded-js) .logout-section {
    padding: 0.5rem;
  }
  
  #layout-menu:not(.sidebar-expanded-js) #sidebar-toggle {
    display: none !important;
  }
}

/* ============== DESKTOP EXPANDED STATE ============== */
@media (min-width: 1200px) {
  #layout-menu.sidebar-expanded-js {
    width: 280px;
  }

  #layout-menu.sidebar-expanded-js .menu-text,
  #layout-menu.sidebar-expanded-js .app-brand-text {
    opacity: 1;
    visibility: visible;
    width: auto;
    transition: opacity 0.2s ease-in-out 0.1s;
  }

  #layout-menu.sidebar-expanded-js .app-brand {
    justify-content: flex-start;
  }

  #layout-menu.sidebar-expanded-js .menu-item {
    padding: 0 8px;
  }
  
  #layout-menu.sidebar-expanded-js .user-profile-section {
    padding: 1rem 0.5rem;
  }

  #layout-menu.sidebar-expanded-js .logout-section {
    padding: 0.5rem 0.5rem 1rem 0.5rem;
  }
}

/* ============== APP BRAND / LOGO ============== */
.app-brand {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Aligned left by default */
  gap: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  overflow: hidden; /* Changed from visible to hidden to better control children */
  height: 70px;
}

.app-brand-link {
  display: flex;
  align-items: center;
  justify-content: center; /* Center the link content (logo+text) within app-brand */
  gap: 0.75rem;
  text-decoration: none;
  width: 100%;
  height: 100%;
}

.app-brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 38px;
  height: 100%; /* Take full height of app-brand-link */
  position: relative;
  overflow: visible;
}

.app-brand-logo img {
  object-fit: contain;
  transition: all 0.3s ease;
  padding: 5px; /* Add some padding to prevent touching edges */
}

/* Default Logo (Collapsed state) */
.logo-collapsed {
  display: block;
  width: 38px;
  height: 38px;
}

/* Expanded Logo (Logo 2) */
.logo-expanded {
  display: none; /* Hidden by default */
  width: auto; /* Allow auto width */
  height: 50px; /* Increased height */
  max-width: 200px; /* Adjusted max width */
}

/* When Sidebar is Expanded (Desktop Hover) or Shown (Mobile) */
#layout-menu.sidebar-expanded-js .logo-collapsed,
#layout-menu.show .logo-collapsed {
  display: none;
}

#layout-menu.sidebar-expanded-js .logo-expanded,
#layout-menu.show .logo-expanded {
  display: block;
  animation: fadeIn 0.3s ease;
}

#layout-menu.sidebar-expanded-js .app-brand,
#layout-menu.show .app-brand {
  justify-content: flex-start;
  padding-left: 1rem; /* Adjusted padding */
}

.app-brand-text {
  font-weight: 700;
  font-size: 1.1rem;
  color: #0f172a;
  white-space: nowrap;
}

/* Sidebar Toggle Button (Inside Sidebar - Desktop) */
#sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  margin-left: auto;
  color: #64748b;
  display: none;
  transition: all 0.2s ease;
  border-radius: 0.375rem;
}

#sidebar-toggle:hover {
  background: #e0f7fa;
  color: #00bcd4;
}

#sidebar-toggle svg {
  transition: transform 0.3s ease;
}

#layout-menu.sidebar-expanded-js #sidebar-toggle svg {
  transform: rotate(180deg);
}

@media (max-width: 1199.98px) {
  #sidebar-toggle {
    display: none !important;
  }
}
@media (min-width: 1200px) {
  #sidebar-toggle {
    display: block !important;
  }
}

/* ============== MENU ITEMS ============== */
.menu-inner {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  padding: 1rem 0.5rem;
}

.menu-item {
  margin-bottom: 0.25rem;
  list-style: none;
  padding: 0;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  text-decoration: none;
  color: #475569;
  border-radius: 0.5rem;
  transition: all 0.28s ease;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  height: 54px;
  overflow: hidden;
  width: 100%;
}

.menu-link:hover {
  background: #e0f7fa;
  color: #00bcd4;
  transform: translateX(2px);
}

.menu-link.active,
.menu-item.active > .menu-link {
  background: #00bcd4;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 188, 212, 0.3);
}

.menu-item.active > .menu-link .menu-icon {
  background: #00bcd4;
  color: white;
}

.menu-text {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  padding-right: 0.75rem;
  padding-left: 0.75rem;
  flex: 1;
}

/* Icon container */
.menu-icon {
  width: 54px;
  height: 54px;
  min-width: 54px;
  flex-shrink: 0;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #64748b;
  background: transparent;
  transition: all 0.2s ease;
}

.menu-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.menu-icon i {
  font-size: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  opacity: 0.5 !important;
  width: 100% !important;
  height: 100% !important;
  transition: all 0.2s ease;
}

.menu-link:hover .menu-icon {
  color: #00bcd4;
  transform: scale(1.05);
}

.menu-link:hover .menu-icon i {
  opacity: 1 !important;
}

#layout-menu.sidebar-expanded-js .menu-icon i {
  opacity: 1 !important;
}

.menu-link.active .menu-icon,
.menu-item.active > .menu-link .menu-icon {
  background: #00bcd4 !important;
  color: white !important;
  border-radius: 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: white !important;
}

.menu-link.active .menu-icon i,
.menu-item.active > .menu-link .menu-icon i {
  opacity: 1 !important;
  font-size: 30px !important;
  transform: scale(1) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: white !important;
}

.menu-link.active:hover .menu-icon,
.menu-item.active > .menu-link:hover .menu-icon {
  color: white;
}

/* ============== USER PROFILE SECTION ============== */
.user-profile-section {
  flex-shrink: 0;
  padding: 1rem 0;
  margin-top: auto;
}

.user-profile-card {
  background: #e0f7fa;
  border-radius: 0.375rem;
  padding: 0;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  height: 54px;
  display: flex;
  align-items: center;
}

.user-profile-card:active {
  transform: translateX(0);
}

.user-profile-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.user-avatar {
  width: 54px;
  height: 54px;
  min-width: 54px;
  border-radius: 0.375rem;
  background: #00bcd4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  color: white;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  overflow: hidden;
  padding-right: 0.75rem;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #0f172a;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.3s ease;
}

.user-role {
  font-size: 0.75rem;
  color: #64748b;
  margin: 0.15rem 0 0 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
}

.user-profile-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, padding 0.3s ease;
  opacity: 0;
  padding: 0 0.75rem;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #b2ebf2;
  border-radius: 0 0 0.375rem 0.375rem;
  z-index: 10;
}

.user-profile-card.expanded {
  border-radius: 0.375rem 0.375rem 0 0;
}

.user-profile-card.expanded .user-profile-details {
  max-height: 200px;
  opacity: 1;
  padding: 0.75rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.user-email {
  font-size: 0.8rem;
  color: #475569;
  margin: 0;
  padding: 0.5rem;
  background: white;
  border-radius: 0.375rem;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.3s ease;
}

.user-email svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ============== LOGOUT SECTION ============== */
.logout-section {
  flex-shrink: 0;
  padding: 0.5rem 0 1rem 0;
  border-top: 1px solid #e2e8f0;
}

#logout-btn .menu-icon {
  color: #ef4444 !important;
  background: transparent;
  border-radius: 0.375rem;
}

#logout-btn:hover .menu-icon {
  color: #dc2626 !important;
  background: transparent;
}

#logout-btn:hover .menu-text {
  color: #dc2626 !important;
}

#logout-btn:hover {
  background-color: #fee2e2 !important;
  transform: translateX(2px);
}

#logout-btn {
  color: #ef4444 !important;
  border-radius: 0.375rem !important;
}

/* ============== TOOLTIP ============== */
@media (min-width: 1200px) {
  #layout-menu:not(.sidebar-expanded-js) .menu-link[data-tooltip] {
    position: relative;
  }

  #layout-menu:not(.sidebar-expanded-js) .menu-link[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) scale(0.95);
    background: #1e293b;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
  }

  #layout-menu:not(.sidebar-expanded-js) .menu-link[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) scale(1);
  }
  
  #layout-menu:not(.sidebar-expanded-js) .user-profile-card {
    position: relative;
  }
  
  #layout-menu:not(.sidebar-expanded-js) .user-profile-card::after {
    content: attr(data-user-name);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) scale(0.95);
    background: #1e293b;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
  }
}

/* ============== SCROLLBAR ============== */
.menu-inner::-webkit-scrollbar {
  width: 6px;
}
.menu-inner::-webkit-scrollbar-track {
  background: transparent;
}
.menu-inner::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
  transition: background 0.2s ease;
}
.menu-inner::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
