:root {
  --primary: #8E2C84;
  --primary-light: #C23E9D;
  --primary-dark: #5D1B57;
  --bg-color: #F4F7F6;
  --white: #FFFFFF;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --error: #EF4444;
  --success: #10B981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Vazirmatn', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  perspective: 1000px;
}

.scene-3d {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.floating-shape {
  position: absolute;
  border-radius: 20%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  opacity: 0.15;
  box-shadow: 0 20px 50px rgba(142, 44, 132, 0.4);
  animation: float3D 15s infinite ease-in-out alternate;
}

.shape-1 { width: 200px; height: 200px; top: 10%; left: 10%; transform: rotate(45deg); animation-delay: 0s; }
.shape-2 { width: 150px; height: 150px; bottom: 15%; right: 10%; border-radius: 50%; animation-delay: -3s; }
.shape-3 { width: 100px; height: 100px; top: 60%; left: 20%; transform: rotate(-20deg); animation-delay: -6s; }
.shape-4 { width: 120px; height: 120px; bottom: 40%; right: 30%; border-radius: 50%; background: linear-gradient(135deg, #FDE047, #F59E0B); opacity: 0.1; animation-delay: -9s; }

@keyframes float3D {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  50% { transform: translateY(-30px) rotate(180deg) scale(1.1); }
  100% { transform: translateY(30px) rotate(360deg) scale(0.9); }
}

.main-wrapper {
  z-index: 10;
  width: 100%;
  padding: 20px;
  display: flex;
  justify-content: center;
  perspective: 1000px;
}

.login-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  width: 100%;
  max-width: 440px;
  padding: 45px 35px;
  box-shadow:
    0 25px 50px -12px rgba(142, 44, 132, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  transform-style: preserve-3d;
  animation: cardEntrance 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  opacity: 0;
  transform: translateY(50px) rotateX(-10deg);
}

@keyframes cardEntrance {
  to { opacity: 1; transform: translateY(0) rotateX(0deg); }
}

.card-header {
  text-align: center;
  margin-bottom: 35px;
}

.rightel-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 15px;
}

.logo-icon {
  position: relative;
  width: 50%;
  height: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-outer {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 8px solid var(--primary);
  border-radius: 50%;
}

.ring-inner {
  position: absolute;
  width: 60%;
  height: 60%;
  border: 6px solid var(--primary-light);
  border-radius: 50%;
}

.logo-text {
  text-align: right;
  line-height: 1.2;
}

.logo-text .fa {
  display: block;
  font-size: 32px;
  font-weight: 900;
  color: var(--text-main);
}

.logo-text .en {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
}

.card-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 5px;
}

.card-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.form-group {
  position: relative;
  margin-bottom: 25px;
}

.form-group input {
  width: 100%;
  padding: 16px 45px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--white);
  font-size: 15px;
  color: var(--text-main);
  outline: none;
  transition: all 0.3s ease;
  font-family: inherit;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(142, 44, 132, 0.1);
}

.form-group label {
  position: absolute;
  top: 50%;
  right: 45px;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
  transition: all 0.3s ease;
  padding: 0 5px;
  background: transparent;
}

.form-group input:focus ~ label,
.form-group input:not(:placeholder-shown) ~ label {
  top: 0;
  right: 35px;
  font-size: 12px;
  color: var(--primary);
  background: var(--white);
  font-weight: 700;
}

.input-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  transition: color 0.3s;
  font-size: 18px;
}

.form-group input:focus ~ .input-icon {
  color: var(--primary);
}

.toggle-password {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: color 0.3s;
  padding: 5px;
}

.toggle-password:hover {
  color: var(--primary);
}

.captcha-container {
  display: flex;
  gap: 15px;
  margin-bottom: 30px;
}

.captcha-box {
  position: relative;
  width: 140px;
  height: 56px;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.captcha-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.captcha-loader {
  color: var(--primary);
  font-size: 20px;
}

.reload-captcha {
  position: absolute;
  top: 0;
  left: 0;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-bottom-right-radius: 12px;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}

.reload-captcha:hover {
  background: var(--primary);
  color: var(--white);
}

.captcha-input {
  flex: 1;
  margin-bottom: 0;
}

.submit-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
  font-family: inherit;
  box-shadow: 0 10px 20px -5px rgba(142, 44, 132, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.submit-btn::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 ease;
}

.submit-btn:not(:disabled):hover::before {
  left: 100%;
}

.submit-btn:not(:disabled):hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 25px -5px rgba(142, 44, 132, 0.5);
}

