/* Language Detection Popup Styles */
.language-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  background: rgba(16, 46, 92, 0.744);
  backdrop-filter: blur(25px) saturate(150%) brightness(1.05);
  -webkit-backdrop-filter: blur(25px) saturate(150%) brightness(1.05);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
  overflow: hidden;
  /* Prevent iOS Safari bounce scroll */
  -webkit-overflow-scrolling: touch;
}

.language-popup-overlay.active {
  opacity: 1 !important;
  visibility: visible !important;
  display: flex !important;
}

.language-popup {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(30px) saturate(120%);
  -webkit-backdrop-filter: blur(30px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  padding: 40px;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 8px 25px rgba(13, 71, 161, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: scale(0.8) translateY(40px);
  transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.language-popup-overlay.active .language-popup {
  transform: scale(1) translateY(0) !important;
}

.popup-title {
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  line-height: 1.4;
}

.popup-subtitle {
  color: rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  text-align: center;
  margin-bottom: 32px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  line-height: 1.5;
}

.language-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.language-btn {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 1.1rem;
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  cursor: pointer;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  position: relative;
  overflow: hidden;
}

.language-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.6s ease;
}

.language-btn:hover::before {
  left: 100%;
}

.language-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.language-btn:active {
  transform: translateY(0);
}

.flag-icon {
  width: 24px;
  height: 18px;
  margin-right: 12px;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.close-btn {
  width: 100%;
  padding: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 24px;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
}

.invoice-section {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.invoice-text {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  margin-bottom: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.invoice-btn {
  display: inline-block;
  padding: 12px 24px;
  background: linear-gradient(135deg, rgba(25, 118, 210, 0.6), rgba(13, 71, 161, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 15px rgba(25, 118, 210, 0.2);
  position: relative;
  overflow: hidden;
}

.invoice-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.6s ease;
}

.invoice-btn:hover::after {
  width: 300px;
  height: 300px;
}

.invoice-btn:hover {
  background: linear-gradient(135deg, rgba(25, 118, 210, 0.75), rgba(13, 71, 161, 0.8));
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(25, 118, 210, 0.3);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .language-popup-overlay {
    padding: 20px;
    align-items: center !important; /* Centrar na sredini ekrana */
    justify-content: center !important;
    padding-top: 0; /* Uklanjam padding-top da bude u centru */
  }
  
  .language-popup {
    padding: 30px 20px;
    margin: 0;
    border-radius: 20px;
    max-width: 95%;
    width: 100%;
    max-height: 85vh;
    transform: scale(0.9) translateY(20px);
    box-shadow: 
      0 25px 80px rgba(0, 0, 0, 0.4),
      0 12px 35px rgba(13, 71, 161, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.25);
  }
  
  .language-popup-overlay.active .language-popup {
    transform: scale(1) translateY(0);
  }
  
  .popup-title {
    font-size: 1.4rem;
    margin-bottom: 12px;
    line-height: 1.3;
  }
  
  .popup-subtitle {
    font-size: 1rem;
    margin-bottom: 24px;
    line-height: 1.4;
  }
  
  .language-buttons {
    gap: 12px;
    margin-bottom: 24px;
  }
  
  .language-btn {
    padding: 16px 20px;
    font-size: 1rem;
    border-radius: 14px;
    min-height: 60px; /* Veći gumbovi za lakše dodirovanje */
  }
  
  .flag-icon {
    width: 22px;
    height: 16px;
    margin-right: 12px;
  }
  
  .close-btn {
    padding: 14px;
    font-size: 0.9rem;
    margin-bottom: 20px;
    border-radius: 12px;
    min-height: 50px;
  }
  
  .invoice-section {
    padding-top: 16px;
  }
  
  .invoice-text {
    font-size: 0.9rem;
    margin-bottom: 12px;
  }
  
  .invoice-btn {
    padding: 12px 20px;
    font-size: 0.9rem;
    border-radius: 12px;
    min-height: 48px;
  }
}

@media (max-width: 480px) {
  .language-popup-overlay {
    padding: 15px;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .language-popup {
    padding: 25px 18px;
    border-radius: 18px;
    max-width: 98%;
    max-height: 90vh;
    transform: scale(0.85) translateY(15px);
  }
  
  .language-popup-overlay.active .language-popup {
    transform: scale(1) translateY(0);
  }
  
  .popup-title {
    font-size: 1.2rem;
    margin-bottom: 10px;
    line-height: 1.25;
  }
  
  .popup-subtitle {
    font-size: 0.9rem;
    margin-bottom: 18px;
    line-height: 1.35;
  }
  
  .language-buttons {
    gap: 10px;
    margin-bottom: 18px;
  }
  
  .language-btn {
    padding: 14px 16px;
    font-size: 0.95rem;
    border-radius: 12px;
    min-height: 55px;
  }
  
  .flag-icon {
    width: 20px;
    height: 15px;
    margin-right: 10px;
  }
  
  .close-btn {
    padding: 12px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    border-radius: 10px;
    min-height: 46px;
  }
  
  .invoice-section {
    padding-top: 14px;
  }
  
  .invoice-text {
    font-size: 0.85rem;
    margin-bottom: 10px;
  }
  
  .invoice-btn {
    padding: 10px 18px;
    font-size: 0.85rem;
    border-radius: 10px;
    min-height: 44px;
  }
}

@media (max-width: 360px) {
  .language-popup-overlay {
    padding: 10px;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .language-popup {
    padding: 20px 14px;
    border-radius: 16px;
    max-width: 100%;
  }
  
  .popup-title {
    font-size: 1.1rem;
    margin-bottom: 8px;
  }
  
  .popup-subtitle {
    font-size: 0.85rem;
    margin-bottom: 16px;
  }
  
  .language-btn {
    padding: 12px 14px;
    font-size: 0.9rem;
    min-height: 52px;
  }
  
  .flag-icon {
    width: 18px;
    height: 13px;
    margin-right: 8px;
  }
  
  .close-btn {
    min-height: 44px;
  }
  
  .invoice-btn {
    min-height: 42px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .language-btn {
    /* Veći padding za lakše dodirovanje na mobilnim */
    padding: 18px 24px !important;
    min-height: 65px !important;
    font-size: 1.05rem !important;
  }
  
  .language-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: none;
    box-shadow: none;
  }
  
  .language-btn:active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(0.97);
    transition: all 0.1s ease;
  }
  
  .close-btn {
    min-height: 55px !important;
    font-size: 0.95rem !important;
    padding: 16px !important;
  }
  
  .close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
  }
  
  .close-btn:active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(0.97);
    transition: all 0.1s ease;
  }
  
  .invoice-btn {
    min-height: 50px !important;
    padding: 14px 24px !important;
  }
  
  .invoice-btn:hover {
    background: linear-gradient(135deg, rgba(25, 118, 210, 0.6), rgba(13, 71, 161, 0.7));
    border-color: rgba(255, 255, 255, 0.3);
    transform: none;
    box-shadow: 0 4px 15px rgba(25, 118, 210, 0.2);
  }
  
  .invoice-btn:active {
    background: linear-gradient(135deg, rgba(25, 118, 210, 0.8), rgba(13, 71, 161, 0.85));
    transform: scale(0.97);
    transition: all 0.1s ease;
  }
  
  /* Dodaj vizualni feedback na dodir */
  .language-btn, .close-btn, .invoice-btn {
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

/* Animation for popup entrance */
@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(40px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Smooth scrollbar for mobile */
.language-popup::-webkit-scrollbar {
  width: 6px;
}

.language-popup::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.language-popup::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.language-popup::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Fallback for browsers that don't support backdrop-filter */
@supports not (backdrop-filter: blur(1px)) {
  .language-popup-overlay {
    background: rgba(13, 71, 161, 0.85);
  }
  
  .language-popup {
    background: rgba(16, 42, 82, 0.95);
  }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .language-popup-overlay {
    height: -webkit-fill-available;
    /* Poboljšano centriranje za iOS Safari */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .language-popup {
    -webkit-overflow-scrolling: touch;
    /* Sprečava zoom na focus input elementa */
    -webkit-text-size-adjust: 100%;
  }
  
  /* Dodatno centriranje za landscape orientaciju */
  @media (orientation: landscape) and (max-height: 500px) {
    .language-popup-overlay {
      padding: 10px;
    }
    
    .language-popup {
      max-height: 90vh;
      padding: 20px 16px;
    }
    
    .popup-title {
      font-size: 1.1rem;
      margin-bottom: 8px;
    }
    
    .popup-subtitle {
      font-size: 0.85rem;
      margin-bottom: 14px;
    }
    
    .language-buttons {
      gap: 8px;
      margin-bottom: 14px;
    }
    
    .language-btn {
      padding: 12px 16px;
      min-height: 50px;
      font-size: 0.95rem;
    }
  }
}

/* Dodatno poboljšanje za Android */
@media screen and (max-width: 768px) {
  .language-popup-overlay {
    /* Osigurava da popup bude uvijek u centru */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
  }
  
  /* Sprečava scroll na body-ju kad je popup aktivan */
  body.popup-active {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
  }
}
