/* ===========================
   RESET & VARIABLES
=========================== */

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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

  --secondary: #06b6d4;
  --secondary-dark: #0891b2;

  --bg-main: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  --bg-panel: rgba(255, 255, 255, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.1);
  --bg-overlay: rgba(0, 0, 0, 0.05);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border-soft: #e2e8f0;
  --border-focus: #6366f1;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);

  --radius-xl: 24px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-main: 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-bounce: 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Enhanced bounce keyframes for desktop form transitions */
@keyframes slideInFromRight {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }
  60% {
    transform: translateX(-3%);
    opacity: 0.9;
  }
  80% {
    transform: translateX(1%);
    opacity: 0.95;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutToLeft {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  40% {
    transform: translateX(-5%);
    opacity: 0.8;
  }
  100% {
    transform: translateX(-100%);
    opacity: 0;
  }
}

@keyframes slideInFromLeft {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  60% {
    transform: translateX(3%);
    opacity: 0.9;
  }
  80% {
    transform: translateX(-1%);
    opacity: 0.95;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutToRight {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  40% {
    transform: translateX(5%);
    opacity: 0.8;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ===========================
   GLOBAL
=========================== */

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   AUTH WRAPPER
=========================== */

.auth-wrapper {
  width: 100%;
  max-width: 1180px;
  height: 100vh;
  padding: 20px;
}

.auth-container {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ===========================
   PANELS
=========================== */

.auth-panel {
  width: 50%;
  height: 100%;
  position: relative;
  transition: transform var(--transition-main);
}

/* Desktop animations - form slide transitions */
@media (min-width: 769px) {
  .auth-form {
    transition: none; /* Remove transition for custom animations */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /* Override default display for animations */
  .login-form,
  .register-form {
    display: flex;
  }

  /* Login → Register: Form slides right out, Visual slides left in */
  /* Login → Register: Login form slides left out, Register form slides left in */
  .auth-wrapper.is-register .login-form {
    animation: slideOutToLeft 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  .auth-wrapper.is-register .register-form {
    animation: slideInFromRight 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94)
      forwards;
  }

  /* Register → Login: Register form slides right out, Login form slides right in */
  .auth-wrapper.is-login .register-form {
    animation: slideOutToRight 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94)
      forwards;
  }

  .auth-wrapper.is-login .login-form {
    animation: slideInFromLeft 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94)
      forwards;
  }
}

/* FORM PANEL */
.auth-panel--form {
  padding: 60px;
  position: relative;
  z-index: 2;
}

/* VISUAL PANEL */
.auth-panel--visual {
  background: var(--primary-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  z-index: 1;
  position: relative;
  overflow: hidden;
}

.auth-panel--visual::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,255,255,0.05)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.3;
}

/* ===========================
   VISUAL CONTENT
=========================== */

.visual-content {
  max-width: 360px;
  text-align: left;
}

.visual-content h2 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 16px;
}

.visual-content p {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 40px;
  line-height: 1.6;
}

.visual-content img {
  width: 100%;
  max-width: 320px;
}

/* ===========================
   LOGO
=========================== */

.auth-logo {
  position: absolute;
  top: 40px;
  left: 80%;
}

.auth-logo img {
  height: 42px;
}

/* ===========================
   FORMS
=========================== */

.auth-form {
  max-width: 360px;
  width: 100%;
  transition: opacity var(--transition-main), transform var(--transition-main);
}

.auth-form h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 32px;
  font-weight: 400;
}

.form-row {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
}

.form-group.half {
  flex: 1;
  margin-bottom: 0;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-group input {
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-soft);
  font-size: 16px;
  font-weight: 400;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all var(--transition-fast);
  color: var(--text-main);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 4px var(--primary-light), var(--shadow-md);
  transform: translateY(-1px);
}

.form-group input:hover {
  border-color: var(--text-light);
}

.form-group input::placeholder {
  color: var(--text-light);
  font-weight: 400;
}

/* PASSWORD */
.password-wrapper {
  position: relative;
}

.password-wrapper i {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.password-wrapper i:hover {
  color: var(--primary);
  background: var(--primary-light);
}

/* ===========================
   BUTTONS
=========================== */

.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  opacity: 0.8;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled::before {
  display: none;
}

/* Loading spinner */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.btn-primary.loading {
  position: relative;
  color: transparent;
}

.btn-primary.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

/* ===========================
   LINKS & SWITCH
=========================== */

.auth-links {
  margin-top: 16px;
}

.auth-links a {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
}

.switch-auth {
  margin-top: 30px;
  font-size: 14px;
  color: var(--text-muted);
}

.switch-auth span {
  margin-right: 6px;
}

/* ===========================
   MESSAGES
=========================== */

.auth-message {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 20px;
}

.auth-message.error {
  background: #fdecea;
  color: #b91c1c;
}

.auth-message.info {
  background: #e0f2fe;
  color: #0369a1;
}

.auth-message.success {
  background: #d1edff;
  color: #0c4a6e;
}

/* ===========================
   LOGIN / REGISTER STATES
=========================== */

/* Default = LOGIN */
.register-form {
  display: none;
}

/* REGISTER MODE */
.auth-wrapper.is-register .login-form {
  display: none;
}

.auth-wrapper.is-register .register-form {
  display: block;
}

/* Panel swap animation */
.auth-wrapper.is-register .auth-panel--form {
  transform: translateX(100%);
}

.auth-wrapper.is-register .auth-panel--visual {
  transform: translateX(-100%);
}

/* ===========================
   MOBILE RESPONSIVE
   =========================== */

@media (max-width: 768px) {
  .auth-wrapper {
    height: auto;
    min-height: 100vh;
    padding: 10px;
  }

  .auth-container {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    border-radius: var(--radius-md);
    justify-content: center;
    padding: 20px;
  }

  .auth-panel {
    width: 100%;
    height: auto;
    position: static;
    transform: none !important;
  }

  .auth-panel--form {
    padding: 40px 20px;
    order: 1;
  }

  .auth-panel--visual {
    display: none; /* Hide visual panel on mobile */
  }

  .auth-logo {
    position: static;
    top: auto;
    left: auto;
    margin-bottom: 20px;
    text-align: center;
  }

  .auth-form {
    max-width: none;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-group.half {
    margin-bottom: 20px;
  }

  /* Mobile transitions - slide with bounce */
  .auth-wrapper.is-login .register-form {
    animation: slideOutLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  .auth-wrapper.is-register .login-form {
    animation: slideOutRight 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  .auth-wrapper.is-login .login-form {
    animation: slideInLeftBounce 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94)
      forwards;
  }

  .auth-wrapper.is-register .register-form {
    animation: slideInRightBounce 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94)
      forwards;
  }

  .btn-primary {
    width: 100%;
    padding: 16px;
    font-size: 16px;
  }

  .switch-auth {
    text-align: center;
    margin-top: 25px;
  }

  .auth-message {
    margin-bottom: 15px;
    font-size: 13px;
  }
}

/* ===========================
    TOAST NOTIFICATIONS
=========================== */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  margin-bottom: 10px;
  min-width: 300px;
  max-width: 400px;
  padding: 0;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: auto;
  border-left: 4px solid;
}

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

.toast-error {
  border-left-color: #ef4444;
}

.toast-success {
  border-left-color: #10b981;
}

.toast-info {
  border-left-color: #3b82f6;
}

.toast-content {
  display: flex;
  align-items: center;
  padding: 16px;
  gap: 12px;
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-error .toast-icon {
  color: #ef4444;
}

.toast-success .toast-icon {
  color: #10b981;
}

.toast-content span {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-main);
}

.toast-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 16px;
  line-height: 1;
  transition: color 0.2s ease;
}

.toast-close:hover {
  color: var(--text-main);
}
