@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-main: #1d2127;
  --bg-top: #21252b;

  --panel: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.13);

  --text-main: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.76);

  --pink: #f1c6d1;
  --pink-hover: #f6d3dc;

  --button-glass-top: rgba(255, 255, 255, 0.14);
  --button-glass-bottom: rgba(255, 255, 255, 0.07);
  --button-glass-hover-top: rgba(255, 255, 255, 0.18);
  --button-glass-hover-bottom: rgba(255, 255, 255, 0.1);

  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 10px 24px rgba(0, 0, 0, 0.22);
  --shadow-sm: 0 6px 14px rgba(0, 0, 0, 0.15);

  --radius-xl: 30px;
  --radius-pill: 999px;

  --page-width: 1600px;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Inter", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(77, 90, 109, 0.22), transparent 24%),
    radial-gradient(circle at top right, rgba(76, 93, 118, 0.12), transparent 20%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-main) 100%);
  line-height: 1.5;
  overflow: hidden;
}

.page-shell {
  width: min(100%, var(--page-width));
  height: 100vh;
  margin: 0 auto;
  padding: 0.7rem 1rem 4.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.top-panel {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  flex: 0 0 auto;
}

.user-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.user-select-form,
.delete-user-form,
.add-user-form,
.country-form {
  margin: 0;
}

.country-form input[type="text"] {
  flex: 1 1 320px;
  min-width: 220px;
  height: 48px;
  padding: 0 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.11),
      rgba(255, 255, 255, 0.07));
  color: var(--text-main);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}

.country-form input.country-input.error {
  border-color: rgba(255, 98, 98, 0.75);
  color: #ffb0b0;
  background: linear-gradient(90deg,
      rgba(255, 98, 98, 0.14),
      rgba(255, 98, 98, 0.08));
}

.country-form input.country-input.error::placeholder {
  color: #ff8d8d;
  opacity: 1;
}

button {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font: inherit;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
  box-shadow: var(--shadow-md);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.user-pill {
  min-height: 44px;
  padding: 0 0.95rem;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow-sm);
  font-size: 0.94rem;
}

.delete-user-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(180deg,
      var(--button-glass-top) 0%,
      var(--button-glass-bottom) 100%);
  color: #ffffff;
  font-size: 1.1rem;
  line-height: 1;
}

.delete-user-btn:hover {
  background: linear-gradient(180deg,
      var(--button-glass-hover-top) 0%,
      var(--button-glass-hover-bottom) 100%);
}

.add-user-btn {
  min-height: 44px;
  padding: 0 1rem;
  min-width: 170px;
  background: linear-gradient(180deg,
      var(--button-glass-top) 0%,
      var(--button-glass-bottom) 100%);
  color: #ffffff;
  font-size: 0.94rem;
}

.add-user-btn:hover {
  background: linear-gradient(180deg,
      var(--button-glass-hover-top) 0%,
      var(--button-glass-hover-bottom) 100%);
}

/* COUNTRY ROW: input + add + delete all on one line */
.country-form {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  width: 100%;
  max-width: 760px;
}

.country-form input[type="text"] {
  flex: 1 1 320px;
  min-width: 220px;
  height: 48px;
  padding: 0 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.11),
      rgba(255, 255, 255, 0.07));
  color: var(--text-main);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

.country-form input[type="text"]::placeholder {
  color: rgba(255, 255, 255, 0.48);
}

.country-form input[type="text"]:focus {
  border-color: rgba(255, 255, 255, 0.24);
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.14),
      rgba(255, 255, 255, 0.09));
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 0 0 auto;
}

.action-buttons button {
  min-height: 44px;
  min-width: 86px;
  padding: 0 0.95rem;
  font-size: 0.93rem;
}

.action-buttons button:first-child {
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.action-buttons button:last-child {
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.18) 0%,
      rgba(255, 255, 255, 0.1) 100%) !important;
  color: #ffffff;
}

.action-buttons button:last-child:hover {
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.22) 0%,
      rgba(255, 255, 255, 0.13) 100%) !important;
}

.map-section {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
}

.ag-canvas {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1rem 1.15rem 1.1rem;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg,
      rgba(255, 255, 255, 0.07),
      rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ag-canvas_svg {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
}

/* restore visible country borders */
.ag-canvas_svg path {
  fill: #0a0c0f;
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 0.85;
  transition: fill 0.2s ease, opacity 0.2s ease, stroke 0.2s ease;
}

.total-count {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.13),
      rgba(255, 255, 255, 0.07));
  color: var(--text-main);
  font-size: 0.94rem;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .page-shell {
    height: auto;
    min-height: 100vh;
    padding: 0.75rem 0.85rem 5rem;
  }

  .country-form {
    max-width: 100%;
  }

  .country-form input[type="text"] {
    flex: 1 1 100%;
    min-width: 0;
  }

  .action-buttons {
    width: 100%;
  }

  .action-buttons button {
    flex: 1 1 0;
  }

  .map-section {
    min-height: 0;
  }

  .ag-canvas {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .user-list {
    gap: 0.5rem;
  }

  .user-pill {
    min-height: 42px;
    padding: 0 0.9rem;
    font-size: 0.92rem;
  }

  .delete-user-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }

  .add-user-form {
    width: 100%;
  }

  .add-user-btn {
    width: 100%;
    min-width: unset;
    min-height: 44px;
  }

  .country-form {
    gap: 0.55rem;
  }

  .country-form input[type="text"] {
    height: 46px;
    font-size: 0.94rem;
  }

  .action-buttons button {
    min-height: 42px;
    min-width: 0;
    font-size: 0.9rem;
  }

  .ag-canvas {
    padding: 0.8rem;
    border-radius: 24px;
    min-height: 360px;
  }

  .total-count {
    left: 0.8rem;
    right: 0.8rem;
    bottom: 0.8rem;
  }
}