/* React-specific additional styles */

/* Animation for flowing logos */
@keyframes flowRight {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(-50%)); /* Exactly half width for perfect loop */
  }
}

.sponsor-logos {
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
  border-radius: 8px;
  padding: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.logo-container-animated {
  display: flex;
  align-items: center;
  gap: 55px;
  animation: flowRight 30s linear infinite; /* Slower animation */
  white-space: nowrap;
  padding: 0 10px;
  width: max-content;
}

.logo-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 6px;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sponsor-logo {
  height: 50px;
  width: auto;
  object-fit: contain;
}

/* Countdown component improvements */
.countdown-component {
  width: 100%;
}

.countdown-component.compact .countdown-content {
  padding: 5px;
}

.screen-countdown {
  margin: auto !important;
}

.countdown-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.countdown-timer {
  background: rgba(202, 206, 180, 0.493);
  padding: 6px 12px;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 20px;
  color: #374151;
  /* Flexible text handling */
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.4;
  max-width: 100%;
  min-height: auto;
  display: block;
  width: auto;
  /* Typography enhancement */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* MainHeader component styles */
.header {
  /* position: absolute; */
  bottom: 10;
  left: 0;
  right: 0;
  z-index: 1000;
  color: #334155;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.header:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-content {
  display: flex;
  flex-direction: column;
  /* justify-content: space-between;
  align-items: center; */
  padding: 14px 24px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 65px;
}

.header-left {
  flex: 1;
}

.header-center {
  order: 2;
  display: flex;
  justify-content: center;
}

.header-countdown {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #418df0 0%, #fde68a 100%);
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid #0ea5e9;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.1);
  transition: all 0.3s ease;
}

.header-countdown:hover {
  border: orange 1px solid;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(245, 158, 11, 0.2);
}

.countdown-icon {
  font-size: 3rem;
  color: #d97706;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.countdown-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.countdown-label {
  font-size: 0.75rem;
  color: #92400e;
  font-weight: 600;
  line-height: 1.2;
  max-width: 280px;
  word-wrap: break-word;
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  order: 1;
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 80px;
  margin-bottom: 10px;
  background: linear-gradient(
    360deg,
    rgba(40, 82, 116, 0.5),
    rgba(6, 58, 126, 0.7)
  );
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 10px 16px;
  border-radius: 30px;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.user-info:hover {
  border: #fff 1px solid;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(14, 165, 233, 0.2);
}

.user-avatar {
  font-size: 1.4rem;
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
  color: #0f172a;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0ea5e9;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.user-avatar:hover {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.user-details h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  color: white;
}

.user-details p {
  margin: 0;
  font-size: 0.8rem;
  color: white;
  line-height: 1.2;
}

.user-info-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-btn {
  /* background: linear-gradient(135deg, #4439db 0%, #fca5a5 100%); */
  background-color: #356d94;
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  border: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.5rem;
  font-weight: 500;
}

.logout-btn:hover {
  border: #fff 1px solid;
  background-color: #356d94;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(220, 38, 38, 0.2);
}

.logout-btn:active {
  transform: translateY(0);
}

.logout-btn .icon {
  font-size: 1rem;
}

.logout-text {
  font-size: 0.85rem;
  font-weight: 600;
}

/* MainAppScreen specific improvements */
#main-app-screen .container {
  width: 100%;
  max-width: 600px;
  /* margin: 60px auto; */
}

#main-app-screen .section {
  margin-bottom: 1.5rem;
}

#main-app-screen .card {
  margin-bottom: 1rem;
}

/* Better spacing for app layout */
.app-layout {
  min-height: auto;
  display: block;
  padding: 1rem;
}

.app-layout .section {
  width: 100%;
  max-width: none;
}

/* Ensure consistent PrizeGallery positioning across all screens */
#phone-entry-screen .container:last-child,
#code-verification-screen .container:last-child,
#main-app-screen .container:last-child,
#lottery-closed-screen .container:last-child {
  /* margin-top: 100px; */
}

#phone-entry-screen .container:last-child .card,
#code-verification-screen .container:last-child .card,
#main-app-screen .container:last-child .card,
#lottery-closed-screen .container:last-child .card {
  margin-bottom: 0;
}

