/* ========================================
   MOBILE NAVIGATION SYSTEM
   Professional mobile nav for all pages
   Supports multiple toggle patterns
   ======================================== */

/* ======================
   MOBILE DRAWER - Base Styles
   ====================== */
.mobile-drawer {
  display: block !important;
  flex-direction: column;
  position: fixed !important;
  top: 70px !important;
  right: 0 !important;
  width: 280px !important;
  height: calc(100vh - 70px) !important;
  background: linear-gradient(135deg, rgba(15,23,42,0.98), rgba(30,41,59,0.98)) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-left: 1px solid rgba(220,38,38,0.3) !important;
  box-shadow: -4px 0 20px rgba(0,0,0,0.5) !important;
  padding: 0 !important;
  gap: 0 !important;
  
  /* Hidden by default using transform */
  -webkit-transform: translateX(100%);
  -moz-transform: translateX(100%);
  -ms-transform: translateX(100%);
  transform: translateX(100%);
  
  -webkit-transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  z-index: 9998 !important;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  
  visibility: visible;
  opacity: 1;
}

/* ======================
   ACTIVE STATES - Multiple Patterns
   ====================== */

/* Pattern 1: JavaScript .active class */
.mobile-drawer.active {
  -webkit-transform: translateX(0) !important;
  -moz-transform: translateX(0) !important;
  -ms-transform: translateX(0) !important;
  transform: translateX(0) !important;
}

/* Pattern 2: JavaScript .open class (legacy) */
.mobile-drawer.open {
  -webkit-transform: translateX(0) !important;
  -moz-transform: translateX(0) !important;
  -ms-transform: translateX(0) !important;
  transform: translateX(0) !important;
}

/* Pattern 3: CSS checkbox toggle */
#mobile-menu-toggle:checked ~ .mobile-drawer {
  -webkit-transform: translateX(0) !important;
  -moz-transform: translateX(0) !important;
  -ms-transform: translateX(0) !important;
  transform: translateX(0) !important;
}

/* ======================
   MOBILE HEADER - Base Styles
   ====================== */
.mobile-header {
  display: none; /* Hidden on desktop */
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 70px !important;
  background: linear-gradient(135deg, rgba(15,23,42,0.98), rgba(30,41,59,0.98)) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-bottom: 1px solid rgba(220,38,38,0.3) !important;
  z-index: 9999 !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
}

/* Support for alternative mobile header layout */
.mobile-header-left,
.mobile-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-header-left {
  flex: 1;
}

.mobile-header-right {
  gap: 0.5rem;
}

/* Burger menu button (alternative to .mobile-burger) */
.burger-menu {
  width: 44px;
  height: 44px;
  background: rgba(220,38,38,0.15);
  border: 1px solid rgba(220,38,38,0.3);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 0;
  transition: all 0.3s ease;
}

.burger-menu span {
  display: block;
  width: 20px;
  height: 2px;
  background: #ef4444;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.burger-menu.active span:nth-child(1) {
  transform: rotate(45deg) translateY(7px);
}

.burger-menu.active span:nth-child(2) {
  opacity: 0;
  transform: translateX(20px);
}

.burger-menu.active span:nth-child(3) {
  transform: rotate(-45deg) translateY(-7px);
}

/* Mobile toggle button (legacy pattern) */
.mobile-toggle {
  display: none; /* Hidden on desktop */
  flex-direction: column;
  gap: 5px;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10001;
  background: rgba(220,38,38,0.15);
  border: 1px solid rgba(220,38,38,0.3);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.mobile-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #ef4444;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translateY(7px);
}

.mobile-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translateY(-7px);
}

/* ======================
   MOBILE OVERLAY
   ====================== */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 9997;
}

.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Checkbox pattern overlay */
#mobile-menu-toggle:checked ~ .mobile-overlay {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* ======================
   CHECKBOX (hidden)
   ====================== */
.mobile-menu-checkbox {
  display: none !important;
}

.mobile-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 1rem;
  max-width: 100%;
}

/* Logo */
.mobile-logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
}

.mobile-logo-img {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 2px solid rgba(220,38,38,0.4);
  box-shadow: 0 0 15px rgba(220,38,38,0.3);
}

/* Alternative class name for mobile logo */
.mobile-logo {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 2px solid rgba(220,38,38,0.4);
  box-shadow: 0 0 15px rgba(220,38,38,0.3);
}

.mobile-logo-text {
  display: flex;
  flex-direction: column;
}

.mobile-logo-title {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #dc2626, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mobile-logo-subtitle {
  font-size: 0.625rem;
  color: #94a3b8;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Header Icons */
.mobile-header-icons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-icon-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  font-size: 1.125rem;
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
}

.mobile-icon-btn:active {
  transform: scale(0.95);
  background: rgba(220,38,38,0.2);
}

.mobile-icon-btn i {
  transition: transform 0.3s ease;
}

.mobile-icon-btn:active i {
  transform: scale(1.1);
}

/* Notification Badge */
.mobile-icon-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid rgba(15,23,42,1);
  box-shadow: 0 2px 8px rgba(220,38,38,0.5);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Burger Menu Button */
