:root {
  --primary: #C9F4FC;
  --primary-dark: #0056b3;
  --accent: #5fe0f7;
  --bg-light: #f8f9fa;
  --bg-dark: #343a40;
  --text-light: #ffffff;
  --text-dark: #212529;
  --hover-opacity: 0.9;
  --transition-speed: 0.3s;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Montserrat", sans-serif;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Loader overlay */
#loaderOverlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) ease;
}

#loaderOverlay.active {
  opacity: 1;
  pointer-events: all;
}

#loaderOverlay .spinner {
  border: 4px solid #ddd;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Main container */
#loginContainer {
  width: 100%;
  max-width: 900px;
  height: 600px;
  perspective: 1200px;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Flipper */
.flipper {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1s ease;
}

.front,
.back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  backface-visibility: hidden;
}

.front {
  transform: rotateY(0deg);
}

.back {
  transform: rotateY(180deg);
}

/* Sides */
.form-side,
.image-side {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Form Card */
.card-form {
  width: 100%;
  height: 100%;
  background: #fff;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 2;
  transition: box-shadow var(--transition-speed);
}

.card-form:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

.form-side h1,
.form-side h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-dark);
}

.input-group {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  background: var(--bg-light);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  width: 100%;
  transition: background var(--transition-speed);
}

.input-group:hover {
  background: #e9ecef;
}

.input-group:focus-within {
  background: #e2e6ea;
}

.input-group i {
  margin-right: 0.5rem;
  color: #6c757d;
}

.input-group input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 1rem;
}

/* Select2 Overrides */
.form-side .select2-container {
  width: 100% !important;
}

.form-side .select2-selection--single {
  height: auto;
  padding: 0.5rem;
  background: var(--bg-light);
  border: none;
  border-radius: 8px;
  transition: background var(--transition-speed);
}

.select2-selection--single:hover {
  background: #e9ecef;
}

/* Button Styles */
.btn-primary {
  background: var(--primary);
  color: var(--text-light);
  padding: 0.75rem;
  border: none;
  width: 100%;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-speed);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.toggle-button {
  margin-top: 1rem;
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
  transition: color var(--transition-speed);
}

.toggle-button:hover {
  color: var(--primary-dark);
}

.back-btn {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: transparent;
  border: none;
  color: var(--text-dark);
  font-size: 1rem;
  cursor: pointer;
  display: none;
  z-index: 3;
  transition: color var(--transition-speed);
}

.back-btn:hover {
  color: var(--primary);
}

/* Image Side */
.image-side {
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.image-side img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-style: preserve-3d;
  opacity: 0.85;
  transition: transform var(--transition-speed);
}

.image-side:hover img {
  transform: scale(1.05);
}

/* Responsive */
@media (max-width: 768px) {
  #loginContainer {
    height: auto;
  }

  .flipper {
    transform: none !important;
    transition: none;
  }

  .front,
  .back {
    position: relative;
    width: 100%;
    height: auto;
    display: none;
    flex-direction: column;
  }

  .front.active,
  .back.active {
    display: contents;
  }

  .image-side {
    width: 100%;
    height: 200px;
  }

  .card-form {
    padding: 1rem;
    justify-content: flex-start;
  }

  .form-side h1,
  .form-side h2 {
    font-size: 1.5rem;
  }

  .input-group {
    padding: 0.4rem 0.6rem;
  }

  .btn-primary {
    padding: 0.6rem;
    font-size: 0.9rem;
  }

  .back-btn {
    top: 0.5rem;
    left: 0.5rem;
    font-size: 0.9rem;
  }
}