/* Specific adjustments for code verification screen */
#code-verification-screen {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 2rem;
  min-height: 100vh;
}

#code-verification-screen .container {
  width: 100%;
  max-width: 32rem;
  margin-bottom: 1rem;
}

#code-verification-screen .container:last-child {
  margin-bottom: 0;
  margin-top: 1.5rem;
}

/* Ensure PrizeGallery appears at bottom consistently */
#code-verification-screen .container:last-child .section-title {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

/* Code verification timer styles */
.code-timer {
  margin: 1rem 0;
  text-align: center;
  padding: 8px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.timer-text {
  margin: 0;
  color: #1e40af;
  font-size: 0.9rem;
}

.timer-expired {
  margin: 0;
  color: #dc2626;
  font-weight: 600;
  font-size: 0.9rem;
}

.resend-btn {
  width: 100%;
  margin-top: 10px;
}

.resend-info {
  color: #6b7280;
  font-size: 0.85rem;
  text-align: center;
  display: block;
  margin-top: 10px;
}

/* Autocomplete suggestions */
.autocomplete-wrapper {
  position: relative !important;
  min-height: 2.5rem !important;
  margin-bottom: 1rem !important;
  /* isolation: isolate; - stacking context үүсгэхгүй */
}

.autocomplete-wrapper input {
  position: static !important;
  background: white !important;
  /* z-index устгав */
}

/* Force suggestions below input, always on top */
.suggestions-dropdown {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  min-width: 100% !important;
  background: white !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15) !important;
  max-height: 220px !important;
  overflow-y: auto !important;
  z-index: 9999 !important; /* Бүх элементээс дээр */
  margin-top: 2px !important;
  margin-bottom: 0 !important;
}

.suggestion-item {
  padding: 6px 8px !important;
  cursor: pointer !important;
  border-bottom: 1px solid #f1f5f9 !important;
  transition: background-color 0.2s !important;
  font-size: 0.7rem !important;
  position: relative !important;
  z-index: 99999 !important;
  background: white !important;
}

.suggestion-item:hover,
.suggestion-item.active {
  background-color: #f8fafc !important;
  color: #4f46e5 !important;
}

.suggestion-item:last-child {
  border-bottom: none !important;
}

/* Field warning for autocomplete validation */
.field-warning {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  font-size: 0.75rem !important;
  color: #dc3545 !important;
  background: #f8d7da !important;
  border: 1px solid #f5c6cb !important;
  border-radius: 4px !important;
  padding: 2px 6px !important;
  margin-top: 2px !important;
  z-index: 10000 !important;
  white-space: nowrap !important;
}

/* Make sure suggestions appear above other elements */
.form-group {
  position: static !important; /* Remove z-index stacking context */
  z-index: auto !important;
  margin-bottom: 0px !important;
}

.names-grid {
  position: static !important;
  z-index: auto !important;
}

