:root {
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #8b5cf6 50%, #764ba2 100%);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-lg: 0 12px 40px rgba(102,126,234,0.4);
  --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  background: linear-gradient(180deg, rgba(102,126,234,0.03) 0%, rgba(118,75,162,0.03) 100%);
  min-height: 100vh;
  position: relative;
}


body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(102,126,234,0.08) 0%, transparent 70%);
  animation: rotateBackground 30s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes rotateBackground {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


.page-title-section {
  background: var(--gradient-primary);
  padding: 3.5rem 0;
  border-radius: 0 0 32px 32px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.page-title-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 100%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
  animation: floatGlow 20s ease-in-out infinite;
}

@keyframes floatGlow {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-15%, 15%); }
}

.page-title-section .page-title {
  color: white;
  font-weight: 800;
  font-size: 2.8rem;
  text-shadow: 0 4px 16px rgba(0,0,0,0.25);
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
  animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.page-title-section .page-description {
  color: rgba(255,255,255,0.95);
  font-size: 1.15rem;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.section-padding {
  padding: 2.5rem 0 5rem 0;
  position: relative;
  z-index: 1;
}


.countries-header {
  background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.9) 100%);
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 2.5rem;
  box-shadow: 0 8px 32px rgba(102,126,234,0.15);
  backdrop-filter: blur(12px);
  border: 2px solid rgba(102,126,234,0.1);
  position: relative;
  overflow: hidden;
}

.countries-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(102,126,234,0.1), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.countries-header h3 {
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

#countries-counter {
  color: #6b7280;
  font-weight: 600;
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.1) 100%);
  border-radius: 12px;
  font-size: 0.9rem;
}


.search-wrapper {
  position: relative;
}

#country-search {
  border-radius: 16px;
  border: 2px solid rgba(102,126,234,0.2);
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  transition: var(--transition);
  background: rgba(255,255,255,0.9);
}

#country-search:focus {
  box-shadow: 0 0 0 4px rgba(102,126,234,0.15);
  border-color: #667eea;
  background: white;
  outline: none;
}

#country-search::placeholder {
  color: #94a3b8;
}

#country-search-btn {
  border-radius: 16px;
  padding: 0.875rem 1.5rem;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(102,126,234,0.3);
}

#country-search-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102,126,234,0.4);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

#country-search-btn i {
  font-size: 1.1rem;
}


#countries-grid {
  position: relative;
}


.country-card {
  background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.9) 100%);
  border: 2px solid rgba(102,126,234,0.12);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  transition: var(--transition);
  height: auto;
  position: relative;
  display: block;
  padding: 0.75rem;
  overflow: hidden;
  backdrop-filter: blur(8px);
}

.country-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(102,126,234,0.15), transparent);
  transition: left 0.6s ease;
}

.country-card:hover::before {
  left: 100%;
}

.country-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: rgba(102,126,234,0.4);
  box-shadow: 0 16px 48px rgba(102,126,234,0.25);
}

.country-flag-container {
  width: 100%;
  aspect-ratio: 4 / 3;
  position: relative;
  background: linear-gradient(135deg, rgba(102,126,234,0.05) 0%, rgba(118,75,162,0.05) 100%);
  overflow: hidden;
  border-radius: 14px;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1) inset;
}

.country-flag {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: var(--transition);
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.15));
}

.country-card:hover .country-flag {
  transform: scale(1.08);
}

.country-info { display: none; }

.country-caption { 
  min-height: 2.5rem;
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.country-name-link { 
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
  display: inline-block;
}

.country-name-link:hover {
  transform: translateY(-2px);
}

.country-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.3s ease;
  text-align: center;
}

.country-name-link:hover .country-name {
  color: #667eea;
}

.country-count {
  display: inline-block;
  margin-left: 0.35rem;
  color: #667eea;
  font-weight: 600;
  font-size: 0.85rem;
}

.country-count i {
  color: #667eea;
}

.stretched-link { position: static; }
.stretched-link::after { 
  position: absolute;
  inset: 0;
  content: "";
  z-index: 1;
}

