/* ==========================================================================
   AquaPortal - Persian (Farsi) Theme with Vazirmatn Font & RTL Support
   ========================================================================== */

:root {
  /* Aqua Palette */
  --aqua-50: #f0fdfa;
  --aqua-100: #ccfbf1;
  --aqua-200: #99f6e4;
  --aqua-300: #5eead4;
  --aqua-400: #2dd4bf;
  --aqua-500: #14b8a6;
  --aqua-600: #0d9488;
  --aqua-700: #0f766e;

  /* Cyan / Blue-Aqua Accents */
  --cyan-400: #22d3ee;
  --cyan-500: #06b6d4;
  --cyan-600: #0891b2;

  /* Neutral Palette */
  --bg-page: #f6fbfa;
  --surface-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-light: #e2e8f0;
  --border-focus: #06b6d4;

  /* Status Colors */
  --error: #ef4444;
  --error-bg: #fef2f2;
  --success: #10b981;
  --success-bg: #ecfdf5;

  /* Elevations & Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 20px 45px -10px rgba(6, 182, 212, 0.12),
                 0 0 0 1px rgba(20, 184, 166, 0.08),
                 0 8px 16px -4px rgba(15, 23, 42, 0.04);
  --shadow-button: 0 4px 14px rgba(6, 182, 212, 0.35);
  --shadow-button-hover: 0 6px 20px rgba(6, 182, 212, 0.45);
  --shadow-input-focus: 0 0 0 4px rgba(6, 182, 212, 0.15);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Vazirmatn', 'Vazir', -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  line-height: 1.6;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Glowing Background Elements */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  z-index: 0;
  pointer-events: none;
  animation: floatAmbient 12s ease-in-out infinite alternate;
}

.glow-top-left {
  top: -100px;
  right: -80px;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, var(--aqua-200) 0%, var(--cyan-400) 50%, transparent 70%);
}

.glow-bottom-right {
  bottom: -120px;
  left: -80px;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, var(--aqua-300) 0%, var(--aqua-100) 55%, transparent 75%);
  animation-delay: -6s;
}

@keyframes floatAmbient {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(-30px, 40px) scale(1.08);
  }
}

/* Layout Wrapper */
.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: 24px 16px;
}

/* Login Card */
.login-card {
  background: var(--surface-card);
  border-radius: 24px;
  padding: 44px 38px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

/* Header & Brand Icon */
.card-header {
  text-align: center;
  margin-bottom: 28px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--cyan-500) 0%, var(--aqua-600) 100%);
  color: #ffffff;
  margin-bottom: 16px;
  box-shadow: 0 8px 18px rgba(6, 182, 212, 0.32);
}

.brand-icon {
  width: 28px;
  height: 28px;
}

.card-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Form Groups & Inputs */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.password-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.forgot-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--cyan-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.forgot-link:hover {
  color: var(--aqua-700);
  text-decoration: underline;
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
}

/* Right-aligned icon for RTL */
.input-icon {
  position: absolute;
  right: 14px;
  left: auto;
  width: 20px;
  height: 20px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: color var(--transition-fast);
}

.input-icon svg {
  width: 100%;
  height: 100%;
}

.form-input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 44px; /* Right for icon, Left for password toggle */
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background-color: #fafdfd;
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  outline: none;
  transition: all var(--transition-fast);
  text-align: right;
}

.form-input[type="email"] {
  direction: ltr;
  text-align: right;
}

.form-input[type="email"]:focus,
.form-input[type="email"]:not(:placeholder-shown) {
  text-align: left;
}

.form-input::placeholder {
  color: #94a3b8;
  font-family: 'Vazirmatn', inherit;
  direction: rtl;
  text-align: right;
}

.form-input:hover {
  border-color: #cbd5e1;
  background-color: #ffffff;
}

.form-input:focus {
  border-color: var(--border-focus);
  background-color: #ffffff;
  box-shadow: var(--shadow-input-focus);
}

