/* ============================================
   Reset & Base
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  color: var(--text);
  transition:
    background 0.3s ease,
    color 0.3s ease;
  padding: 1.5rem;
}

/* ============================================
   Variables (Light / Dark)
   ============================================ */
:root {
  --primary: #d62828;
  --primary-dark: #b71c1c;
  --primary-light: #ff6b6b;
  --primary-gradient: linear-gradient(135deg, #d62828, #b71c1c);
  --bg-light: #f0f2f5;
  --white: #ffffff;
  --black: #000000;
  --dark: #1a1a1a;
  --text: #2d2d2d;
  --text-light: #666666;
  --gray: #888888;
  --gray-light: #bbbbbb;
  --gray-lighter: #e8e8e8;
  --border: #dddddd;
  --border-focus: #d62828;
  --card-bg: #ffffff;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
  --shadow-hover: 0 12px 48px rgba(214, 40, 40, 0.2);
  --radius: 20px;
  --radius-sm: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --primary: #ff4d4d;
  --primary-dark: #ff1f1f;
  --primary-light: #ff6b6b;
  --primary-gradient: linear-gradient(135deg, #ff4d4d, #ff1f1f);
  --bg-light: #18181b;
  --white: #2a2a2a;
  --black: #ffffff;
  --dark: #e4e4e4;
  --text: #e4e4e4;
  --text-light: #aaaaaa;
  --gray: #aaaaaa;
  --gray-light: #666666;
  --gray-lighter: #3a3a3a;
  --border: #3a3a3a;
  --border-focus: #ff4d4d;
  --card-bg: #2a2a2a;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 12px 48px rgba(255, 77, 77, 0.2);
}

/* ============================================
   Auth Wrapper & Container
   ============================================ */
.auth-wrapper {
  width: 100%;
  max-width: 480px;
  animation: containerFadeUp 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes containerFadeUp {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.auth-container::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 4px;
  background: var(--primary-gradient);
}

/* ============================================
   Back Button
   ============================================ */
.auth-back {
  margin-bottom: 1.5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
}

.back-link:hover {
  color: var(--primary);
  background: rgba(0, 0, 0, 0.04);
  transform: translateX(4px);
}

/* ============================================
   Theme Toggle
   ============================================ */
.theme-toggle {
  position: absolute;
  top: 1.2rem;
  left: 1.2rem;
}

.theme-toggle button {
  background: rgba(0, 0, 0, 0.04);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle button:hover {
  background: var(--primary);
  color: #fff;
  transform: rotate(30deg);
}

/* ============================================
   Logo
   ============================================ */
.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo img {
  max-height: 60px;
  margin-bottom: 0.5rem;
}

.auth-logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

/* ============================================
   Header
   ============================================ */
.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  transition: var(--transition);
}

.auth-header p {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-top: 0.3rem;
}

/* ============================================
   Messages
   ============================================ */
.message {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  animation: messageSlide 0.4s ease;
}

@keyframes messageSlide {
  0% {
    opacity: 0;
    transform: translateY(-12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.error {
  background: #fee2e2;
  color: #991b1b;
  border-right: 4px solid #dc2626;
}

.message.success {
  background: #dcfce7;
  color: #166534;
  border-right: 4px solid #22c55e;
}

[data-theme="dark"] .message.error {
  background: #3b1a1a;
  color: #fca5a5;
  border-right-color: #dc2626;
}

[data-theme="dark"] .message.success {
  background: #1a3a2a;
  color: #86efac;
  border-right-color: #22c55e;
}

/* ============================================
   Form Sections
   ============================================ */
.form-section {
  animation: sectionFade 0.4s ease;
}

@keyframes sectionFade {
  0% {
    opacity: 0.5;
    transform: translateY(6px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   FORM ROW - با GRID AREA (چیدمان حرفه‌ای)
   ============================================ */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem 1rem;
  grid-template-areas:
    "first_name last_name"
    "username phone"
    "national_code email"
    "address address"
    "password password"
    "password_confirm password_confirm"
    "terms terms";
}

/* اختصاص grid-area به هر فیلد */
.first_name {
  grid-area: first_name;
}
.last_name {
  grid-area: last_name;
}
.username {
  grid-area: username;
}
.phone {
  grid-area: phone;
}
.national_code {
  grid-area: national_code;
}
.email {
  grid-area: email;
}
.address {
  grid-area: address;
}
.password {
  grid-area: password;
}
.password_confirm {
  grid-area: password_confirm;
}
.terms {
  grid-area: terms;
}

/* حذف margin-bottom از form-group داخل grid */
.form-row .form-group {
  margin-bottom: 0;
}

/* ============================================
   FORM GROUP
   ============================================ */
.form-group {
  position: relative;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.form-group label i {
  color: var(--primary);
  font-size: 0.9rem;
}

/* ============================================
   Input Wrapper
   ============================================ */
.input-wrapper {
  position: relative;
}

.input-wrapper input,
.input-wrapper textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  padding-right: 2.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  font-size: 1rem;
  transition: var(--transition);
  outline: none;
}

.input-wrapper textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.input-wrapper input:focus,
.input-wrapper textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(214, 40, 40, 0.12);
}

.input-wrapper input::placeholder,
.input-wrapper textarea::placeholder {
  color: var(--gray-light);
}

/* ============================================
   Input Icon
   ============================================ */
.input-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-light);
  font-size: 1rem;
  transition: var(--transition);
  pointer-events: none;
}

.input-wrapper textarea ~ .input-icon {
  top: 16px;
  transform: none;
}

.input-wrapper input:focus ~ .input-icon,
.input-wrapper textarea:focus ~ .input-icon {
  color: var(--primary);
}

/* ============================================
   Input Line Animation
   ============================================ */
.input-line {
  display: block;
  height: 2px;
  width: 0;
  background: var(--primary-gradient);
  transition: width 0.4s ease;
  margin-top: 2px;
  border-radius: 2px;
}

.input-wrapper input:focus ~ .input-line,
.input-wrapper textarea:focus ~ .input-line {
  width: 100%;
}

/* ============================================
   Password Wrapper
   ============================================ */
.password-wrapper input {
  padding-left: 3.5rem;
}

.toggle-password {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--gray);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.3rem;
  transition: var(--transition);
}

.toggle-password:hover {
  color: var(--primary);
}

/* ============================================
   Forgot Password (فقط برای ورود)
   ============================================ */
.forgot-password {
  text-align: left;
  margin-top: 0.5rem;
}

.forgot-password a {
  color: var(--text-light);
  font-size: 0.85rem;
  text-decoration: none;
  transition: var(--transition);
}

.forgot-password a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ============================================
   Terms Checkbox
   ============================================ */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-light);
  position: relative;
  padding-right: 2rem;
}

.checkbox-label input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 20px;
  width: 20px;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 4px;
  transition: var(--transition);
}

.checkbox-label:hover input ~ .checkmark {
  border-color: var(--primary);
}

.checkbox-label input:checked ~ .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}

