/* Basic Reset & Variables */
:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --primary: #18181b;
  --primary-foreground: #fafafa;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
    "Noto Color Emoji";
  line-height: 1.5;
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding: 2rem 1rem; /* py-8 px-4 */
}

/* Titles */
.title {
  font-size: 1.875rem; /* text-3xl */
  line-height: 2.25rem;
  font-weight: 700; /* font-bold */
  margin-bottom: 2rem;
  text-align: center;
}

/* Search Input & Dropdown Container */
.search-container {
  position: relative; /* Needed for absolute positioning of dropdown */
  /* max-width: 28rem; max-w-md */
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 2rem;
}

.search-icon {
  position: absolute;
  left: 0.75rem; /* left-3 */
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  height: 1rem; /* h-4 */
  width: 1rem; /* w-4 */
  z-index: 10; /* Ensure icon is above input */
}

.input-field {
  display: flex;
  height: 2.5rem; /* h-10 */
  width: 100%;
  border-radius: 0.375rem; /* rounded-md */
  border: 1px solid var(--input);
  background-color: var(--background);
  padding: 0.5rem 0.75rem; /* px-3 py-2 */
  padding-left: 2.5rem; /* pl-10 */
  font-size: 0.875rem; /* text-sm */
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(24, 24, 27, 0.2); /* ring-2 ring-ring */
}

/* Country Dropdown */
.country-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem); /* Position below the input with some space */
  left: 0;
  width: 100%;
  max-height: 20rem; /* Limit height and enable scrolling */
  overflow-y: auto;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 100; /* Ensure it's on top of other content */
}

.dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.dropdown-item:hover {
  background-color: var(--muted);
}

.dropdown-item img {
  width: 2rem; /* Small flag size */
  height: 1.5rem;
  object-fit: cover;
  margin-right: 0.75rem;
  border: 1px solid var(--border); /* Small border for flags */
}

.dropdown-item span {
  font-size: 0.875rem;
  color: var(--foreground);
}

/* Country Grid */
.country-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1.5rem; /* gap-6 */
}

@media (min-width: 640px) {
  /* sm */
  .country-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  /* md */
  .country-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  /* lg */
  .country-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Country Card */
.country-card {
  border-radius: 0.5rem; /* rounded-lg */
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--card-foreground);
  overflow: hidden;
  height: 100%;
  cursor: pointer;
  transition: box-shadow 0.3s ease-in-out;
}

.country-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* hover:shadow-lg */
}

.country-flag-container {
  position: relative;
  height: 10rem; /* h-40 */
  width: 100%;
}

.country-flag-container img {
  object-fit: cover;
  width: 100%;
  height: 100%;
  display: block;
}

.country-info {
  padding: 1rem; /* p-4 */
}

.country-info h2 {
  font-weight: 700; /* font-bold */
  font-size: 1.125rem; /* text-lg */
  line-height: 1.75rem;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* line-clamp-1 equivalent */
}

.country-info p {
  font-size: 0.875rem; /* text-sm */
  line-height: 1.25rem;
  color: var(--muted-foreground);
  margin-bottom: 0.25rem; /* mb-1 */
}

.country-info p:last-child {
  margin-bottom: 0;
}

.country-info p span {
  font-weight: 500; /* font-medium */
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem; /* rounded-md */
  font-size: 0.875rem; /* text-sm */
  font-weight: 500; /* font-medium */
  padding: 0.5rem 1rem; /* px-4 py-2 */
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  outline: none;
}

.button .icon-left {
  margin-right: 0.5rem; /* mr-2 */
  height: 1rem; /* h-4 */
  width: 1rem; /* w-4 */
}

.ghost-button {
  background-color: transparent;
  border: none;
  color: var(--foreground);
  padding: 0.5rem 0.75rem; /* px-3 py-2 */
  margin-bottom: 2rem; /* mb-8 */
}

.ghost-button:hover {
  background-color: var(--muted);
}

.outline-button {
  border: 1px solid var(--border);
  background-color: transparent;
  color: var(--foreground);
  padding: 0.25rem 0.75rem; /* px-3 py-1.5 for size="sm" */
  font-size: 0.875rem; /* text-sm */
  line-height: 1.25rem;
}

.outline-button:hover {
  background-color: var(--muted);
}

/* Country Detail View */
.detail-content {
  display: grid;
  gap: 3rem; /* gap-12 */
}

@media (min-width: 768px) {
  /* md */
  .detail-content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.detail-flag-container {
  position: relative;
  height: 20rem; /* h-80 */
  width: 100%;
}

.detail-flag-container img {
  object-fit: contain;
  width: 100%;
  height: 100%;
  display: block;
}

.detail-info h1 {
  font-size: 1.875rem; /* text-3xl */
  line-height: 2.25rem;
  font-weight: 700; /* font-bold */
  margin-bottom: 2rem; /* mb-8 */
}

.detail-grid {
  display: grid;
  gap: 2rem; /* gap-8 */
}

@media (min-width: 768px) {
  /* md */
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.detail-info p {
  margin-bottom: 0.5rem; /* mb-2 */
}

.detail-info p span {
  font-weight: 600; /* font-semibold */
}

.border-countries-section {
  margin-top: 2rem; /* mt-8 */
}

.border-countries-section h3 {
  font-size: 1.25rem; /* text-xl */
  line-height: 1.75rem;
  font-weight: 600; /* font-semibold */
  margin-bottom: 1rem; /* mb-4 */
}

.border-buttons-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem; /* gap-2 */
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-red-500 {
  color: #ef4444;
}

.text-gray-600 {
  color: #52525b;
}

/* Skeleton Loaders */
.skeleton-card {
  border: 1px solid var(--border);
  background-color: var(--card);
  border-radius: 0.5rem;
  overflow: hidden;
  height: 100%;
  cursor: default;
  box-shadow: none;
}

.skeleton-flag {
  height: 10rem;
  width: 100%;
  background-color: var(--muted);
  animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-text {
  height: 1rem;
  background-color: var(--muted);
  border-radius: 0.25rem;
  margin-bottom: 0.5rem;
  animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-text-lg {
  height: 1.5rem;
  width: 75%;
  margin-bottom: 0.75rem;
}

.skeleton-text-sm {
  height: 1rem;
  width: 50%;
  margin-bottom: 0.25rem;
}

.skeleton-detail-content {
  display: grid;
  gap: 3rem;
}

@media (min-width: 768px) {
  .skeleton-detail-content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.skeleton-detail-flag {
  height: 20rem;
  width: 100%;
  background-color: var(--muted);
  animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-title {
  height: 2.5rem;
  width: 75%;
  margin-bottom: 2rem;
}

.skeleton-button {
  height: 2.5rem;
  width: 6rem;
  background-color: var(--muted);
  border-radius: 0.375rem;
  animation: pulse 1.5s infinite ease-in-out;
  margin-bottom: 2rem;
}

.skeleton-border-section {
  margin-top: 2rem;
}

.skeleton-border-section .skeleton-text {
  height: 1.5rem;
  width: 50%;
  margin-bottom: 1rem;
}

.skeleton-border-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.skeleton-border-buttons .skeleton-button {
  height: 2rem;
  width: 6rem;
  margin-bottom: 0;
}

@keyframes pulse {
  0% {
    background-color: var(--muted);
  }
  50% {
    background-color: var(--border);
  }
  100% {
    background-color: var(--muted);
  }
}
