/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header styles */
.header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 2rem 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #4a5568;
  text-align: center;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.title i {
  color: #667eea;
  font-size: 2rem;
}

.subtitle {
  text-align: center;
  color: #718096;
  font-size: 1.1rem;
  font-weight: 300;
}

/* Main content */
.main {
  padding: 2rem 0;
}

/* Stats bar */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.stat-item {
  background: rgba(255, 255, 255, 0.9);
  padding: 1.5rem 2rem;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  text-align: center;
  min-width: 200px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
}

.stat-item i {
  font-size: 2rem;
  color: #667eea;
  margin-bottom: 0.5rem;
  display: block;
}

.stat-item span:first-of-type {
  font-size: 2rem;
  font-weight: 700;
  color: #4a5568;
  display: block;
}

.stat-item span:last-of-type {
  font-size: 0.9rem;
  color: #718096;
  font-weight: 500;
}

/* Search and filter container */
.search-container {
  margin-bottom: 3rem;
}

.search-box {
  position: relative;
  max-width: 500px;
  margin: 0 auto 2rem;
}

.search-box i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #718096;
  font-size: 1.2rem;
}

#search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border: none;
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

#search-input:focus {
  outline: none;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
  background: white;
}

.filter-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.8);
  color: #4a5568;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.filter-btn.active {
  background: #667eea;
  color: white;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  border: 2px solid #000;
  border-radius: 25px;
}

/* Countries grid */
.countries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  padding: 1rem 0;
}

.countries {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transition: all 0.4s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.countries::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.countries:hover::before {
  transform: scaleX(1);
}

.countries:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.countries img {
  width: 100%;
  max-width: 200px;
  height: 120px;
  object-fit: cover;
  border-radius: 15px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.countries:hover img {
  transform: scale(1.05);
}

.name {
  font-size: 1.3rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.country-details {
  width: 100%;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: all 0.4s ease;
  background: rgba(102, 126, 234, 0.05);
  border-radius: 10px;
  padding: 0;
}

.countries:hover .country-details {
  opacity: 1;
  max-height: 200px;
  padding: 1rem;
  margin-top: 1rem;
}

.country-details p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: #718096;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.country-details p strong {
  color: #4a5568;
  font-weight: 600;
}

/* Float container (modal) */
.float-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.float-container.show {
  display: flex;
  opacity: 1;
}

.float {
  background: white;
  border-radius: 20px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.7);
  transition: transform 0.3s ease;
}

.float-container.show .float {
  transform: scale(1);
}

.float-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.float-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background 0.3s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.float-content {
  padding: 2rem;
  max-height: 60vh;
  overflow-y: auto;
}

/* Footer */
.footer {
  background: rgba(255, 255, 255, 0.9);
  padding: 2rem 0;
  text-align: center;
  margin-top: 3rem;
}

.footer p {
  color: #718096;
  font-size: 0.9rem;
}

/* Responsive design */
@media (max-width: 768px) {
  .title {
    font-size: 2rem;
  }
  
  .stats-bar {
    gap: 1rem;
  }
  
  .stat-item {
    min-width: 150px;
    padding: 1rem 1.5rem;
  }
  
  .countries-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
  }
  
  .filter-buttons {
    gap: 0.5rem;
  }
  
  .filter-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 15px;
  }
  
  .title {
    font-size: 1.5rem;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .countries-grid {
    grid-template-columns: 1fr;
  }
  
  .float {
    width: 95%;
    margin: 1rem;
  }
}

/* Loading animation */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 3rem;
}

.loading::after {
  content: '';
  width: 50px;
  height: 50px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Mejoras adicionales para funcionalidad */
.stat-item {
  cursor: pointer;
  transition: all 0.3s ease;
}

.stat-item:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

/* Mejorar botones de filtro */
.filter-btn {
  position: relative;
  overflow: hidden;
}

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

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

/* Asegurar que los elementos sean clickeables */
.countries {
  cursor: pointer;
  user-select: none;
}

.countries:active {
  transform: translateY(-5px) scale(0.98);
}

/* Mejorar accesibilidad */
.filter-btn:focus,
.search-box input:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}