.submit-btn:not(:disabled):active {
  transform: translateY(1px);
}

.submit-btn:disabled {
  background: #CBD5E1;
  color: #94A3B8;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-loader {
  display: none;
}

.submit-btn.loading .btn-text { display: none; }
.submit-btn.loading .btn-loader { display: block; font-size: 20px; }

.form-footer {
  text-align: center;
  margin-top: 25px;
}

.form-footer a {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.3s;
  font-weight: 500;
}

.form-footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.toast-container {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--white);
  padding: 15px 25px;
  border-radius: 50px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 1000;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-container.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-container.error {
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.toast-container.success {
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.toast-icon {
  width: 40px;
  height: 40px;
}

.toast-message {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.checkmark__circle, .crossmark__circle {
  stroke-width: 4;
  stroke-miterlimit: 10;
  fill: none;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark__circle { stroke: var(--success); }
.checkmark__check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke: var(--success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

.crossmark__circle { stroke: var(--error); }
.crossmark__cross {
  stroke: var(--error);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

@keyframes stroke {
  100% { stroke-dashoffset: 0; }
}

.crossmark { display: none; }
.toast-container.error .checkmark { display: none; }
.toast-container.error .crossmark { display: block; }

@media (max-width: 480px) {
  .login-card { padding: 35px 25px; }
  .logo-text .fa { font-size: 26px; }
  .captcha-container { flex-direction: column; }
  .captcha-box { width: 100%; }
}

.login-theme-toggle {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(100, 30, 100, .25);
  background: rgba(142, 44, 132, .1);
  color: #5D1B57;
  backdrop-filter: blur(8px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background .2s, border-color .2s, color .2s;
  box-shadow: 0 2px 8px rgba(142,44,132,.15);
}
.login-theme-toggle:hover {
  background: rgba(142, 44, 132, .18);
  border-color: rgba(142, 44, 132, .4);
}
.login-theme-toggle .icon-sun { display: none; }
.login-theme-toggle .icon-moon { display: block; }

body.login-dark {
  background-color: #140d1c !important;
  --bg-color:    #140d1c;
  --text-main:   #f0e8f5;
  --text-muted:  #c0b4cc;
  --border:      rgba(255,255,255,.1);
  --white:       #2a1b34;
}

body.login-dark .scene-3d {
  background: radial-gradient(ellipse at 20% 30%, rgba(100,30,130,.35) 0%, transparent 55%),
              radial-gradient(ellipse at 80% 70%, rgba(60,10,80,.3)  0%, transparent 55%);
}

body.login-dark .floating-shape {
  opacity: .18;
  filter: hue-rotate(20deg) brightness(.7);
}

body.login-dark .login-card {
  background: rgba(28, 16, 38, 0.88);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 30px 90px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.04);
}

body.login-dark .card-header h2 { color: #f0e8f5; }
body.login-dark .card-header p  { color: #b0a4be; }

body.login-dark .form-group input {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.12);
  color: #f0e8f5;
}
body.login-dark .form-group input:focus {
  border-color: #c86bb0;
  background: rgba(255,255,255,.1);
  box-shadow: 0 0 0 3px rgba(200,107,176,.2);
}
body.login-dark .form-group input::placeholder { color: rgba(255,255,255,.25); }
body.login-dark .form-group label { color: #b0a4be; }
body.login-dark .form-group .input-icon { color: #9478a8; }
body.login-dark .toggle-password { color: #9478a8; }
body.login-dark .toggle-password:hover { color: #d8aed8; }

body.login-dark .captcha-box {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
}
body.login-dark .captcha-loader { color: #c86bb0; }

body.login-dark .submit-btn {
  background: linear-gradient(135deg, #9d2b8a, #6e1a60) !important;
  box-shadow: 0 8px 22px rgba(100,20,80,.4) !important;
}

body.login-dark .form-footer a { color: #c886c0; }

body.login-dark .login-theme-toggle {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.18);
  color: #f5e0f5;
}
body.login-dark .login-theme-toggle:hover {
  background: rgba(255,255,255,.18);
}
body.login-dark .login-theme-toggle .icon-sun  { display: block; }
body.login-dark .login-theme-toggle .icon-moon { display: none; }