@keyframes slideInRight {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Tablet styles (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .header-content {
    padding: 12px 20px;
  }

  .header-countdown {
    padding: 9px 14px;
    gap: 10px;
  }

  .countdown-label {
    font-size: 0.72rem;
    max-width: 250px;
  }

  .user-info {
    padding: 9px 14px;
    gap: 80px;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
  }

  .user-details h2 {
    font-size: 0.95rem;
  }

  .user-details p {
    font-size: 0.75rem;
  }

  .logout-text {
    display: inline;
    font-size: 0.8rem;
  }

  .logout-btn {
    padding: 7px 10px;
    gap: 5px;
  }

  #main-app-screen {
    padding-top: 90px; /* Adjusted for tablet absolute header */
  }

  #main-app-screen .container {
    /* margin-top: 160px; */
    max-width: 700px;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #main-app-screen .section {
    margin-bottom: 0;
  }
  .sponsor-logo {
    height: 60px;
    width: 110px;
    object-fit: contain;
  }

  /* Mobile fixes for countdown component */
  .countdown-component {
    width: 100%;
  }

  .countdown-content {
    flex-direction: column;
    text-align: center;
    padding: 8px 5px;
  }

  .countdown-text {
    font-size: 0.8rem;
    margin-bottom: 2px;
  }

  .countdown-timer {
    font-size: 0.85rem !important;
    padding: 8px 10px !important;
    line-height: 1.3 !important;
    margin: 0 auto !important;
    max-width: 95% !important;
    min-width: 200px !important;
    text-align: center !important;
    /* Better text wrapping */
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
    /* Remove conflicting styles */
    width: auto !important;
    display: block !important;
  }

  /* Mobile code timer adjustments */
  .code-timer {
    margin: 0.75rem 0;
    padding: 6px;
  }

  .timer-text,
  .timer-expired {
    font-size: 0.8rem;
  }

  .resend-info {
    font-size: 0.75rem;
  }

  /* Mobile header adjustments */
  .header-content {
    padding: 12px 16px;
    min-height: auto;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .header-center {
    flex: none;
    max-width: none;
    order: 2;
  }

  .header-right {
    flex: none;
    max-width: none;
    order: 1;
    justify-content: center;
  }

  .header-countdown {
    padding: 10px 12px;
    gap: 10px;
    border-radius: 10px;
    max-width: 100%;
    width: 100%;
    justify-content: center;
  }

  .countdown-icon {
    font-size: 3rem;
  }

  .countdown-label {
    font-size: 0.75rem; /* Slightly larger on mobile */
    line-height: 1.3;
    max-width: none;
    text-align: center;
  }

  .countdown-info {
    gap: 2px;
    text-align: center;
    width: 100%;
  }

  .user-info {
    /* position: fixed;
    top: 90%;
    left: 0;
    z-index: 1000;
    gap: 140px; */
    padding: 10px 12px;
    border-radius: 30px;
    width: 100%;
    justify-content: center;
  }

  .user-avatar {
    width: 34px;
    height: 34px;
    font-size: 1.3rem;
  }

  .user-details h2 {
    font-size: 0.9rem;
  }

  .user-details p {
    font-size: 0.75rem;
  }

  .logout-btn {
    padding: 8px 12px;
    gap: 6px;
    border-radius: 20px;
  }

  .logout-text {
    display: inline;
    font-size: 0.8rem;
  }

  .logout-btn .icon {
    font-size: 1rem;
  }

  #main-app-screen {
    /* padding-top: 100px;  */
    /* Reduced for absolute header */
  }

  /* MainAppScreen mobile improvements */
  #main-app-screen .container {
    /* margin-top: 160px; */
    padding: 0 10px;
  }

  #main-app-screen .app-layout {
    padding: 0.5rem;
  }

  #main-app-screen .card {
    padding: 1rem;
    margin-bottom: 0.75rem;
  }

  /* Consistent PrizeGallery spacing on mobile */
  #phone-entry-screen .container:last-child,
  #code-verification-screen .container:last-child,
  #lottery-closed-screen .container:last-child {
    margin-top: 530px;
    /* Reduced from 10rem for better spacing */
  }

  #main-app-screen .container:last-child,
  #code-verification-screen .container:last-child,
  #main-app-screen .container:last-child,
  #lottery-closed-screen .container:last-child {
    margin-top: 100px;
    /* Reduced from 10rem for better spacing */
  }

  #code-verification-screen .container:last-child,
  #code-verification-screen .container:last-child,
  #lottery-closed-screen .container:last-child {
    margin-top: 530px;
    /* Reduced from 10rem for better spacing */
  }

  #phone-entry-screen .container:last-child .card,
  #code-verification-screen .container:last-child .card,
  #main-app-screen .container:last-child .card,
  #lottery-closed-screen .container:last-child .card {
    padding: 1rem 0.8rem;
    margin-bottom: 1rem;
  }

  #code-verification-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-bottom: 2rem;
    min-height: 100vh;
  }
}

/* Toast Messages */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
  min-width: 300px;
  max-width: 400px;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-content {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toast-message {
  flex-grow: 1;
  font-weight: 500;
  color: #333;
}

.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  padding: 0;
  margin-left: 16px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  color: #333;
}

.toast-success {
  border-left: 4px solid #4caf50;
}

.toast-success .toast-message {
  color: #2e7d32;
}

.toast-error {
  border-left: 4px solid #f44336;
  background-color: #ffebee;
}