.mobile-burger {
  width: 44px;
  height: 44px;
  background: rgba(220,38,38,0.15);
  border: 1px solid rgba(220,38,38,0.3);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 0;
  transition: all 0.3s ease;
}

.mobile-burger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #ef4444;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-burger.active span:nth-child(1) {
  transform: rotate(45deg) translateY(7px);
}

.mobile-burger.active span:nth-child(2) {
  opacity: 0;
  transform: translateX(20px);
}

.mobile-burger.active span:nth-child(3) {
  transform: rotate(-45deg) translateY(-7px);
}

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

/* Mobile Drawer */
.mobile-drawer {
  position: fixed;
  top: 70px;
  right: 0;
  width: 280px;
  height: calc(100vh - 70px);
  background: linear-gradient(135deg, rgba(15,23,42,0.98), rgba(30,41,59,0.98));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(220,38,38,0.3);
  box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  
  /* Safari compatibility - add all transform prefixes */
  -webkit-transform: translateX(100%);
  -moz-transform: translateX(100%);
  -ms-transform: translateX(100%);
  transform: translateX(100%);
  
  -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  z-index: 9998;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  
  /* Ensure visibility */
  visibility: visible;
  opacity: 1;
}

/* Active state via JavaScript */
.mobile-drawer.active {
  -webkit-transform: translateX(0) !important;
  -moz-transform: translateX(0) !important;
  -ms-transform: translateX(0) !important;
  transform: translateX(0) !important;
}

/* Active state via CSS checkbox (for index.html) */
#mobile-menu-toggle:checked ~ .mobile-drawer {
  -webkit-transform: translateX(0) !important;
  -moz-transform: translateX(0) !important;
  -ms-transform: translateX(0) !important;
  transform: translateX(0) !important;
}

.mobile-drawer-content {
  padding: 1.5rem 1rem;
}

/* User Info in Drawer */
.mobile-user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(220,38,38,0.1);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.mobile-user-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  border: 2px solid rgba(220,38,38,0.5);
  overflow: hidden;
}

.mobile-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-user-details {
  flex: 1;
  min-width: 0;
}

.mobile-user-name {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-user-role {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Drawer Links */
.mobile-drawer-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: 10px;
  transition: all 0.2s ease;
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.mobile-drawer-link:active {
  background: rgba(220,38,38,0.2);
  transform: translateX(5px);
}

.mobile-drawer-link i {
  width: 20px;
  text-align: center;
  color: #ef4444;
  font-size: 1.125rem;
}

.mobile-drawer-link span {
  flex: 1;
}

/* Section Headers */
.mobile-drawer-section {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem 1rem;
}

/* Primary action button */
.mobile-drawer-primary {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  color: #fff !important;
  border-radius: 10px !important;
  margin-top: 0.5rem;
}

/* Logout button */
.mobile-logout-btn {
  background: rgba(239,68,68,0.1) !important;
  color: #ef4444 !important;
  border: 1px solid rgba(239,68,68,0.3) !important;
  border-radius: 10px !important;
  margin-top: 0.5rem;
  width: 100%;
  cursor: pointer;
}

.mobile-logout-btn:active {
  background: rgba(239,68,68,0.2) !important;
}

/* User info in drawer */
.mobile-user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(15,23,42,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  margin: 0.5rem 0;
}

.mobile-user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.mobile-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-user-details {
  flex: 1;
  min-width: 0;
}

.mobile-user-name {
  font-weight: 600;
  color: #fff;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-user-email {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile Overlay */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 9997;
}

.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Page Content Adjustment */
body.mobile-nav-active {
  padding-top: 70px;
}

/* Show on Mobile Only */
@media (max-width: 768px) {
  .mobile-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
  }
  
  .mobile-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 0 1rem;
  }
  
  .mobile-header-left,
  .mobile-header-right {
    display: flex;
    align-items: center;
  }
  
  .mobile-drawer {
    display: block;
  }
  
  .mobile-overlay {
    display: block;
  }
  
  /* Show mobile toggle button on mobile */
  .mobile-toggle {
    display: flex !important;
  }
  
  body {
    padding-top: 70px;
  }
  
  /* Hide desktop nav on mobile */
  .nav-main {
    display: none !important;
  }
}

/* CSS-ONLY MENU - Additional rules */
.mobile-menu-checkbox {
  display: none;
}

/* When checkbox checked, show overlay */
#mobile-menu-toggle:checked ~ .mobile-overlay {
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
}

/* When checked, burger becomes X */
#mobile-menu-toggle:checked ~ .mobile-header .mobile-burger span:nth-child(1) {
  -webkit-transform: rotate(45deg) translateY(7px);
  transform: rotate(45deg) translateY(7px);
}

#mobile-menu-toggle:checked ~ .mobile-header .mobile-burger span:nth-child(2) {
  opacity: 0;
  -webkit-transform: translateX(20px);
  transform: translateX(20px);
}

#mobile-menu-toggle:checked ~ .mobile-header .mobile-burger span:nth-child(3) {
  -webkit-transform: rotate(-45deg) translateY(-7px);
  transform: rotate(-45deg) translateY(-7px);
}

/* Make label clickable and touchable */
.mobile-burger {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Prevent scroll when drawer open */
body.drawer-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* ========================================
   END MOBILE NAVIGATION SYSTEM
   ======================================== */

