/**
 * ========================================
 * 14-auth.css
 * ========================================
 * Назначение: Стили для авторизации
 * ========================================
 */

/* ========== Auth Modal ========== */

.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow: hidden;
}

.auth-modal.modal--visible {
  opacity: 1;
  visibility: visible;
}

.auth-modal .modal__overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* по умолчанию (светлая тема): не «чёрное окно» */
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(6px);
  z-index: 0;
}

html[data-theme="dark"] .auth-modal .modal__overlay {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
}

.auth-modal__content {
  position: relative;
  z-index: 1;
  max-width: 380px;
  width: 100%;
  padding: 0;
  overflow: hidden;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

.auth-modal.modal--visible .auth-modal__content {
  transform: scale(1) translateY(0);
}

.auth-modal__close {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1rem;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 10;
}

.auth-modal__close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.auth-modal__header {
  padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-md);
  text-align: center;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 55%, var(--accent-color) 100%);
  color: white;
}

.auth-modal__logo {
  font-size: 2.5rem;
  margin-bottom: var(--spacing-xs);
}

.auth-modal__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-modal__subtitle {
  font-size: 0.85rem;
  opacity: 0.9;
}

.auth-modal__form {
  padding: var(--spacing-md) var(--spacing-lg);
}

/* ========== Tabs ========== */

.auth-modal__tabs {
  display: flex;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-xs);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
}

.auth-modal__tab {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-modal__tab:hover {
  color: var(--color-text-primary);
}

.auth-modal__tab--active {
  background: var(--color-bg-primary);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* ========== Tab Content ========== */

.auth-modal__tab-content {
  display: none;
}

.auth-modal__tab-content--active {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* ========== Form Fields ========== */

.auth-modal__field {
  margin-bottom: var(--spacing-sm);
}

.auth-modal__label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.auth-modal__input {
  width: 100%;
  padding: 10px var(--spacing-md);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.auth-modal__input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.auth-modal__input::placeholder {
  color: var(--text-muted);
}

.auth-modal__hint {
  margin-top: var(--spacing-xs);
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.auth-modal__hint a {
  color: var(--primary-color);
  text-decoration: none;
}

.auth-modal__hint a:hover {
  text-decoration: underline;
}

/* ========== OTP Input ========== */

.auth-modal__input--otp {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5em;
  font-family: 'Courier New', monospace;
}

.auth-modal__link-btn {
  display: inline-block;
  margin-top: var(--spacing-sm);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--primary-color);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.auth-modal__link-btn:hover {
  color: var(--secondary-color);
}

.auth-modal__link-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== Submit Button ========== */

.auth-modal__submit {
  width: 100%;
  padding: 12px;
  margin-top: var(--spacing-sm);
  border: none;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.auth-modal__submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.28);
}

.auth-modal__submit:active {
  transform: translateY(0);
}

.auth-modal__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ========== Error Message ========== */

.auth-modal__error {
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-md);
  background: var(--color-error-bg);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-sm);
  color: var(--color-error);
  font-size: 0.875rem;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ========== Success Message ========== */

.auth-modal__success {
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-md);
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid #22c55e;
  border-radius: var(--radius-sm);
  color: #22c55e;
  font-size: 0.875rem;
  animation: fadeIn 0.3s ease;
}

/* ========== OTP Section ========== */

.auth-modal__otp-section {
  animation: fadeIn 0.3s ease;
}

.auth-modal__resend {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.auth-modal__cooldown {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-modal__back-btn {
  display: block;
  width: 100%;
  padding: var(--spacing-sm);
  margin-top: var(--spacing-md);
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-modal__back-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ========== Footer ========== */

.auth-modal__footer {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-primary);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--glass-border);
}

.auth-modal__footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.auth-modal__footer a:hover {
  text-decoration: underline;
}

/* ========== Login Button (in header) ========== */

.header__login-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header__login-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

/* ========== User Display (in header) ========== */

.user-display {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
}

.user-display__icon {
  font-size: 1rem;
}

.user-display__name {
  color: var(--color-text-primary);
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-display__logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  margin-left: var(--spacing-xs);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-display__logout:hover {
  background: var(--color-error-bg);
  color: var(--color-error);
}

/* ========== Modal Open State ========== */

body.modal-open {
  overflow: hidden;
  height: 100vh;
}

/* ========== Responsive ========== */

@media (max-width: 480px) {
  .auth-modal {
    padding: var(--spacing-md);
  }
  
  .auth-modal__content {
    width: 100%;
    max-width: none;
  }
  
  .auth-modal__header {
    padding: var(--spacing-lg);
  }
  
  .auth-modal__form {
    padding: var(--spacing-md);
  }
  
  .user-display__name {
    max-width: 80px;
  }
}

/* ========== Auth Required Section (SECURITY) ========== */

.auth-required-section {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-3xl) var(--spacing-lg);
  animation: fadeIn 0.6s ease;
}

/* Светлая тема по умолчанию (:root) — белые/нейтральные тона */
.auth-required-card {
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: var(--spacing-3xl) var(--spacing-2xl);
  background: linear-gradient(
    165deg,
    #ffffff 0%,
    #f8fafc 45%,
    #f1f5f9 100%
  );
  border-radius: var(--radius-xl);
  text-align: center;
  box-shadow:
    0 4px 24px rgba(15, 23, 42, 0.06),
    0 0 0 1px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

/* Декоративная полоска: спокойный акцент, не «тёмно-синий блок» */
.auth-required-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    rgba(37, 99, 235, 0.35) 0%,
    rgba(14, 165, 233, 0.3) 50%,
    rgba(37, 99, 235, 0.25) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: 200% 0; }
  50% { background-position: -200% 0; }
}

.auth-required-icon {
  font-size: 5rem;
  margin-bottom: var(--spacing-xl);
  display: inline-block;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 2px 12px rgba(15, 23, 42, 0.06));
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.auth-required-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  letter-spacing: -0.02em;
}

.auth-required-text {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xl);
  line-height: 1.7;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.auth-required-text strong {
  color: var(--primary-color);
  font-weight: 600;
}

.auth-required-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 16px 40px;
  background: var(--gradient-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.22);
  position: relative;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.auth-required-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.2), 
    transparent);
  transition: left 0.5s ease;
}

