/**
 * Mobile Bottom Navigation Bar
 * Fixed navigation för mobil-användare (90% av användarna)
 *
 * iOS Safari: När adressfält/nedre verktygsrad döljes vid scroll skiljer sig
 * layout viewport från visual viewport — det kan ge en vit "lucka" under menyn.
 * JS sätter --ios-safari-vv-gap (px) från visualViewport; vi lägger det i padding-bottom
 * så bakgrunden fyller hela vägen ned.
 */

:root {
  --ios-safari-vv-gap: 0px;
}

/* ========== BOTTOM NAVIGATION BAR ========== */

.mobile-bottom-nav {
  display: none; /* Dölj på desktop */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 0.5rem 0;
  /* constant() = äldre iOS, env() = nyare; vv-gap fyller Safari-luckan */
  padding-bottom: calc(
    0.5rem + constant(safe-area-inset-bottom, 0px) + var(--ios-safari-vv-gap, 0px)
  );
  padding-bottom: calc(
    0.5rem + env(safe-area-inset-bottom, 0px) + var(--ios-safari-vv-gap, 0px)
  );
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transition: transform 0.3s ease;
  /* Undvik subpixel-glipor mellan nav och skärmkant */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.mobile-bottom-nav.hidden {
  transform: translateY(100%);
}

.bottom-nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.25rem;
  text-decoration: none;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  min-width: 60px;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:active {
  transform: scale(0.95);
}

.bottom-nav-item.active {
  color: #1e293b;
}

.bottom-nav-icon {
  font-size: 1.5rem !important; /* Konsistent storlek på alla sidor */
  margin-bottom: 0.25rem !important; /* Konsistent spacing */
  line-height: 1 !important; /* Konsistent höjd */
  transition: transform 0.2s ease;
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  /* Font Awesome 5 specifikt */
  font-family: "Font Awesome 5 Free" !important;
  font-weight: 900 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
}

.bottom-nav-icon::before {
  display: inline-block !important;
  font-family: "Font Awesome 5 Free" !important;
  font-weight: 900 !important;
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: scale(1.1);
  color: #1e293b;
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.bottom-nav-item.active .bottom-nav-icon::before {
  display: inline-block !important;
}

.bottom-nav-label {
  font-size: 0.688rem;
  line-height: 1;
}

/* Badge för olästa notifikationer */
.bottom-nav-badge {
  position: absolute;
  top: 0.25rem;
  right: calc(50% - 1rem);
  background: #ef4444;
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.125rem 0.375rem;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* ========== FLOATING ACTION BUTTON (FAB) ========== */

.fab-button {
  display: none; /* visas bara i @media (max-width: 767px) nedan */
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px) + var(--ios-safari-vv-gap, 0px));
  /* safe-area så knappen inte hamnar under notch/home-indicator / utanför */
  right: calc(1rem + env(safe-area-inset-right, 0px));
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #f59e0b 0%, #fb923c 100%);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 
    0 8px 20px rgba(245, 158, 11, 0.4),
    0 2px 8px rgba(245, 158, 11, 0.3);
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  animation: fab-pulse-continuous 3s ease-in-out infinite;
  /* Hindra att pulse-scale ger horisontell layout-expansion */
  will-change: transform;
}

.fab-button:active {
  transform: scale(0.92);
  box-shadow: 
    0 4px 12px rgba(245, 158, 11, 0.35),
    0 2px 6px rgba(245, 158, 11, 0.25);
}

.fab-button:hover {
  box-shadow: 
    0 12px 28px rgba(245, 158, 11, 0.5),
    0 4px 12px rgba(245, 158, 11, 0.4);
  transform: translateY(-2px) scale(1.02);
}

.fab-button.hidden {
  transform: scale(0);
  opacity: 0;
}

/* Continuous subtle pulse animation */
@keyframes fab-pulse-continuous {
  0%, 100% {
    transform: scale(1);
    box-shadow: 
      0 8px 20px rgba(245, 158, 11, 0.4),
      0 2px 8px rgba(245, 158, 11, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 
      0 12px 28px rgba(245, 158, 11, 0.5),
      0 4px 12px rgba(245, 158, 11, 0.4);
  }
}

/* ========== MORE MENU (Quick Menu Overlay) ========== */

.more-menu-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.more-menu-overlay.active {
  display: block;
  opacity: 1;
}

.more-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 24px 24px 0 0;
  padding: 1.5rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 1002;
  max-height: 70vh;
  overflow-y: auto;
}

.more-menu-overlay.active .more-menu {
  transform: translateY(0);
}

.more-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.more-menu-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
}

.more-menu-close {
  width: 40px;
  height: 40px;
  border: none;
  background: #dc2626;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s;
}

