@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-dark: #020617;
  --bg-card: rgba(15, 23, 42, 0.6);
  --primary: #8b5cf6;
  --primary-glow: rgba(139, 92, 246, 0.5);
  --secondary: #0ea5e9;
  --accent: #f43f5e;
  --text-main: #f8fafc;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.03);
  --radius: 28px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 0% 0%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(14, 165, 233, 0.05) 0%, transparent 50%);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.app-container {
  display: block;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem 4rem;
}

/* Common Components */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-main);
}

.section-title .step-num {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 10px 20px -5px var(--primary-glow);
}

.input-group {
  margin-bottom: 1.5rem;
}

.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.075rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

/* Country List Grid */
#country-list-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 1.5rem;
  max-height: 280px;
  overflow-y: auto;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 28px;
  border: 1px solid var(--border);
}

.country-item {
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: var(--transition);
}

.country-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  transform: scale(1.02);
}

.country-item.selected {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(14, 165, 233, 0.2));
  border-color: var(--primary);
  box-shadow: inset 0 0 20px rgba(139, 92, 246, 0.1);
}

.country-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.country-code {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Distribution List */
.selected-country-row {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1.5rem;
  transition: var(--transition);
}

.selected-country-row:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
}

/* Buttons */
button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  padding: 1rem 2rem;
  box-shadow: 0 10px 25px -5px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px -5px var(--primary-glow);
}

.preset-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: var(--text-muted);
}

.preset-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 20px var(--primary-glow);
}

.btn-clear {
  background: rgba(244, 63, 94, 0.1) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(244, 63, 94, 0.2) !important;
  margin-left: auto;
}

.btn-clear:hover {
  background: var(--accent) !important;
  color: white !important;
  border-color: var(--accent) !important;
}

/* Total Badge */
#total-count-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: 100px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#total-count-display {
  color: var(--secondary);
  font-weight: 800;
  font-size: 1.1rem;
}

/* Sidebar Overlay */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(8px);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
  visibility: visible;
}

.sidebar.hidden {
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(0px);
  display: flex !important;
  pointer-events: none;
}

.sidebar .card {
  width: 100%;
  max-width: 1100px;
  height: 80vh;
  background: #0f172a;
  border-color: var(--primary);
  box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.8);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  transform: scale(1) translateY(0);
}

.sidebar.hidden .card {
  transform: scale(0.9) translateY(30px);
}

/* Json Preview */
#json-preview {
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

.animate-in {
  animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}
