:root {
  --nodenest-dark-teal: #0D5C63;
  --nodenest-light-teal: #248277;
  --background-primary: #FFFFFF;
  --background-secondary: #fdfdff;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --border-color: #E5E7EB;
  --input-focus-shadow: rgba(36, 130, 119, 0.15);
  --error-text: #D9534F;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  display: grid;
  place-items: center;
  min-height: 100vh; /* Fallback för äldre webbläsare */
  min-height: 100dvh; /* Använder hela dynamiska skärmhöjden */
  margin: 0;
  padding: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.site-background {
  position: relative;
  background-color: var(--background-secondary);
  overflow: hidden;
  isolation: isolate;
}
.site-background::before {
  content: "";
  position: absolute;
  inset: -25%;
  background:
      radial-gradient(38% 34% at 30% 40%, rgba(0,211,127,0.06) 0%, transparent 60%),
      radial-gradient(34% 30% at 70% 60%, rgba(36, 130, 119, 0.05) 0%, transparent 60%);
  filter: blur(6px);
  animation: haloParallax 50s ease-in-out infinite alternate;
  z-index: -2;
}
.site-background::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
      linear-gradient(rgba(0,0,0,0.035) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0,0,0,0.035) 1px, transparent 1px),
      radial-gradient(circle 1px, rgba(0,211,127,0.25) 98%, transparent 100%);
  background-size: 44px 44px, 44px 44px, 44px 44px;
  background-position: 0 0, 0 0, 0 0;
  mix-blend-mode: multiply;
  animation: gridDrift 60s linear infinite;
}

.main-container {
  width: 100%;
  max-width: 450px;
  position: relative;
  height: 600px;
}

.content-wrapper {
  background: var(--background-primary);
  padding: clamp(2rem, 6vw, 3rem);
  border-radius: 24px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -4px rgba(0,0,0,0.05);
  border: 1px solid var(--border-color);
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  transform: scale(0.98);
}
.content-wrapper.active {
  display: flex;
  opacity: 1;
  transform: scale(1);
}

.form-header {
  text-align: center;
  margin-bottom: clamp(1.5rem, 5vw, 2.5rem);
}
.logo {
  width: clamp(100px, 25vw, 130px);
  margin-bottom: clamp(1.5rem, 4vw, 2rem);
  height: auto;
}
h1 {
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}
.subtitle {
  color: var(--text-secondary);
  margin: 0;
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  line-height: 1.5;
}

.form-body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.form-content {
  flex-grow: 1;
}

.input-group {
  margin-bottom: 1.5rem;
}
label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s ease;
}
input:focus {
  outline: none;
  border-color: var(--nodenest-dark-teal);
  box-shadow: 0 0 0 3px var(--input-focus-shadow);
}
.subdomain-container {
  display: flex;
}
.subdomain-container input {
  border-right: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  text-align: right;
  flex-grow: 1;
}
.subdomain-suffix {
  display: grid;
  place-items: center;
  padding: 0 1rem;
  background-color: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  white-space: nowrap;
}
.error-message {
  color: var(--error-text);
  font-size: 0.85rem;
  padding-top: 0.5rem;
  min-height: 1.5rem;
}

.spacer-fields {
  min-height: 138px; /* Höjd för två input-grupper + marginal */
}

button {
  width: 100%;
  padding: 1rem;
  background-color: var(--nodenest-dark-teal);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: auto;
}
button:hover:not(:disabled) {
  background-color: var(--nodenest-light-teal);
  transform: translateY(-2px);
}
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { background-color: #a0c2bf; cursor: not-allowed; }

/* --- Laddningsvy & Felvy --- */
.loading-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 100%;
  height: 100%;
}
#loading-container.error .loading-logo-wrapper { border-color: var(--error-text); }
.loading-logo-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 2rem;
}
.loading-logo {
  width: 70px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.spinner-ring {
  width: 100%;
  height: 100%;
  border: 4px solid var(--nodenest-light-teal);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1.5s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.loading-text-wrapper {
  display: none; /* Inte längre nödvändig, vi använder direkt #loading-text */
}
#loading-text {
  font-size: clamp(1.1rem, 4vw, 1.25rem);
  font-weight: 500;
  color: var(--text-primary);
  min-height: 3em; /* Ger plats för 2 rader text utan att layouten hoppar */
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  transition: opacity 0.3s ease;
}
.progress-bar-container {
  height: 8px;
  width: 100%;
  max-width: 300px;
  background-color: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--nodenest-light-teal), var(--nodenest-dark-teal));
  border-radius: 4px;
  transition: width 1s cubic-bezier(0.65, 0, 0.35, 1);
}
.loading-info-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.error-display {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1rem;
}
.error-display strong {
  font-size: 1.1rem;
  color: var(--error-text);
}
.error-display p {
  color: var(--text-secondary);
  margin: 0.5rem 0 1.5rem 0;
}
.error-display button {
  max-width: 200px;
}

/* --- Bakgrundsanimationer --- */
@keyframes haloParallax {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-2%, 2%); }
}
@keyframes gridDrift {
  0% { background-position: 0 0, 0 0, 0 0; }
  100% { background-position: 44px 22px, 22px 44px, 22px 22px; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .site-background::before, .site-background::after, .spinner-ring {
      animation: none !important;
  }
}
