/* Remove number input arrows for all browsers when using .no-arrows */
input[type="number"].no-arrows {
  appearance: textfield;
}
input[type="number"].no-arrows::-webkit-outer-spin-button,
input[type="number"].no-arrows::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}
input[type="number"].no-arrows::-ms-input-spin {
  display: none;
}
/* Global styles */
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
}

/* ================= Sidebar ================= */
.sidebar {
  /* Sticky positioning relative to the viewport */
  position: sticky;
  top: 0;
  min-width: 250px;
  width: 250px;
  height: 100vh;
  background-color: #2c3e50;
  color: #ecf0f1;
  padding: 20px;
  overflow: hidden;
  transition:
    width 0.6s ease-in-out,
    min-width 0.6s ease-in-out;
}

/* Sidebar header/logo */
.logo {
  text-align: center;
  font-size: 24px;
  margin-bottom: 30px;
  white-space: nowrap;
}

/* Sidebar navigation styles */
.sidebar nav ul {
  list-style: none;
  padding-inline-start: 0;
  margin: 0;
}

.sidebar nav ul li {
  margin-bottom: 15px;
}

/* Sidebar tabs */
.tab {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 5px;
  background: none;
  border: none;
  color: inherit;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  transition: background-color 0.3s;
}

.sidebar:not(.hidden) .tab i {
  margin-right: 8px;
}

.tab:hover,
.tab.active {
  background-color: #34495e;
}

/* Collapsed sidebar state */
.sidebar.hidden {
  width: 20px;
  min-width: 20px;
}

/* Show text labels only when sidebar is expanded */
.sidebar.hidden .tab-label,
.sidebar.hidden .logo-text {
  display: none;
}

/* For initial-load state, ensure labels are visible */
.sidebar.initial-load .tab-label,
.sidebar.initial-load .logo-text {
  opacity: 1;
  white-space: nowrap;
}

/* When the sidebar is expanded (not hidden and not in initial load) animate text fade in */
.sidebar:not(.hidden):not(.initial-load) .tab-label,
.sidebar:not(.hidden):not(.initial-load) .logo-text {
  opacity: 0; /* start hidden */
  animation: fadeIn 0.3s ease-in-out 0.4s forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* When collapsed, center the icons */
.sidebar.hidden .tab {
  display: flex;
  justify-content: center;
}

/* Optionally rotate the arrow when sidebar is expanded */
.sidebar:not(.hidden) .toggle-arrow i {
  transform: rotate(180deg);
}

/* Logout Button Specific Styling */
.logout-tab {
  background-color: #e74c3c;
  margin-top: 20px;
}
.logout-tab:hover {
  background-color: #c0392b;
}

/* ================= Mobile Sidebar Styles ================= */

/* Mobile backdrop overlay */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 30;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Prevent body scroll when mobile menu is open */
body.mobile-menu-open {
  overflow: hidden;
}

/* Sidebar toggle button - hidden by default */
#sidebar-toggle {
  display: none;
}

/* Show toggle button only on mobile and for authenticated pages */
@media (max-width: 767px) {
  #sidebar-toggle.show-mobile {
    display: block !important;
  }

  /* Force mobile sidebar to always show full content */
  #admin-sidebar.w-18 {
    width: 18rem !important; /* Force w-72 equivalent (288px / 16 = 18rem) */
  }

  /* Ensure mobile sidebar content is always visible */
  #admin-sidebar .font-medium,
  #admin-sidebar .text-2xl,
  #admin-sidebar .text-sm {
    display: block !important;
    opacity: 1 !important;
  }

  /* Ensure mobile sidebar icons have proper spacing */
  #admin-sidebar .mr-2 {
    margin-right: 0.5rem !important;
  }
}

/* PWA Standalone Mode Styles */
.pwa-standalone {
  /* Remove any browser-specific padding when running as PWA */
  margin: 0;
  padding: 0;
}

.pwa-standalone .sidebar {
  /* Adjust for no browser UI in standalone mode */
  height: 100vh;
}

.pwa-standalone .admin-content {
  /* Ensure full height utilization in standalone mode */
  min-height: 100vh;
}

/* PWA Install Button Styles */
#pwa-install-btn {
  /* Ensure install button is properly styled */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-weight: 500;
  letter-spacing: 0.5px;
  backdrop-filter: blur(10px);
}

#pwa-install-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* PWA Modal Styles */
.pwa-install-modal {
  backdrop-filter: blur(5px);
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* PWA Status Indicators */
.pwa-status {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1000;
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: bold;
}

.pwa-status.installed {
  background: #10b981;
  color: white;
}

.pwa-status.browser {
  background: #6b7280;
  color: white;
}

/* ================= Loading Overlay ================= */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Loading Spinner */
.loading-spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Loading Text */
.loading-text {
  color: white;
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  margin-top: 10px;
  letter-spacing: 0.5px;
}

/* Prevent interactions when loading */
.loading-active {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
}

.loading-active *:not(.loading-overlay):not(.loading-overlay *) {
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  cursor: default !important;
}

/* Specifically block interactive elements */
.loading-active a,
.loading-active button,
.loading-active input,
.loading-active select,
.loading-active textarea,
.loading-active [onclick],
.loading-active [role="button"],
.loading-active [tabindex],
.loading-active .tab,
.loading-active nav a,
.loading-active nav button {
  pointer-events: none !important;
  cursor: default !important;
  opacity: 0.5;
}