/* Accent icon color when input is focused */
.input-container:focus-within .input-icon {
  color: var(--cyan-600);
}

/* Left-aligned Toggle Password Button for RTL */
.toggle-password {
  position: absolute;
  left: 12px;
  right: auto;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.toggle-password:hover {
  color: var(--text-secondary);
  background-color: var(--aqua-50);
}

.toggle-password:focus-visible {
  outline: 2px solid var(--cyan-500);
}

.eye-icon {
  width: 19px;
  height: 19px;
}

.hidden {
  display: none !important;
}

/* Validation Error Styles */
.form-group.has-error .form-input {
  border-color: var(--error);
  background-color: var(--error-bg);
}

.form-group.has-error .input-icon {
  color: var(--error);
}

.form-group.has-error .form-input:focus {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

.error-text {
  font-size: 0.8rem;
  color: var(--error);
  font-weight: 500;
  min-height: 18px;
  display: none;
  animation: fadeIn 0.2s ease-in;
}

.form-group.has-error .error-text {
  display: block;
}

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

/* Remember Me Checkbox */
.options-row {
  display: flex;
  align-items: center;
  margin: 2px 0 6px 0;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.custom-checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.checkmark svg {
  width: 12px;
  height: 12px;
  color: #ffffff;
  opacity: 0;
  transform: scale(0.6);
  transition: all var(--transition-fast);
}

.custom-checkbox:hover input ~ .checkmark {
  border-color: var(--cyan-500);
}

.custom-checkbox input:checked ~ .checkmark {
  background: linear-gradient(135deg, var(--cyan-500) 0%, var(--aqua-600) 100%);
  border-color: transparent;
}

.custom-checkbox input:checked ~ .checkmark svg {
  opacity: 1;
  transform: scale(1);
}

.custom-checkbox input:focus-visible ~ .checkmark {
  box-shadow: var(--shadow-input-focus);
}

.checkbox-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Primary Button */
.btn-primary {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--cyan-500) 0%, var(--aqua-600) 100%);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-button);
  transition: all var(--transition-fast);
  margin-top: 6px;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #08c0df 0%, #0e9f92 100%);
  box-shadow: var(--shadow-button-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-button);
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.35);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Button Loading Spinner */
.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  margin: 26px 0 20px 0;
  text-align: center;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.divider-text {
  padding: 0 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #94a3b8;
}

/* Social Buttons */
.social-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.social-btn {
  height: 44px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background-color: #ffffff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.social-btn:hover {
  background-color: var(--aqua-50);
  border-color: var(--aqua-300);
  color: var(--aqua-700);
  transform: translateY(-1px);
}

.social-btn:active {
  transform: translateY(1px);
}

.social-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-input-focus);
}

.social-icon {
  width: 18px;
  height: 18px;
}

/* Footer Section */
.card-footer {
  text-align: center;
  margin-top: 26px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.signup-link {
  color: var(--cyan-600);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.signup-link:hover {
  color: var(--aqua-700);
  text-decoration: underline;
}

/* Toast Notifications (RTL aligned) */
.toast-container {
  position: fixed;
  top: 24px;
  left: 24px;
  right: auto;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 380px;
  padding: 14px 18px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  transform: translateX(-120%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  direction: rtl;
  text-align: right;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.success {
  border-right: 4px solid var(--aqua-500);
  border-left: none;
  color: var(--text-primary);
}

.toast.error {
  border-right: 4px solid var(--error);
  border-left: none;
  color: var(--text-primary);
}

.toast.info {
  border-right: 4px solid var(--cyan-500);
  border-left: none;
  color: var(--text-primary);
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast.success .toast-icon {
  color: var(--aqua-600);
}

.toast.error .toast-icon {
  color: var(--error);
}

.toast.info .toast-icon {
  color: var(--cyan-600);
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .login-card {
    padding: 32px 22px;
    border-radius: 20px;
  }

  .card-title {
    font-size: 1.45rem;
  }

  .toast-container {
    top: 16px;
    left: 16px;
    right: 16px;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}