.checkmark::after {
  content: "";
  position: absolute;
  display: none;
  right: 5px;
  top: 2px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-label input:checked ~ .checkmark::after {
  display: block;
}

.terms-text a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.terms-text a:hover {
  text-decoration: underline;
}

/* ============================================
   Submit Button
   ============================================ */
.btn-submit {
  width: 100%;
  padding: 0.95rem;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 1rem;
  box-shadow: 0 4px 14px rgba(214, 40, 40, 0.35);
  position: relative;
  overflow: hidden;
}

.btn-submit::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition:
    width 0.6s,
    height 0.6s,
    top 0.6s,
    left 0.6s;
}

.btn-submit:hover::after {
  width: 300px;
  height: 300px;
  top: -100px;
  left: -100px;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(214, 40, 40, 0.45);
}

.btn-submit:active {
  transform: scale(0.97);
}

.btn-submit i {
  transition: var(--transition);
}

.btn-submit .btn-loader {
  position: absolute;
}

/* ============================================
   Auth Toggle
   ============================================ */
.auth-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.auth-toggle p {
  color: var(--text-light);
  font-size: 0.95rem;
}

.toggle-link {
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.toggle-link:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--primary-dark);
  transform: translateX(4px);
}

/* ============================================
   Social Login
   ============================================ */
.auth-footer {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.auth-footer p {
  color: var(--text-light);
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
}

.social-login {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

.social-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.social-btn:hover {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.03);
  transform: translateY(-2px);
}

.social-btn.google i {
  color: #ea4335;
}

.social-btn.telegram i {
  color: #0088cc;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 480px) {
  .auth-container {
    padding: 1.8rem 1.2rem;
  }

  .auth-logo h1 {
    font-size: 1.4rem;
  }

  .auth-header h2 {
    font-size: 1.3rem;
  }

  .form-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "first_name"
      "last_name"
      "username"
      "phone"
      "national_code"
      "email"
      "address"
      "password"
      "password_confirm"
      "terms";
    gap: 0;
  }

  .social-login {
    flex-direction: column;
    align-items: center;
  }

  .social-btn {
    width: 100%;
    justify-content: center;
  }

  .theme-toggle {
    top: 0.8rem;
    left: 0.8rem;
  }

  .theme-toggle button {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }
}