.auth-required-btn:hover::before {
  left: 100%;
}

.auth-required-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.28);
}

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

.auth-required-note {
  margin-top: var(--spacing-xl);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-required-note a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.auth-required-note a:hover {
  color: var(--secondary-color);
  text-decoration: underline;
}

/* Лёгкое свечение в углу — почти нейтральное для светлой темы */
.auth-required-card::after {
  content: '';
  position: absolute;
  bottom: -50%;
  right: -30%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(148, 163, 184, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* Светлая тема = отсутствие data-theme (см. 10-theme.js) — стили выше по умолчанию */

/* Опционально: если когда-либо выставят явно data-theme="light" */
html[data-theme="light"] .auth-required-section {
  background: var(--bg-secondary);
}

html[data-theme="light"] .auth-required-card {
  background: linear-gradient(165deg, #ffffff 0%, #fafbfc 50%, #f4f6f8 100%);
  border-color: rgba(15, 23, 42, 0.07);
  box-shadow:
    0 8px 30px rgba(15, 23, 42, 0.07),
    0 0 0 1px rgba(255, 255, 255, 0.9) inset,
    0 0 0 1px rgba(15, 23, 42, 0.05);
}

html[data-theme="light"] .auth-required-card::after {
  background: radial-gradient(circle, rgba(59, 130, 246, 0.05) 0%, transparent 68%);
}

/* Только явная тёмная тема (никаких : не light » — это ломало светлый режим без атрибута) */
html[data-theme="dark"] .auth-required-section {
  background: var(--bg-primary);
}

html[data-theme="dark"] .auth-required-card {
  background: linear-gradient(145deg,
    rgba(30, 41, 59, 0.95) 0%,
    rgba(15, 23, 42, 0.98) 100%);
  border: 1px solid rgba(37, 99, 235, 0.25);
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(37, 99, 235, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .auth-required-card::before {
  height: 4px;
  background: linear-gradient(90deg,
    var(--primary-color) 0%,
    var(--secondary-color) 50%,
    var(--accent-color) 100%);
}

html[data-theme="dark"] .auth-required-card::after {
  background: radial-gradient(circle, rgba(37, 99, 235, 0.1) 0%, transparent 70%);
}

html[data-theme="dark"] .auth-required-icon {
  filter: drop-shadow(0 4px 20px rgba(37, 99, 235, 0.28));
}

/* ========== Password Requirements Tooltip ========== */

.password-requirements {
  margin-top: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.password-requirements__title {
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  color: var(--color-text-primary);
}

.password-requirements__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.password-requirements__item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 2px 0;
}

.password-requirements__item--valid {
  color: var(--color-success);
}

.password-requirements__item--invalid {
  color: var(--color-text-muted);
}

.password-requirements__item::before {
  content: '○';
  font-size: 0.6rem;
}

.password-requirements__item--valid::before {
  content: '●';
  color: var(--color-success);
}