.toast-error .toast-message {
  color: #c62828;
  font-weight: bold;
}

@keyframes toastSlideIn {
  0% {
    transform: translateX(100%) scale(0.8);
    opacity: 0;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

/* Mobile responsive */
@media (max-width: 480px) {
  .toast {
    left: 20px;
    right: 20px;
    min-width: auto;
    max-width: none;
  }

  .countdown-timer {
    font-size: 0.8rem !important;
    padding: 6px 8px !important;
    line-height: 1.25 !important;
    margin: 0 auto !important;
    max-width: 90% !important;
    min-width: 180px !important;
    /* Enhanced text wrapping for small screens */
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    text-align: center !important;
    border-radius: 4px !important;
  }
}

/* Extra small mobile devices */
@media (max-width: 360px) {
  .toast {
    left: 20px;
    right: 20px;
    min-width: auto;
    max-width: none;
  }

  /* Enhanced responsive countdown styles */
  .countdown-timer {
    font-size: 0.75rem !important;
    padding: 5px 6px !important;
    line-height: 1.2 !important;
    margin: 0 auto !important;
    max-width: 85% !important;
    min-width: 160px !important;
    /* Aggressive text wrapping for tiny screens */
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    text-align: center !important;
    border-radius: 3px !important;
  }

  .countdown-content {
    padding: 3px !important;
    gap: 4px !important;
  }

  .countdown-text {
    font-size: 0.7rem !important;
    line-height: 1.1 !important;
  }
}

/* Very small screens (280px and below) */
@media (max-width: 280px) {
  .countdown-timer {
    font-size: 0.7rem !important;
    padding: 4px 5px !important;
    line-height: 1.1 !important;
    margin: 0 auto !important;
    max-width: 80% !important;
    min-width: 140px !important;
    /* Maximum text flexibility for micro screens */
    white-space: normal !important;
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    text-align: center !important;
    border-radius: 2px !important;
  }

  .countdown-content {
    padding: 2px !important;
    gap: 2px !important;
  }

  .countdown-text {
    font-size: 0.65rem !important;
    line-height: 1 !important;
  }
}

/* Header countdown mobile specific fixes */
@media (max-width: 768px) {
  .header-countdown .countdown-timer {
    font-size: 0.8rem !important;
    padding: 6px 8px !important;
    max-width: none !important;
    min-width: auto !important;
    width: 100% !important;
  }

  .header-countdown .countdown-info {
    width: 100% !important;
    text-align: center !important;
  }

  .header-countdown .countdown-label {
    font-size: 0.75rem !important;
    line-height: 1.3 !important;
    white-space: normal !important;
    word-wrap: break-word !important;
  }
}

/* Landscape orientation fixes */
@media (max-width: 896px) and (orientation: landscape) {
  .countdown-timer {
    font-size: 0.8rem !important;
    padding: 4px 8px !important;
    line-height: 1.2 !important;
  }

  .countdown-content {
    padding: 3px !important;
    gap: 4px !important;
  }
}

/* iPhone SE and similar small screens */
@media (max-width: 375px) and (max-height: 667px) {
  .countdown-timer {
    font-size: 0.75rem !important;
    padding: 4px 6px !important;
    line-height: 1.1 !important;
    max-width: 90% !important;
    min-width: 150px !important;
  }
}

/* iPhone 12 mini and similar */
@media (max-width: 360px) and (max-height: 780px) {
  .countdown-timer {
    font-size: 0.7rem !important;
    padding: 3px 5px !important;
    line-height: 1.1 !important;
    max-width: 85% !important;
    min-width: 140px !important;
  }
}

/* Ensure parent containers don't constrain the countdown timer */
.countdown-component,
.countdown-content,
.header-countdown,
.countdown-info {
  overflow: visible !important;
  min-width: 0 !important;
  flex-shrink: 1 !important;
}

/* Remove any conflicting styles that might cause text wrapping issues */
.countdown-timer * {
  white-space: inherit !important;
  word-wrap: inherit !important;
  overflow-wrap: inherit !important;
}

.names-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  position: static !important; /* Remove stacking context */
  z-index: auto !important;
}