/* Empty state */
.empty-state {
  padding: 5rem 2rem;
  text-align: center;
  background: linear-gradient(135deg, rgba(102,126,234,0.08) 0%, rgba(118,75,162,0.08) 100%);
  border: 2px dashed rgba(102,126,234,0.3);
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}

.empty-state::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 40% 50%, rgba(102,126,234,0.12) 0%, transparent 60%);
  animation: moveGradient 10s ease-in-out infinite;
}

@keyframes moveGradient {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(20%, 20%); }
}

.empty-state i {
  font-size: 5rem;
  color: #94a3b8;
  opacity: 0.5;
  animation: floatIcon 4s ease-in-out infinite;
  position: relative;
  z-index: 1;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

.empty-state h3 {
  font-weight: 700;
  color: #64748b;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.75rem;
  position: relative;
  z-index: 1;
}

.empty-state p {
  color: #94a3b8;
  font-size: 1.1rem;
  position: relative;
  z-index: 1;
}

/* Alert */
.alert-danger {
  border-radius: 16px;
  border: 2px solid rgba(239, 68, 68, 0.3);
  background: linear-gradient(135deg, rgba(254, 226, 226, 0.95) 0%, rgba(254, 226, 226, 0.85) 100%);
  backdrop-filter: blur(8px);
  padding: 1.25rem;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.2);
}


@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.country-card {
  animation: fadeInUp 0.6s ease-out backwards;
}

.col-6:nth-child(1) .country-card { animation-delay: 0.05s; }
.col-6:nth-child(2) .country-card { animation-delay: 0.1s; }
.col-6:nth-child(3) .country-card { animation-delay: 0.15s; }
.col-6:nth-child(4) .country-card { animation-delay: 0.2s; }
.col-6:nth-child(5) .country-card { animation-delay: 0.25s; }
.col-6:nth-child(6) .country-card { animation-delay: 0.3s; }
.col-6:nth-child(7) .country-card { animation-delay: 0.35s; }
.col-6:nth-child(8) .country-card { animation-delay: 0.4s; }
.col-6:nth-child(9) .country-card { animation-delay: 0.45s; }
.col-6:nth-child(10) .country-card { animation-delay: 0.5s; }
.col-6:nth-child(11) .country-card { animation-delay: 0.55s; }
.col-6:nth-child(12) .country-card { animation-delay: 0.6s; }
.col-6:nth-child(n+13) .country-card { animation-delay: 0.65s; }

@media (max-width: 991px) {
  .page-title-section .page-title {
    font-size: 2.3rem;
  }
  
  .countries-header {
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  body::before {
    animation: rotateBackground 40s linear infinite;
  }
  
  .page-title-section { 
    padding: 2.5rem 0;
    border-radius: 0 0 24px 24px;
  }
  
  .page-title-section .page-title {
    font-size: 2rem;
  }
  
  .page-title-section .page-description {
    font-size: 1rem;
  }
  
  .countries-header {
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 2rem;
  }
  
  .countries-header h3 {
    font-size: 1.25rem;
  }
  
  #countries-counter {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
  }
  
  #country-search {
    border-radius: 14px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }
  
  #country-search-btn {
    border-radius: 14px;
    padding: 0.75rem 1.25rem;
  }
  
  .country-card { 
    border-radius: 16px;
    padding: 0.6rem;
  }
  
  .country-flag-container {
    border-radius: 12px;
  }
  
  .country-name {
    font-size: 0.85rem;
  }
  
  .country-count {
    font-size: 0.75rem;
  }
  
  .empty-state {
    padding: 4rem 1.5rem;
    border-radius: 20px;
  }
  
  .empty-state i {
    font-size: 4rem;
  }
  
  .empty-state h3 {
    font-size: 1.5rem;
  }
  
  .empty-state p {
    font-size: 1rem;
  }
}

@media (max-width: 576px) {
  .page-title-section .page-title {
    font-size: 1.75rem;
  }
  
  .countries-header h3 {
    font-size: 1.1rem;
    text-align: center;
  }
  
  #countries-counter {
    display: block;
    margin-top: 0.5rem;
    text-align: center;
  }
}