/* CSS Variables representing Shadcn UI Light Mode Theme */
:root {
  --background: 240 10% 98%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
}

/* Reset and Global Styles */
html {
  font-size: 18px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--card-foreground));
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Premium Visual Elements */
.bg-grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-size: 32px 32px;
  background-image:
    linear-gradient(to right, hsla(240, 5.9%, 10%, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, hsla(240, 5.9%, 10%, 0.03) 1px, transparent 1px);
  mask-image: radial-gradient(circle at center, black 40%, transparent 80%);
  -webkit-mask-image: radial-gradient(circle at center, black 40%, transparent 80%);
  pointer-events: none;
}

.radial-glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(circle at center, hsla(240, 5.9%, 92%, 0.6) 0%, transparent 70%);
  pointer-events: none;
}

/* Layout container */
.container {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 1.5rem;
}

/* Card - Standard Shadcn styling with premium animations */
.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 4px 12px -1px rgba(0, 0, 0, 0.03), 0 2px 4px -1px rgba(0, 0, 0, 0.02), 0 20px 25px -5px rgba(0, 0, 0, 0.02);
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 400px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

.card:hover {
  border-color: hsla(240, 5.9%, 80%, 1);
  box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.06), 0 4px 12px -2px rgba(0, 0, 0, 0.03), 0 30px 40px -10px rgba(0, 0, 0, 0.04);
}

/* Card Header */
.card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 2rem;
}

.logo-wrapper {
  background-color: hsl(var(--secondary));
  color: hsl(var(--primary));
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.25rem;
  border: 1px solid hsl(var(--border));
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
}

.card:hover .logo-wrapper {
  transform: scale(1.06) rotate(6deg);
}

.logo-icon {
  width: 1.375rem;
  height: 1.375rem;
  stroke-width: 2.25px;
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.card-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: 0.375rem;
  color: hsl(var(--primary));
}

.card-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.4;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--primary));
  text-align: left;
}

.input-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
}

.form-input {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.625rem 0.875rem;
  background-color: transparent;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  color: hsl(var(--card-foreground));
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.form-input::placeholder {
  color: hsl(var(--muted-foreground));
  opacity: 0.7;
}

.form-input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsla(240, 5.9%, 10%, 0.08);
}

/* Input Validation Error */
.form-input.is-invalid {
  border-color: hsl(var(--destructive));
}

.form-input.is-invalid:focus {
  box-shadow: 0 0 0 2px hsla(0, 84.2%, 60.2%, 0.15);
}

.error-message {
  font-size: 0.75rem;
  color: hsl(var(--destructive));
  margin-top: 0.375rem;
  display: none;
  text-align: left;
  animation: fadeIn 0.15s ease forwards;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  gap: 0.5rem;
  height: 2.5rem;
}

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  margin-top: 0.5rem;
}

.btn-primary:hover {
  background-color: hsla(240, 5.9%, 10%, 0.9);
}

.btn-primary:active {
  transform: scale(0.985);
}

.btn-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid hsl(var(--border));
}

.btn-secondary:hover {
  background-color: hsla(240, 4.8%, 92%, 1);
}

.btn-secondary:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Spinner for Loading State */
.spinner {
  width: 1.125rem;
  height: 1.125rem;
  animation: rotate 1s linear infinite;
  flex-shrink: 0;
}

.spinner .path {
  stroke: currentColor;
  stroke-linecap: round;
  animation: dash 1.5s ease-in-out infinite;
}

.hidden {
  display: none !important;
}

/* Lobby Card & Success Layout */
.lobby-details {
  background-color: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.125rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: fadeIn 0.4s ease forwards;
}

.lobby-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.lobby-label {
  color: hsl(var(--muted-foreground));
}

.lobby-value {
  font-weight: 500;
  color: hsl(var(--card-foreground));
  word-break: break-all;
  max-width: 180px;
  text-align: right;
}

.lobby-value.badge {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  padding: 0.175rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.success-badge {
  background-color: hsla(142.1, 76.2%, 36.3%, 0.1) !important;
  color: hsl(142.1, 76.2%, 36.3%) !important;
  border-color: hsla(142.1, 76.2%, 36.3%, 0.2) !important;
}

.progress-bar-container {
  background-color: hsl(var(--secondary));
  height: 6px;
  width: 100%;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.progress-bar {
  background-color: hsl(142.1, 76.2%, 36.3%);
  height: 100%;
  width: 0%;
  transition: width 2.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 100;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.875rem 1.125rem;
  min-width: 320px;
  max-width: 420px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.03), 0 4px 6px -2px rgba(0, 0, 0, 0.02), 0 20px 25px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transform: translateY(100px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  opacity: 0;
}

.toast.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast-icon {
  margin-top: 0.125rem;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}

.toast-success .toast-icon {
  color: hsl(142.1, 76.2%, 36.3%);
}

.toast-error .toast-icon {
  color: hsl(var(--destructive));
}

.toast-content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.toast-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--primary));
}

.toast-description {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.35;
}

/* Animations declarations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

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

@keyframes dash {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }

  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -124;
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-5px);
  }

  40%,
  80% {
    transform: translateX(5px);
  }
}

.shake {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.fade-out {
  animation: fadeOut 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Responsive adjust */
@media (max-width: 480px) {
  .card {
    padding: 1.75rem 1.5rem;
  }

  .toast-container {
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}