:root {
  /* Match global palette from styles.css */
  --primary-color: #3498db;
  --secondary-color: #2980b9; /* used as darker primary for gradients */
  --background-color: #eef2f7;
  --text-color: #1f2933;
  --muted-text: #5b6b7b;
  --error-color: #e74c3c;
  --card-bg: rgba(255, 255, 255, 0.72);
  --card-border: rgba(255, 255, 255, 0.6);
  --input-bg: rgba(255, 255, 255, 0.65);
  --input-border: rgba(148, 163, 184, 0.35);
  --shadow-color: rgba(31, 41, 51, 0.12);
  --blob-1: #60a5fa;
  --blob-2: #818cf8;
  --blob-3: #38bdf8;
}

.dark-theme {
  /* Align with site's dark theme */
  --primary-color: #3498db;
  --secondary-color: #2980b9;
  --background-color: #0f1115;
  --text-color: #e8edf2;
  --muted-text: #9aa6b2;
  --error-color: #ef4444;
  --card-bg: rgba(30, 34, 42, 0.66);
  --card-border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.06);
  --input-border: rgba(255, 255, 255, 0.12);
  --shadow-color: rgba(0, 0, 0, 0.5);
  --blob-1: #2563eb;
  --blob-2: #4f46e5;
  --blob-3: #0ea5e9;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Vazirmatn', sans-serif;
  background-color: var(--background-color);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text-color);
  transition: background-color 0.4s ease, color 0.4s ease;
  position: relative;
}

/* Animated gradient mesh background */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  z-index: 0;
  pointer-events: none;
  animation: floatBlob 14s ease-in-out infinite alternate;
}

body::before {
  width: 480px;
  height: 480px;
  top: -120px;
  right: -80px;
  background: radial-gradient(circle at 30% 30%, var(--blob-1), var(--blob-2));
}

body::after {
  width: 420px;
  height: 420px;
  bottom: -140px;
  left: -100px;
  background: radial-gradient(circle at 70% 70%, var(--blob-3), var(--blob-1));
  animation-delay: -7s;
}

@keyframes floatBlob {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(-40px, 40px) scale(1.15);
  }
}

.login-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: transparent;
  z-index: 1000;
  pointer-events: none;
}

.login-header > * {
  pointer-events: all;
}

.main-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  height: 100vh;
  padding: 20px;
  gap: 40px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* Floating glass control buttons */
.theme-toggle,
.home-button {
  position: fixed;
  top: 20px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  color: var(--text-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  font-size: 1.2rem;
  text-decoration: none;
  box-shadow: 0 6px 18px var(--shadow-color);
  transition: transform 0.4s ease, background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle {
  left: 20px;
  font-family: 'Vazirmatn', sans-serif;
}

.home-button {
  right: 20px;
}

.theme-toggle:hover,
.home-button:hover {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff;
  transform: translateY(-2px) rotate(360deg);
  box-shadow: 0 10px 26px rgba(52, 152, 219, 0.45);
}

.theme-toggle i {
  font-size: 1.4rem;
}

.home-button i {
  font-size: 1.3rem;
}

/* Glassmorphism login card */
.login-box {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 38px 32px;
  border-radius: 24px;
  border: 1px solid var(--card-border);
  box-shadow: 0 24px 60px var(--shadow-color);
  width: 100%;
  max-width: 400px;
  height: 480px;        /* ارتفاع ثابت تا با اضافه‌کردن input جمع/باز نشود */
  max-height: 86vh;     /* روی صفحه‌های کوتاه از این بیشتر نشود */
  text-align: center;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  overflow-y: auto;     /* اگر محتوا بیشتر شد، داخل خودِ باکس اسکرول شود */
  animation: cardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-box:hover {
  transform: translateY(-6px);
  box-shadow: 0 30px 70px var(--shadow-color);
}

.login-box h2 {
  margin: 0 0 26px;
  color: var(--text-color);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login-box h2::after {
  content: "";
  display: block;
  width: 56px;
  height: 4px;
  margin: 12px auto 0;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.input-group {
  position: relative;
  margin-bottom: 18px;
  padding: 0 4px;
  text-align: right;
}

.input-group input {
  width: 100%;
  padding: 15px 18px;
  border: 1.5px solid var(--input-border);
  border-radius: 14px;
  font-size: 1rem;
  font-family: 'Vazirmatn', sans-serif;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
  background-color: var(--input-bg);
  color: var(--text-color);
}

.input-group input:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.18);
  background-color: var(--card-bg);
}

.input-group input::placeholder {
  color: var(--muted-text);
  opacity: 0.85;
  transition: opacity 0.3s ease;
}

.input-group input:focus::placeholder {
  opacity: 0.45;
}

.login-box button,
.login-button {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  background-size: 180% 180%;
  color: #fff;
  border: none;
  padding: 15px;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: 'Vazirmatn', sans-serif;
  cursor: pointer;
  width: 100%;
  margin: 12px 0 4px;
  transition: transform 0.25s ease, box-shadow 0.3s ease, background-position 0.5s ease;
  box-shadow: 0 10px 24px rgba(52, 152, 219, 0.35);
}

.login-box button:hover,
.login-button:hover {
  transform: translateY(-2px);
  background-position: 100% 100%;
  box-shadow: 0 14px 32px rgba(52, 152, 219, 0.5);
}

.login-box button:active,
.login-button:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(52, 152, 219, 0.35);
}

.error {
  color: var(--error-color);
  font-size: 0.9rem;
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.25);
  animation: shake 0.5s ease;
}

.error p {
  margin: 0;
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

.text-danger {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--error-color);
  text-align: right;
}

/* Help Section Styles */
.help-section {
  max-width: 400px;
  width: 90%;
  margin: 0;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: 0 24px 60px var(--shadow-color);
  padding: 0;
  border: 1px solid var(--card-border);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  max-height: 86vh;
  overflow-y: auto;
  animation: cardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.help-section:hover {
  transform: translateY(-6px);
  box-shadow: 0 30px 70px var(--shadow-color);
}

.help-content {
  padding: 26px 22px;
  text-align: center;
}

.help-icon {
  color: var(--primary-color);
  font-size: 2rem;
  margin-bottom: 14px;
  display: block;
}

.help-text {
  color: var(--muted-text);
  line-height: 1.7;
}

.help-text p {
  margin: 8px 0;
  font-size: 0.92rem;
}

.help-text p:first-child {
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--text-color);
  font-size: 1.05rem;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white !important;
  text-decoration: none;
  padding: 11px 22px;
  border-radius: 30px;
  font-weight: 500;
  font-size: 0.9rem;
  margin-top: 16px;
  transition: transform 0.25s ease, box-shadow 0.3s ease;
  box-shadow: 0 8px 20px rgba(52, 152, 219, 0.35);
}

.contact-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(52, 152, 219, 0.5);
  text-decoration: none;
}

