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

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #4ade80;
  color: #232323;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  z-index: 10000;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 6px;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  font-family: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.6)),
    url("/Img/Masal\,Guilan\,Iran.jpeg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  overflow-x: hidden;
  direction: rtl;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 100vh;
  padding: 20px;
}

.auth-section {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 40px 30px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  width: 100%;
}

.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.logo {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #232323;
  font-size: 1.8rem;
  box-shadow: 0 4px 15px rgba(74, 222, 128, 0.3);
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.05);
}

.logo-container h1 {
  color: #4ade80;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.auth-form {
  width: 100%;
  transition: all 0.3s ease;
}

.auth-form.hidden {
  display: none;
}

.form-title {
  color: #ffffff;
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 30px;
}

.form-group {
  width: 100%;
  margin-bottom: 24px;
}

.form-label {
  display: block;
  color: #f8fafc;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  text-align: right;
}

.input-container {
  position: relative;
  width: 100%;
}

.form-input {
  width: 100%;
  padding: 16px 20px;
  background: rgba(30, 30, 30, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 400;
  text-align: right;
  direction: rtl;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: "Vazirmatn", sans-serif;
}

.form-input:focus {
  outline: none;
  border-color: #4ade80;
  background: rgba(40, 40, 40, 0.9);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1);
  transform: translateY(-1px);
}

.form-input:valid {
  border-color: rgba(74, 222, 128, 0.5);
}

.form-input:invalid:not(:placeholder-shown) {
  border-color: rgba(239, 68, 68, 0.5);
}

.form-input::placeholder {
  color: #94a3b8;
  text-align: right;
  font-weight: 400;
}

.password-toggle {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.3s ease;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover,
.password-toggle:focus {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
  outline: none;
}

.auth-button {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  border: none;
  border-radius: 12px;
  color: #232323;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  font-family: "Vazirmatn", sans-serif;
  box-shadow: 0 5px 15px rgba(74, 222, 128, 0.3);
  min-height: 56px;
}

.auth-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  transform: translateY(-2px);
  box-shadow: 0 7px 20px rgba(74, 222, 128, 0.4);
}

.auth-button:focus {
  outline: 2px solid #4ade80;
  outline-offset: 2px;
}

.auth-button:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.button-text {
  display: inline-block;
  transition: opacity 0.3s ease;
}

.button-loader {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(35, 35, 35, 0.3);
  border-top: 2px solid #232323;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.auth-button.loading .button-text {
  opacity: 0;
}

.auth-button.loading .button-loader {
  display: block;
}

.form-switch {
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.switch-btn {
  background: none;
  border: none;
  color: #4ade80;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: all 0.3s ease;
  font-family: "Vazirmatn", sans-serif;
  font-size: 14px;
  margin-right: 5px;
  padding: 4px 8px;
  border-radius: 4px;
  min-height: 32px;
}

.switch-btn:hover,
.switch-btn:focus {
  text-decoration-color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
  outline: none;
}

.back-to-home {
  text-align: center;
  margin-top: 20px;
}

.back-to-home a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
  padding: 8px 12px;
  border-radius: 8px;
  min-height: 44px;
}

.back-to-home a:hover,
.back-to-home a:focus {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
  outline: none;
}

/* Animations */
@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-form {
  animation: fadeIn 0.5s ease;
}

/* Focus management */
.form-input:focus,
.password-toggle:focus,
.auth-button:focus,
.switch-btn:focus,
.back-to-home a:focus {
  outline: 2px solid #4ade80;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .auth-card {
    border: 2px solid #ffffff;
  }

  .form-input {
    border-width: 2px;
  }

  .form-input:focus {
    border-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .auth-form {
    animation: none;
  }
}

/* Tablet Responsive Design */
@media (max-width: 1024px) {
  .container {
    padding: 16px;
  }

  .auth-card {
    padding: 35px 25px;
  }

  .logo {
    width: 55px;
    height: 55px;
    font-size: 1.6rem;
  }

  .logo-container h1 {
    font-size: 1.4rem;
  }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
  body {
    background-attachment: scroll;
  }

  .container {
    padding: 12px;
    align-items: flex-start;
    padding-top: 40px;
  }

  .auth-section {
    width: 100%;
    max-width: 100%;
  }

  .auth-card {
    padding: 30px 20px;
    border-radius: 16px;
    margin: 0;
  }

  .logo-container {
    margin-bottom: 25px;
  }

  .logo {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  .logo-container h1 {
    font-size: 1.3rem;
  }

  .form-title {
    font-size: 1.2rem;
    margin-bottom: 25px;
  }

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

  .form-input {
    padding: 14px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .auth-button {
    padding: 14px;
    font-size: 14px;
    min-height: 52px;
  }

  .form-switch {
    font-size: 13px;
  }

  .switch-btn {
    font-size: 13px;
  }

  .back-to-home a {
    font-size: 13px;
  }
}

/* Small Mobile Responsive Design */
@media (max-width: 480px) {
  .container {
    padding: 8px;
    padding-top: 20px;
  }

  .auth-card {
    padding: 25px 16px;
    border-radius: 12px;
  }

  .logo {
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
  }

  .logo-container h1 {
    font-size: 1.2rem;
  }

  .form-title {
    font-size: 1.1rem;
  }

  .form-label {
    font-size: 13px;
  }

  .form-input {
    padding: 12px 14px;
    font-size: 16px;
    border-radius: 10px;
  }

  .password-toggle {
    left: 12px;
    min-width: 40px;
    min-height: 40px;
  }

  .auth-button {
    padding: 12px;
    font-size: 13px;
    min-height: 48px;
    border-radius: 10px;
  }

  .form-switch {
    font-size: 12px;
    line-height: 1.4;
  }

  .switch-btn {
    font-size: 12px;
  }

  .back-to-home a {
    font-size: 12px;
    gap: 6px;
  }
}

/* Extra Small Mobile */
@media (max-width: 360px) {
  .auth-card {
    padding: 20px 12px;
  }

  .form-input {
    padding: 10px 12px;
  }

  .password-toggle {
    left: 10px;
  }

  .auth-button {
    padding: 10px;
    min-height: 44px;
  }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .container {
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .auth-card {
    padding: 20px;
  }

  .logo-container {
    margin-bottom: 20px;
  }

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

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

/* Short screens */
@media (max-height: 700px) {
  .container {
    align-items: flex-start;
    padding-top: 30px;
  }

  .auth-card {
    padding: 25px;
  }

  .logo-container {
    margin-bottom: 20px;
  }

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

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

/* Very short screens */
@media (max-height: 600px) {
  .container {
    padding-top: 20px;
  }

  .auth-card {
    padding: 20px;
  }

  .logo-container {
    margin-bottom: 15px;
  }

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

  .form-title {
    margin-bottom: 15px;
    font-size: 1.1rem;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  .password-toggle,
  .switch-btn,
  .auth-button,
  .back-to-home a {
    min-height: 44px;
    min-width: 44px;
  }

  .form-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .password-toggle:hover {
    background: none;
    color: #94a3b8;
  }

  .password-toggle:active {
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
  }

  .switch-btn:hover {
    background: none;
    text-decoration-color: transparent;
  }

  .switch-btn:active {
    background: rgba(74, 222, 128, 0.1);
    text-decoration-color: #4ade80;
  }

  .back-to-home a:hover {
    background: none;
    color: #94a3b8;
  }

  .back-to-home a:active {
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
  }
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
  }

  .auth-card {
    background: white;
    box-shadow: none;
    border: 1px solid black;
  }

  .logo {
    background: #4ade80;
  }

  .auth-button {
    background: #4ade80;
    color: black;
  }
}