.more-menu-close svg,
.more-menu-close i {
  width: 22px;
  height: 22px;
  color: #fff;
  stroke-width: 2.5;
}

.more-menu-close:active {
  transform: scale(0.95);
  background: #b91c1c;
}

.more-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 1rem;
}

.more-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 1rem 0.5rem;
  background: #f8fafc;
  border-radius: 12px;
  text-decoration: none;
  color: #1e293b;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.more-menu-item:active {
  transform: scale(0.95);
  background: #e2e8f0;
}

/* Logout button styling */
.more-menu-item.logout-btn {
  background: #fef2f2;
  color: #ef4444;
}

.more-menu-item.logout-btn:active {
  background: #fee2e2;
}

.more-menu-item.logout-btn .more-menu-item-icon {
  color: #ef4444;
}

.more-menu-item-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: #1e293b;
}

.more-menu-item-label {
  font-size: 0.813rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}

/* Handle för att indikera att menyn kan dras ner */
.more-menu-handle {
  width: 40px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  margin: 0 auto 1rem;
}

/* ========== RESPONSIVE - Visa endast på mobil ========== */

@media (max-width: 767px) {
  /* OBS: sätt inte overflow-x på html/body här — det bryter vertikal scroll.
     Side-scroll hanteras via .mobile-menu { visibility:hidden } när stängd. */

  .mobile-bottom-nav,
  .fab-button {
    display: flex;
  }

  /* Touch-targets min 44px (UX-krav mobil) */
  .bottom-nav-item {
    min-height: 44px;
    padding: 0.5rem 0.25rem;
  }

  .more-menu-close {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  .more-menu-close svg,
  .more-menu-close i {
    width: 24px;
    height: 24px;
  }

  .more-menu-item {
    min-height: 72px;
  }

  /* Lägg till padding-bottom på body för att förhindra att innehåll döljs bakom bottom nav */
  body.mobile-nav-active {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px) + var(--ios-safari-vv-gap, 0px));
  }
}

/* Extra små skärmar */
@media (max-width: 360px) {
  .bottom-nav-label {
    font-size: 0.625rem;
  }

  .bottom-nav-icon {
    font-size: 1.25rem !important; /* Konsistent storlek på små skärmar */
  }

  .more-menu-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .fab-button {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
    bottom: calc(65px + env(safe-area-inset-bottom, 0px) + var(--ios-safari-vv-gap, 0px));
  }
}

/* Landscape mode - gör bottom nav lite mindre */
@media (max-width: 767px) and (orientation: landscape) {
  .mobile-bottom-nav {
    padding: 0.25rem 0;
  }

  .bottom-nav-item {
    padding: 0.375rem 0.25rem;
  }

  .bottom-nav-icon {
    font-size: 1.25rem !important; /* Konsistent storlek på små skärmar */
    margin-bottom: 0.125rem !important; /* Konsistent spacing */
  }

  .bottom-nav-label {
    font-size: 0.625rem;
  }

  .fab-button {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px) + var(--ios-safari-vv-gap, 0px));
    width: 56px;
    height: 56px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .mobile-bottom-nav {
    background: #1e293b;
    border-top-color: #334155;
  }

  /* Inaktiva items - ljusgrå */
  .bottom-nav-item {
    color: #94a3b8;
  }
  
  .bottom-nav-item .bottom-nav-icon {
    color: #94a3b8;
  }
  
  .bottom-nav-item .bottom-nav-label {
    color: #94a3b8;
  }

  /* Aktiva items - vita */
  .bottom-nav-item.active {
    color: white;
  }
  
  .bottom-nav-item.active .bottom-nav-icon {
    color: white !important;
  }
  
  .bottom-nav-item.active .bottom-nav-label {
    color: white;
  }

  /* More menu dark styling */
  .more-menu {
    background: #1e293b;
  }

  .more-menu-title {
    color: white;
  }

  .more-menu-close {
    background: #dc2626;
    color: #fff;
  }
  .more-menu-close svg,
  .more-menu-close i {
    color: #fff;
    stroke-width: 2.5;
  }
  .more-menu-close:active {
    background: #b91c1c;
  }

  .more-menu-item {
    background: #334155;
    color: white;
  }

  .more-menu-item:active {
    background: #475569;
  }

  .more-menu-item.logout-btn {
    background: #7f1d1d;
    color: #fca5a5;
  }

  .more-menu-item.logout-btn:active {
    background: #991b1b;
  }

  .more-menu-item.logout-btn .more-menu-item-icon {
    color: #fca5a5;
  }

  .more-menu-handle {
    background: #475569;
  }
  
  /* FAB button dark mode */
  .fab-button {
    background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
    box-shadow: 
      0 8px 20px rgba(234, 88, 12, 0.5),
      0 2px 8px rgba(234, 88, 12, 0.3);
  }
}