.contact-link i {
  font-size: 0.9rem;
}

/* Custom scrollbar inside cards */
.login-box::-webkit-scrollbar,
.help-section::-webkit-scrollbar {
  width: 6px;
}

.login-box::-webkit-scrollbar-thumb,
.help-section::-webkit-scrollbar-thumb {
  background: var(--input-border);
  border-radius: 6px;
}

/* برای تبلت و صفحات متوسط */
@media screen and (max-width: 1024px) and (min-width: 769px) {
  .main-container {
    gap: 30px;
    padding: 20px 15px 20px;
  }
}

/* برای موبایل */
@media screen and (max-width: 768px) {
  .main-container {
    flex-direction: column;
    gap: 16px;
    padding: 80px 12px 20px;
    height: 100vh;
    overflow-y: auto;
  }

  .login-box {
    padding: 26px 22px;
    max-width: 90%;
    margin: 0;
    max-height: 52vh;
  }

  .help-section {
    max-width: 90%;
    margin: 0;
    max-height: 38vh;
  }
}

@media screen and (max-width: 480px) {
  .login-box {
    padding: 22px 18px;
    max-width: 88%;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 52vh;
  }

  .main-container {
    flex-direction: column;
    gap: 12px;
    padding: 70px 10px 15px;
    height: 100vh;
    overflow-y: auto;
  }

  .login-box form {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .login-box h2 {
    font-size: 1.45rem;
    margin-bottom: 20px;
    width: 100%;
    text-align: center;
  }

  .input-group {
    margin-bottom: 14px;
    width: 100%;
  }

  .input-group input {
    padding: 13px 16px;
    font-size: 0.95rem;
    width: 100%;
  }

  .login-box button,
  .login-button {
    padding: 13px;
    font-size: 1rem;
    width: 100%;
    margin: 12px 0 4px;
  }

  /* Help Section Mobile Styles */
  .help-section {
    max-width: 88%;
    margin: 0;
    padding: 0;
    max-height: 38vh;
  }

  .help-content {
    padding: 18px;
  }

  .help-icon {
    font-size: 1.6rem;
    margin-bottom: 10px;
  }

  .help-text p {
    font-size: 0.82rem;
    margin: 6px 0;
  }

  .help-text p:first-child {
    font-size: 0.92rem;
    margin-bottom: 12px;
  }

  .contact-link {
    padding: 9px 18px;
    font-size: 0.82rem;
    margin-top: 12px;
  }

  .contact-link i {
    font-size: 0.82rem;
  }
}

/* برای تبلت */
@media screen and (min-width: 481px) and (max-width: 768px) {
  .login-box {
    padding: 28px 24px;
    max-width: 80%;
    max-height: 52vh;
  }

  .main-container {
    flex-direction: column;
    gap: 16px;
    padding: 80px 10px 20px;
    height: 100vh;
    overflow-y: auto;
  }

  /* Help Section Tablet Styles */
  .help-section {
    max-width: 80%;
    max-height: 38vh;
  }

  .help-content {
    padding: 20px;
  }

  .help-text p {
    font-size: 0.88rem;
  }

  .help-text p:first-child {
    font-size: 1rem;
  }

  .contact-link {
    padding: 10px 20px;
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  .login-box,
  .help-section {
    animation: none;
  }
}
