@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700&display=swap');

:root {
  --bg:        #080b12;
  --surface:   #0e1420;
  --card:      #131a28;
  --border:    #1e2d45;
  --accent:    #6c63ff;
  --accent2:   #a78bfa;
  --glow:      #6c63ff66;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --danger:    #f43f5e;
  --success:   #34d399;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  font-family: 'Vazirmatn', 'B Nazanin', sans-serif;
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

/* ── CANVAS BACKGROUND ── */
#bgCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── AUTH BOX ── */
.login-box {
  position: relative;
  z-index: 10;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  width: 90%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 0 60px var(--glow), 0 24px 48px rgba(0,0,0,0.5);
  animation: fadeUp 0.5s ease both;
}

.login-box::before {
  content: '';
  position: absolute;
  top: -1px; left: 20%; right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-box h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

/* ── INPUTS ── */
input, textarea {
  width: 100%;
  padding: 12px 16px;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input::placeholder, textarea::placeholder { color: var(--muted); }

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}

textarea {
  height: 100px;
  resize: vertical;
  margin-top: 8px;
}

/* ── BUTTONS ── */
button {
  margin-top: 14px;
  padding: 12px 28px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity 0.15s;
}

button:active::after { opacity: 0.08; }

#loginBtn, #registerBtn, #verifyBtn, #saveBtn, #resetBtn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  box-shadow: 0 4px 20px var(--glow);
}

#loginBtn:hover, #registerBtn:hover, #verifyBtn:hover,
#saveBtn:hover, #resetBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px var(--glow);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

#logoutBtn {
  width: 100%;
  background: transparent;
  color: var(--danger);
  border: 1px solid #f43f5e44;
  margin-top: 20px;
}

#logoutBtn:hover { background: #f43f5e11; }

/* ── LINKS ── */
a {
  color: var(--accent2);
  text-decoration: none;
  font-size: 13px;
  margin-top: 10px;
  transition: color 0.2s;
}
a:hover { color: white; }

/* ── MESSAGES ── */
#loginMessage, #registerMessage, #otpMessage, #profileMessage, #resetMessage {
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
  min-height: 18px;
}

/* ── OTP BOX ── */
.otp-box {
  gap: 8px;
}

.otp-icon {
  font-size: 40px;
  margin-bottom: 4px;
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.08); }
}

.otp-desc {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.6;
}

.otp-desc span {
  color: var(--accent2);
  font-weight: 600;
}

/* ── OTP DIGIT INPUTS ── */
.otp-inputs {
  display: flex;
  gap: 10px;
  direction: ltr;
  margin: 12px 0 4px;
}

.otp-digit {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  padding: 0;
  margin-top: 0;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  caret-color: var(--accent);
}

.otp-digit:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
  transform: scale(1.08);
  outline: none;
}

.otp-digit:not(:placeholder-shown) {
  border-color: var(--accent2);
  color: var(--accent2);
}

/* ── TIMER ── */
.otp-timer-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  margin: 12px auto 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.otp-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: stroke-dashoffset 1s linear;
}

#timerText {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent2);
  position: relative;
  z-index: 1;
  direction: ltr;
}

/* ── RESEND LINK ── */
.resend-link {
  font-size: 13px;
  color: var(--accent2);
  cursor: pointer;
  transition: color 0.2s, opacity 0.2s;
}

.resend-link.disabled {
  color: var(--muted);
  pointer-events: none;
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── DASHBOARD ── */
.dashboard {
  position: relative;
  z-index: 10;
  width: 90%;
  max-width: 520px;
  margin: 40px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeUp 0.5s ease both;
}

.dashboard h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 24px;
  text-align: center;
  letter-spacing: -0.3px;
}

/* ── AVATAR ── */
.avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.avatar-wrapper {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
  border: 2px solid var(--accent);
  box-shadow: 0 0 24px var(--glow);
  transition: box-shadow 0.2s;
}

.avatar-wrapper:hover { box-shadow: 0 0 36px var(--glow); }

#avatarImg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-overlay {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 42%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.avatar-wrapper:hover .avatar-overlay { opacity: 1; }

.avatar-overlay span {
  color: white;
  font-size: 10px;
  font-weight: 500;
}

/* ── PROFILE CARD ── */
.profile-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 0 40px rgba(108,99,255,0.08);
}

.profile-card::before {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: -28px -28px 24px;
  border-radius: 20px 20px 0 0;
}

.profile-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
  width: 100%;
}

.profile-form input { margin-top: 0; }

.profile-form .full { grid-column: 1 / -1; }

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 12px;
}

/* ── CROP MODAL ── */
#cropModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.crop-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 0 60px var(--glow);
}

.crop-container {
  width: 100%;
  height: 300px;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
  margin-bottom: 16px;
}

.crop-container img {
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 0;
  border: none;
}

.crop-buttons { display: flex; gap: 10px; }

#cropConfirm {
  flex: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  box-shadow: 0 4px 16px var(--glow);
  margin-top: 0;
}

#cropCancel {
  flex: 1;
  background: transparent;
  color: var(--danger);
  border: 1px solid #f43f5e44;
  margin-top: 0;
}

/* ── RESET PAGE ── */
#resetBox { animation: fadeUp 0.5s ease both; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (max-width: 480px) {
  .profile-form { grid-template-columns: 1fr; }
  .profile-card { padding: 20px; }
  .login-box { padding: 30px 24px; }
  .otp-digit { width: 38px; height: 46px; font-size: 18px; }
  .otp-inputs { gap: 7px; }
}

/* ── PASSWORD PAGE ── */
.pass-input-wrap {
  position: relative;
  width: 100%;
  margin-top: 8px;
}

.pass-input-wrap input {
  margin-top: 0;
  padding-left: 44px;
}

.eye-btn {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  margin: 0;
  padding: 4px;
  color: var(--muted);
  transition: color 0.2s;
}

.eye-btn:hover { color: var(--text); }

/* ── شرایط رمز ── */
.pass-rules {
  width: 100%;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  transition: color 0.2s;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.rule.ok {
  color: var(--success);
  border-color: #34d39933;
  background: #34d3990f;
}

.rule-icon {
  font-size: 13px;
  font-weight: 700;
  width: 16px;
  text-align: center;
  color: var(--danger);
  transition: color 0.2s;
}

.rule.ok .rule-icon { color: var(--success); }

/* ── نوار قدرت ── */
.strength-wrap {
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.strength-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.4s ease, background 0.4s ease;
}

.strength-label {
  font-size: 12px;
  font-weight: 600;
  min-width: 40px;
  text-align: right;
}

#setPasswordBtn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  box-shadow: 0 4px 20px var(--glow);
  margin-top: 14px;
}

#setPasswordBtn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px var(--glow);
}

#passwordMessage {
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
  min-height: 18px;
}