.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
  padding: 16px;
}

.login-dialog {
  position: relative;
  background: var(--bg-card, #fff);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: scaleIn 0.25s ease;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--bg-hover, #f0f0f0);
  color: var(--text-secondary, #666);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;

  &:hover {
    background: #e0e0e0;
    color: #333;
  }
}

.login-icon {
  margin: 0 auto 16px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-light, rgba(73, 118, 113, 0.1));
  color: var(--accent-color, #497671);
  display: flex;
  align-items: center;
  justify-content: center;
}

h2 {
  margin: 0 0 8px;
  font-size: var(--font-size-2xl, 1.25rem);
  font-weight: var(--font-weight-bold, 700);
  color: var(--text-primary, #1a1a1a);
}

.login-desc {
  margin: 0 0 24px;
  font-size: var(--font-size-base, 0.875rem);
  color: var(--text-secondary, #666);
  line-height: 1.5;
}

.telegram-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-md, 12px);
  background: #2AABEE;
  color: #fff;
  font-size: var(--font-size-lg, 1rem);
  font-weight: var(--font-weight-semibold, 600);
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    background: #229ED9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(42, 171, 238, 0.3);
  }

  &:active {
    transform: translateY(0);
  }

  .tg-icon {
    flex-shrink: 0;
  }
}

.bot-link {
  display: block;
  margin-top: 10px;
  color: var(--accent-color, #497671);
  font-size: var(--font-size-xs, 0.75rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

.qr-section {
  margin-top: 20px;

  .qr-hint {
    margin: 0 0 12px;
    font-size: var(--font-size-sm, 0.8125rem);
    color: var(--text-secondary, #999);
  }

  .qr-container {
    display: inline-flex;
    padding: 12px;
    background: #fff;
    border-radius: var(--radius-md, 12px);
    border: 1px solid #e8e8e8;

    img {
      display: block;
      border-radius: var(--radius-xs, 4px);
    }

    &.qr-loading {
      align-items: center;
      justify-content: center;
      width: 204px;
      height: 204px;

      .spinner {
        width: 32px;
        height: 32px;
        border: 3px solid #e0e0e0;
        border-top-color: var(--accent-color, #497671);
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
      }
    }

    &.qr-expired {
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      width: 204px;
      height: 204px;
      cursor: pointer;
      color: var(--text-secondary, #999);
      transition: color 0.2s ease;

      &:hover {
        color: var(--accent-color, #497671);
      }

      span {
        font-size: var(--font-size-sm, 0.8125rem);
      }
    }

    &.qr-error {
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      width: 204px;
      height: 204px;
      cursor: pointer;
      color: var(--text-secondary, #999);
      transition: color 0.2s ease;

      &:hover {
        color: var(--accent-color, #497671);
      }

      span {
        font-size: var(--font-size-sm, 0.8125rem);
      }
    }
  }
}

.credentials-toggle {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  border: none;
  background: none;
  color: var(--accent-color, #497671);
  font-size: var(--font-size-sm, 0.8125rem);
  cursor: pointer;

  &:hover {
    text-decoration: underline;
  }
}

.credentials-form {
  margin-top: 16px;
  text-align: left;

  label {
    display: block;
    margin-bottom: 12px;
    font-size: var(--font-size-sm, 0.8125rem);
    color: var(--text-secondary, #666);

    input {
      display: block;
      width: 100%;
      margin-top: 6px;
      padding: 10px 12px;
      border: 1px solid #e0e0e0;
      border-radius: var(--radius-md, 12px);
      font-size: var(--font-size-base, 0.875rem);
      color: var(--text-primary, #1a1a1a);
      background: var(--bg-card, #fff);

      &:focus {
        outline: none;
        border-color: var(--accent-color, #497671);
      }
    }
  }

  .credentials-error {
    margin: 0 0 12px;
    font-size: var(--font-size-xs, 0.75rem);
    color: #d32f2f;
    line-height: 1.4;
  }

  .credentials-actions {
    display: flex;
    gap: 10px;
  }

  .credentials-submit {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md, 12px);
    background: var(--accent-color, #497671);
    color: #fff;
    font-size: var(--font-size-base, 0.875rem);
    font-weight: var(--font-weight-semibold, 600);
    cursor: pointer;
    transition: opacity 0.2s ease;

    &:disabled {
      opacity: 0.6;
      cursor: wait;
    }
  }

  .credentials-back {
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-md, 12px);
    background: none;
    color: var(--text-secondary, #666);
    font-size: var(--font-size-base, 0.875rem);
    cursor: pointer;
  }
}

.login-note {
  margin: 16px 0 0;
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--text-secondary, #999);
  line-height: 1.4;
}

.login-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  color: var(--text-secondary, #666);
  font-size: var(--font-size-base, 0.875rem);

  .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: var(--accent-color, #497671);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@media (max-width: 480px) {
  .login-dialog {
    padding: 24px 20px;
    border-radius: 16px;
  }

  .qr-section .qr-container img {
    width: 140px;
    height: 140px;
  }
}
